[R] isSingular for lm?

peter dalgaard pd@|gd @end|ng |rom gm@||@com
Fri Apr 5 13:22:06 CEST 2019


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.

-pd

> On 5 Apr 2019, at 12:14 , Witold E Wolski <wewolski using 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 using 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.mes using cbs.dk  Priv: PDalgd using gmail.com



More information about the R-help mailing list