[R-sig-Geo] Missing values with lm

Roger Bivand Roger.Bivand at nhh.no
Wed Mar 2 21:35:57 CET 2011


On Wed, 2 Mar 2011, Jan Hackenberg wrote:

> Hello
> I am trying to fit a linear model with lm. I want to decompose
> spatial-temporal pm10 data into pure spatial component and pure temporal
> component with an error term. My data consists of 36 points with 480
> timesteps.
> The code i am using is
> lm.half <- lm(pm10 ~factor(s) +factor(t),data= half)
> so i expect to get 36 s values and 480 t values. Instead for the first cell
> and the first timestep the value is missing, the lm result is only 35 s
> values and 479 t values ( + one intercept coefficient ). Is there a reason
> behind this and some way to fix it?
> Second question is how could i skip the intercept value in my computation.
> is this simple
> lm.half <- lm(pm10 ~factor(s) +factor(t) -1,data= half)
> ??
> I have found it in the internet, but i fear that then a -1 is taken into
> account always...

Don't always trust the internet, but yes, use -1 or equivalently + 0, see:

?formula

or for more detail:

      Chambers, J. M. and Hastie, T. J. (1992) _Statistical models._
      Chapter 2 of _Statistical Models in S_ eds J. M. Chambers and T.
      J. Hastie, Wadsworth & Brooks/Cole.

which is the authoritative source for where formula and data.frame objects 
came from.

Roger

>
> And also one last question, my R sqaured value is not too high, its only
> about 0.51. Does this tell me the model makes no sense? I would very like to
> use this model but i dont know if this number tells me not to use this ;).
> Have also heard that linear models without intercept have a higher r quared
> value, perhaps it will fix a little bit of this.
>
> Regards
> Jan
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list