Hi Peter,

> On Apr 5, 2019, at 7:22 AM, peter dalgaard <pda...@gmail.com> wrote:
> 
> Can't you just check for NA coefficients?
> 
>> y <- rnorm(10) ; x <- rep(0,10)
>> coef(lm(y~x))
> (Intercept)           x 
> -0.0962404          NA 
> 
> so 
> 
>> any(is.na(coef(lm(y~x))))
> [1] TRUE
> 
> I have a vague recollection that at some point there might have been dragons 
> lurking in there (? - NA coefs silently removed), but I can't see a problem 
> with it presently.

I think that the problem you recall related to vcov.lm() and not coef(). 
vcov.lm() silently removed NAs, which motivated the introduction of the 
complete argument, defaulting to TRUE. AFAIK, coef() always included NAs in the 
coefficient vector for a singular fit.

Best,
 John

  -------------------------------------------------
  John Fox, Professor Emeritus
  McMaster University
  Hamilton, Ontario, Canada
  Web: http::/socserv.mcmaster.ca/jfox

> 
> -pd
> 
>> On 5 Apr 2019, at 12:14 , Witold E Wolski <wewol...@gmail.com> wrote:
>> 
>> lme4 has a function isSingular to check if the fitted model is Singular,
>> 
>> Although lm has the parameter singular.ok = TRUE by defualt, I could
>> not find a function to check if the fitted model is singular.
>> 
>> What would be the correct way to implement such a function for and lm object?
>> Check if df.residuals == 0
>> 
>> Thanks
>> Witek
>> 
>> 
>> 
>> 
>> 
>> -- 
>> Witold Eryk Wolski
>> 
>> ______________________________________________
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
> 
> -- 
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd....@cbs.dk  Priv: pda...@gmail.com
> 
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to