Skip to content
Prev 67577 / 398506 Next

lme problem

Milos Zarkovic said the following on 2005-04-12 16:40:
The PROC MIXED code above doesn't correspond to the R code below.
In your `lme' call, a random effect for each of the levels of `type' has 
been added to the model.

Since the analysis performed by PROC MIXED doesn't have any random 
effects it can be reproduced in R using the `lm' function. The results 
below match those of Milliken & Johnson p. 49 (using PROC MIXED) and the 
results on p. 43 (using PROC GLM).

 > fit <- lm(time ~ bstime:type + type - 1, data = CCE)
 > summary(fit)

Call:
lm(formula = time ~ bstime:type + type - 1, data = CCE)

Residuals:
     Min      1Q  Median      3Q     Max
-16.982  -3.196  -0.250   1.400  21.694

Coefficients:
                      Estimate Std. Error t value Pr(>|t|)
typeBlue M&M          17.9744    16.1923   1.110  0.27845
typeButton            21.5719    10.7832   2.001  0.05738 .
typeChoc Chip         16.9167    15.1673   1.115  0.27622
typeRed M&M           26.5760    13.1722   2.018  0.05545 .
typeSmall M&M         22.1977    29.0849   0.763  0.45310
typeSnow Cap           8.7000     9.4131   0.924  0.36495
bstime:typeBlue M&M    1.0641     0.6187   1.720  0.09887 .
bstime:typeButton      1.3352     0.3743   3.567  0.00164 **
bstime:typeChoc Chip   1.1667     0.7302   1.598  0.12373
bstime:typeRed M&M     0.5300     0.5564   0.953  0.35075
bstime:typeSmall M&M   0.1919     0.9881   0.194  0.84775
bstime:typeSnow Cap    0.9000     0.3999   2.250  0.03428 *
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

Residual standard error: 8.196 on 23 degrees of freedom
Multiple R-Squared: 0.9774,     Adjusted R-squared: 0.9656
F-statistic:  82.8 on 12 and 23 DF,  p-value: 5.616e-16
The tests reported by Milliken & Johnson are based on so called "Type 
III" sums of squares. If you want to reproduce these, try the `Anova' 
function in John Fox's indispensable `car' package.

 > library(car)
 > options(contrasts = c("contr.sum", "contr.poly"))
 > Anova(fit, type = "III")
Anova Table (Type III tests)

Response: time
              Sum Sq Df F value   Pr(>F)
type         805.13  6  1.9976 0.107510
bstime:type 1628.79  6  4.0412 0.006557 **
Residuals   1545.01 23
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1


HTH,
Henric