# [R] glm with four variables

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Feb 8 14:35:09 CET 2002

```On Fri, 8 Feb 2002, iago mosqueira wrote:

> Hi,
>
> Yes, it appears R thinks that is the case. lm() complains of singularities.

Ah well, since you are fitting a linear model why not use lm?

> I have a total of four variables (dep,lat,ne and date) and Matlab tells me
> none of them is singular, and the rank of the combined matrix is 4, so they
> don't appear to be correlated. Is there any way I can avoid this? Or does it
> simply indicate two variables will be enough here?

You only used three variables (despite your subject), and it's the design
matrix that is singular.  That has a constant column and expands out any
factors.

R has an alias function to show you what is aliased in a linear model.

I suggest you take some advice on regression from a local expert.

>
> Thanks
>
> iago
>
> ----- Original Message -----
> From: "Martyn Plummer" <plummer at iarc.fr>
> To: "iago mosqueira" <i.mosqueira at ic.ac.uk>
> Cc: "R-help" <r-help at stat.math.ethz.ch>
> Sent: 08 February 2002 13:13
> Subject: RE: [R] glm with four variables
>
>
> > On 08-Feb-2002 iago mosqueira wrote:
> > > Hi,
> > >
> > > Sorry if this is a very basic question, but when I run this
> > >
> > > glm(formula = loge ~ lat + ne + dep, family = gaussian)
> > >
> > > summary shows the same formula but results only for the first two
> variables.
> > > What am I doing wrong?
> >
> > Probably dep is aliased: i.e. some linear combination of lat, ne and the
> > intercept equals dep for all values. A model with all four terms is, in
> > this case, unidentifiable so dep is dropped.  This appears to take place
> > silently.  It might be more useful to issue a warning.
> >
> > Martyn
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

--
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```