[R] Strange warning in summary.lm

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Wed Jul 25 11:04:43 CEST 2007


Dear Peter, Uwe and Brian,

I've found some more problems with options(OutDec = ",").

1) as.numeric yields NA where it shouldn't

> z <- c("12", "12,34", "12.34")
> options(OutDec = ",")
> as.numeric(z)
[1] 12,00    NA 12,34
Warning message:
NAs introduced by coercion in: as.double.default(z) 

# should result in c(12, 12.34, NA)

> options(OutDec = ".")
> as.numeric(z)
[1] 12.00    NA 12.34
Warning message:
NAs introduced by coercion in: as.double.default(z) 


2) anova yields the same warning as summary

> x <- runif(100)
> y <- rnorm(100)
> options(OutDec = ",")
> summary(lm(y~x))

Call:
lm(formula = y ~ x)

Residuals:
     Min       1Q   Median       3Q      Max 
-2,81744 -0,61680  0,02107  0,66309  2,20599 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)
(Intercept) -0,073531   0,195880  -0,375    0,708
x            0,007519   0,318159   0,024    0,981

Residual standard error: 0,9795 on 98 degrees of freedom
Multiple R-Squared: 5.699e-06,  Adjusted R-squared: -0.0102 
F-statistic: 0.0005585 on 1 and 98 DF,  p-value: 0,9812 

Warning message:
NAs introduced by coercion in: as.double.default(Cf[okP]) 
> anova(lm(y~x))
Analysis of Variance Table

Response: y
          Df Sum Sq Mean Sq F value Pr(>F)
x          1  0,001   0,001   6e-04 0,9812
Residuals 98 94,031   0,960               
Warning message:
NAs introduced by coercion in: as.double.default(Cf[okP]) 

Cheers,

Thierry


----------------------------------------------------------------------------
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx op inbo.be
www.inbo.be 

Do not put your faith in what statistics say until you have carefully considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney

 

> -----Oorspronkelijk bericht-----
> Van: r-help-bounces op stat.math.ethz.ch 
> [mailto:r-help-bounces op stat.math.ethz.ch] Namens ONKELINX, Thierry
> Verzonden: donderdag 19 juli 2007 13:56
> Aan: Peter Dalgaard
> CC: r-help op stat.math.ethz.ch; Uwe Ligges
> Onderwerp: Re: [R] Strange warning in summary.lm
> 
> Dear Peter,
> 
> Here's an example. Notice the warning in the last two lines 
> of the summary with options(OutDec = ","). It's not present 
> with options(OutDec = ".").
> 
> Cheers,
> 
> Thierry
> 
> > x <- runif(100)
> > y <- rnorm(100)
> > options(OutDec = ",")
> > summary(lm(y~x))
> 
> Call:
> lm(formula = y ~ x)
> 
> Residuals:
>       Min        1Q    Median        3Q       Max 
> -2,389749 -0,607002  0,006969  0,689535  1,713197 
> 
> Coefficients:
>             Estimate Std. Error t value Pr(>|t|)
> (Intercept)  0,03397    0,17774   0,191    0,849
> x           -0,09219    0,29518  -0,312    0,755
> 
> Residual standard error: 0,868 on 98 degrees of freedom 
> Multiple R-Squared: 0.0009943,  Adjusted R-squared: -0.0092
> F-statistic: 0.09754 on 1 and 98 DF,  p-value: 0,7555 
> 
> Warning message:
> NAs introduced by coercion in: as.double.default(Cf[okP]) 
> > options(OutDec = ".")
> > summary(lm(y~x))
> 
> Call:
> lm(formula = y ~ x)
> 
> Residuals:
>       Min        1Q    Median        3Q       Max 
> -2.389749 -0.607002  0.006969  0.689535  1.713197 
> 
> Coefficients:
>             Estimate Std. Error t value Pr(>|t|)
> (Intercept)  0.03397    0.17774   0.191    0.849
> x           -0.09219    0.29518  -0.312    0.755
> 
> Residual standard error: 0.868 on 98 degrees of freedom 
> Multiple R-Squared: 0.0009943,  Adjusted R-squared: -0.0092
> F-statistic: 0.09754 on 1 and 98 DF,  p-value: 0.7555 
> 
> 
> --------------------------------------------------------------
> --------------
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute 
> for Nature and Forest
> Cel biometrie, methodologie en kwaliteitszorg / Section 
> biometrics, methodology and quality assurance
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
> tel. + 32 54/436 185
> Thierry.Onkelinx op inbo.be
> www.inbo.be 
> 
> Do not put your faith in what statistics say until you have 
> carefully considered what they do not say.  ~William W. Watt
> A statistical analysis, properly conducted, is a delicate 
> dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney
> 
>  
> 
> > -----Oorspronkelijk bericht-----
> > Van: Peter Dalgaard [mailto:P.Dalgaard op biostat.ku.dk] 
> > Verzonden: donderdag 19 juli 2007 13:37
> > Aan: ONKELINX, Thierry
> > CC: Uwe Ligges; r-help op stat.math.ethz.ch
> > Onderwerp: Re: [R] Strange warning in summary.lm
> > 
> > ONKELINX, Thierry wrote:
> > > The problem also exists in a clean workspace. But I've found the 
> > > troublemaker. I had set options(OutDec = ","). Resetting this to 
> > > options(OutDec = ".") solved the problem.
> > >
> > > Thanks,
> > >
> > > Thierry
> > >   
> > Oups. That sounds like there's a bug somewhere. Can you cook 
> > up a minimal example which shows the behaviour?
> > 
> > -- 
> >    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
> >   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
> >  (*) \(*) -- University of Copenhagen   Denmark          Ph:  
> > (+45) 35327918
> > ~~~~~~~~~~ - (p.dalgaard op biostat.ku.dk)                  FAX: 
> > (+45) 35327907
> > 
> > 
> >
> 
> ______________________________________________
> R-help op stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list