[R-sig-ME] lmer() with no intercept

array chip arrayprofile at yahoo.com
Fri Jun 4 21:46:46 CEST 2010

Hi, I am wondering how I can specify no intercept in a mixed model using lmer(). 

Here is an example dataset attached ("test.txt"). There are 3 workers, in 5 days, measured a response variable "y" on independent variable "x". I want to use a quadratic term (x2 in the dataset) to model the relationship between y and x.


If I just simply use lm() and ignore worker and day, so that I can try both a linear regression with and without an intercept, here is what I get:

lm(y~x+x2, data=test)
(Intercept)            x           x2  
-1.7749104    0.1099160   -0.0006152

lm(y~x+x2-1, data=test)
         x          x2  
0.0490097  -0.0001962

Now, I want to try mixed model considering worker and day as random effect. 

With an intercept:

lmer(y~x+x2+(1|worker)+(1|day), data=test)
Fixed effects:
              Estimate Std. Error t value
(Intercept) -1.324e+00  4.490e-01  -2.948
x            1.117e-01  8.563e-03  13.041
x2          -6.357e-04  7.822e-05  -8.127

Without an intercept:

lmer(y~x+x2+(1|worker)+(1|day)-1, data=test)
Fixed effects:
     Estimate Std. Error t value
x   1.107e-01  8.528e-03  12.981
x2 -6.304e-04  7.805e-05  -8.077

It seems working fine. But if you look at the fixed effect coefficients of both mixed models, the coefficients for x and x2 are not much different, regardless of whether an intercept is included or not. This is not the case for simple linear regression using lm() on the top.

If I plot all 4 models in the following plot:

xyplot(y~x,groups=worker,test, col.line = "grey", lwd = 2,
, panel = function(x,y) { 
    panel.xyplot(x,y, type='p')


As you can see, the mixed model without intercept (red line) does not fit the data very well (it's at the top edge of the data, instead of in the middle of the data), so I guess I did something wrong here.

Can anyone make any suggestions?



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.txt
URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20100604/9d1aa4bc/attachment.txt>

More information about the R-sig-mixed-models mailing list