[R] Strange warning in summary.lm

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Jul 19 14:53:06 CEST 2007


Ah, in  printCoefmat() there is Cf which is at some point:

Cf

             Estimate  Std. Error t value  Pr(>|t|)
(Intercept) " 0,2542" " 0,1875"  " 1,356" ""
x           "-0,5346" " 0,3463"  "-1,544" ""

and

cat(Cf)
    0,2542 -0,5346  0,1875  0,3463  1,356 -1,544

(i.e. values are character) and then
    x0 <- (xm[okP] == 0) != (as.numeric(Cf[okP]) == 0)
includes as.numeric(Cf[okP]) which won't work any more.



I think this design is not the best possible. Nevertheless, the real 
problem is in format(), because it does not use its default 
`decimal.mark = "."' if options(OutDec = ",") has been set, and even 
ignores manual chosen values:


# nice:
  options(OutDec = ".")
  format(0.1, decimal.mark = ":") #  [1] "0:1"

# bug:
  options(OutDec = ",")
  format(0.1, decimal.mark = ":") #  [1] "0,1"

Best,
Uwe







ONKELINX, Thierry wrote:
> 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 at 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 at biostat.ku.dk] 
>> Verzonden: donderdag 19 juli 2007 13:37
>> Aan: ONKELINX, Thierry
>> CC: Uwe Ligges; r-help at 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 at biostat.ku.dk)                  FAX: 
>> (+45) 35327907
>>
>>
>>
> 
> ______________________________________________
> R-help at 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