Rev 3734 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
S> ### $Id: Mississippi.St,v 1.1 1999/10/13 00:50:09 saikat Exp $S> ### Analysis of the Mississippi nitrogren concentrations given as data setS> ### 4.2 in "SAS System for Mixed Models"S> options(contrasts=c(factor="contr.SAS", ordered="contr.poly"))S> formula( Mississippi )y ~ 1 | influentS> plot( Mississippi )S> fm1Miss <- lme( y ~ 1, data = Mississippi, random = ~ 1 | influent,+ method = "ML")S> summary( fm1Miss ) # compare with output 4.2, p. 143Linear mixed-effects model fit by maximum likelihoodData: MississippiAIC BIC logLik262.56 267.39 -128.28Random effects:Formula: ~ 1 | influent(Intercept) ResidualStdDev: 7.1592 6.5343Fixed effects: y ~ 1Value Std.Error DF t-value p-value(Intercept) 21.217 3.1651 31 6.7035 <.0001Standardized Within-Group Residuals:Min Q1 Med Q3 Max-1.9344 -0.55704 -0.035454 0.8376 1.9323Number of Observations: 37Number of Groups: 6S> fm1RMiss <- update( fm1Miss, method = "REML" )S> summary( fm1RMiss ) # compare with output 4.1, p. 142Linear mixed-effects model fit by REMLData: MississippiAIC BIC logLik258.35 263.1 -126.18Random effects:Formula: ~ 1 | influent(Intercept) ResidualStdDev: 7.9576 6.5313Fixed effects: y ~ 1Value Std.Error DF t-value p-value(Intercept) 21.223 3.429 31 6.1892 <.0001Standardized Within-Group Residuals:Min Q1 Med Q3 Max-1.9144 -0.53646 -0.032173 0.83714 1.9582Number of Observations: 37Number of Groups: 6S> random.effects( fm1Miss ) # BLUP's of random effects on p. 144(Intercept)3 -3.786275 -5.843522 -6.577231 0.309784 2.882676 13.01457S> random.effects( fm1Miss , aug = TRUE ) # including covariates(Intercept) y Type3 -3.78627 16.800 15 -5.84352 14.400 12 -6.57723 13.857 21 0.30978 21.556 24 2.88267 24.500 26 13.01457 36.400 3S> plot( random.effects( fm1Miss , aug = TRUE ), outer = ~ Type )Error in panel(x = c(-3.7862747633584, -5...: Can't pass data ofmode "call" to old-S functionDumpedS> random.effects( fm1RMiss ) # BLUP's of random effects on p. 142(Intercept)3 -3.897955 -6.012982 -6.719331 0.309294 2.946106 13.37487S> intervals( fm1RMiss ) # interval estimates of variance componentsApproximate 95% confidence intervalsFixed effects:lower est. upper(Intercept) 14.23 21.223 28.217Random Effects:Level: influentlower est. uppersd((Intercept)) 3.9513 7.9576 16.026Within-group standard error:lower est. upper5.0895 6.5313 8.3815S> c(2.9568, 7.9576, 21.416)^2 # compare to output 4.7, p. 148[1] 8.7427 63.3234 458.6451S> fm2RMiss <- lme( y ~ Type, data = Mississippi, random = ~ 1 | influent,+ method = "REML" )S> summary( fm2RMiss ) # compare to output 4.8 and 4.9, pp. 150-152Linear mixed-effects model fit by REMLData: MississippiAIC BIC logLik244.52 252.16 -117.26Random effects:Formula: ~ 1 | influent(Intercept) ResidualStdDev: 3.8691 6.5202Fixed effects: y ~ TypeValue Std.Error DF t-value p-value(Intercept) 36.400 4.8449 31 7.5131 <.0001Type1 -20.800 5.9338 3 -3.5054 0.0393Type2 -16.462 5.5168 3 -2.9840 0.0584Correlation:(Intr) Type1Type1 -0.816Type2 -0.878 0.717Standardized Within-Group Residuals:Min Q1 Med Q3 Max-2.0877 -0.63918 -0.025703 0.70549 2.0191Number of Observations: 37Number of Groups: 6S> fm2Miss <- update( fm2RMiss, method = "ML" ) # get ML results tooS> anova( fm1Miss, fm2Miss ) # getting a p-value for the TypeModel df AIC BIC logLik Test L.Ratio p-valuefm1Miss 1 3 262.56 267.39 -128.28fm2Miss 2 5 256.57 264.63 -123.29 1 vs 2 9.9834 0.0068S> ## Notice that the p-value is considerably smaller than for the F-test.