[R] lme Random Effects and Covariates

patze003 patze003 at umn.edu
Thu Nov 18 18:22:11 CET 2010


1.  I'm attempting to test for Random Effects.  I've grouped the data on
subject (grid) but want to use lme to build the model without subject as a
RE then add it and do anova between the 2 models.  This is the result I get
and it appears it's adding Random Effects.

tmp.dat4 <- groupedData(Trials ~ 1 | grid, data = tmp.dat4)

mod2a <- lme(Trials ~ factor(group_id) + reversal, data = tmp.dat4,
na.action = na.omit, method = "REML")

> summary(mod2a)
Linear mixed-effects model fit by REML
 Data: tmp.dat4 
       AIC      BIC    logLik
  4544.054 4587.718 -2262.027

Random effects:
 Formula: ~factor(group_id) + reversal | grid
 Structure: General positive-definite
                  StdDev    Corr         
(Intercept)       10.505303 (Intr) fc(_)2
factor(group_id)2  9.830679 -0.778       
reversal2          7.106839 -0.275  0.023
Residual           9.995963              

Fixed effects: Trials ~ factor(group_id) + reversal 
                      Value Std.Error  DF   t-value p-value
(Intercept)       23.275874  1.876185 510 12.405960   0e+00
factor(group_id)2 -7.639842  2.151004  72 -3.551757   7e-04
reversal2          7.681495  1.206858 510  6.364869   0e+00
 Correlation: 
                  (Intr) fc(_)2
factor(group_id)2 -0.785       
reversal2         -0.308 -0.015

Standardized Within-Group Residuals:
       Min         Q1        Med         Q3        Max 
-2.6884393 -0.5059063 -0.1892908  0.4944976  2.8477377 

Number of Observations: 585
Number of Groups: 74 

2.  Secondly is this the correct way to add covariates (such as age).

mod2i <- lme(Trials ~ factor(group_id)*factor(reversal) * age, data =
tmp.dat4, random = ~ 1 | grid, na.action = na.omit, method = "ML")

-- 
View this message in context: http://r.789695.n4.nabble.com/lme-Random-Effects-and-Covariates-tp3049181p3049181.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list