Martin Waller
2008-Feb-14 17:54 UTC
[R] lm, coefficient 'not defined because of singularities'? What does this mean?
Hello, I'm doing an lm(y1~x1), no NAs in them, both of length 283. I get out however and 'NA' for the estimate of x1 and summary gives: Residuals: Min 1Q Median 3Q Max -0.1998309 -0.0447269 -0.0006252 0.0390933 0.3141687 Coefficients: (1 not defined because of singularities) Estimate Std. Error t value Pr(>|t|) (Intercept) -0.021291 0.003994 -5.331 2.01e-07 *** x1 NA NA NA NA --- Signif. codes: 0 .***. 0.001 .**. 0.01 .*. 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.06719 on 282 degrees of freedom I don't understand why x1 can't be defined because of singularities - is it trying to tell me something about the data and what can I do about it? Thanks for any help, Martin
Prof Brian Ripley
2008-Feb-14 18:01 UTC
[R] lm, coefficient 'not defined because of singularities'? What does this mean?
Hint: x1 <- rep(pi, 283) y1 <- rnorm(283) summary(lm(y1 ~ x1)) More generally, see ?alias. The idea of singularity is a linear model is a statistical one, so it may be time to revisit your statistical education or read a good book on the subject (MASS comes to mind in this context). On Thu, 14 Feb 2008, Martin Waller wrote:> Hello, > > I'm doing an lm(y1~x1), no NAs in them, both of length 283. > > I get out however and 'NA' for the estimate of x1 and summary gives: > > Residuals: > Min 1Q Median 3Q Max > -0.1998309 -0.0447269 -0.0006252 0.0390933 0.3141687 > > Coefficients: (1 not defined because of singularities) > Estimate Std. Error t value Pr(>|t|) > (Intercept) -0.021291 0.003994 -5.331 2.01e-07 *** > x1 NA NA NA NA > --- > Signif. codes: 0 .***. 0.001 .**. 0.01 .*. 0.05 '.' 0.1 ' ' 1 > > Residual standard error: 0.06719 on 282 degrees of freedom > > > I don't understand why x1 can't be defined because of singularities - is > it trying to tell me something about the data and what can I do about it? > > Thanks for any help, > > Martin > > ______________________________________________ > R-help at r-project.org 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. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Martin Waller
2008-Feb-15 09:03 UTC
[R] lm, coefficient 'not defined because of singularities'? What does this mean?
Ah yes - you're right, and its also a tiny number (10^-18) Thanks... Martin Patrick Burns wrote:> I think it is saying that there is only one (unique) > number in 'x1'. If that is right, then you could do: > > lm(y1 ~ x1 - 1) > > Patrick Burns > patrick at burns-stat.com > +44 (0)20 8525 0696 > http://www.burns-stat.com > (home of S Poetry and "A Guide for the Unwilling S User") > > Martin Waller wrote: > >> Hello, >> >> I'm doing an lm(y1~x1), no NAs in them, both of length 283. >> >> I get out however and 'NA' for the estimate of x1 and summary gives: >> >> Residuals: >> Min 1Q Median 3Q Max >> -0.1998309 -0.0447269 -0.0006252 0.0390933 0.3141687 >> >> Coefficients: (1 not defined because of singularities) >> Estimate Std. Error t value Pr(>|t|) >> (Intercept) -0.021291 0.003994 -5.331 2.01e-07 *** >> x1 NA NA NA NA >> --- >> Signif. codes: 0 .***. 0.001 .**. 0.01 .*. 0.05 '.' 0.1 ' ' 1 >> >> Residual standard error: 0.06719 on 282 degrees of freedom >> >> >> I don't understand why x1 can't be defined because of singularities - >> is it trying to tell me something about the data and what can I do >> about it? >> >> Thanks for any help, >> >> Martin >> >> ______________________________________________ >> R-help at r-project.org 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. >> >> >> >> > >
Maybe Matching Threads
- Summary coefficients give NA values because of singularities
- interpreting "not defined because of singularities" in lm
- Coefficients: (20 not defined because of singularities)
- Package survey: singularities in linear regression models
- Singularities in glm()