> library(nlme) > out.r <- lme(Y ~ SG + VP + V10 + EP, random = ~ 1 | No) > summary(out.r) Linear mixed-effects model fit by REML Data: NULL AIC BIC logLik 166.3820 175.4528 -76.19098 Random effects: Formula: ~1 | No (Intercept) Residual StdDev: 1.445028 1.872146 Fixed effects: Y ~ SG + VP + V10 + EP Value Std.Error DF t-value p-value (Intercept) -6.134690 14.555917 21 -0.421457 0.6777 SG 0.219397 0.146956 6 1.492947 0.1861 VP 0.545861 0.520588 6 1.048547 0.3348 V10 -0.154244 0.039967 6 -3.859288 0.0084 EP 0.157177 0.005588 21 28.128410 <.0001 Correlation: (Intr) SG VP V10 SG -0.694 VP -0.715 0.067 V10 -0.934 0.433 0.836 EP 0.011 0.023 -0.116 -0.197 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -1.7807117 -0.6063671 -0.1069013 0.4571818 1.7811918 Number of Observations: 32 Number of Groups: 10 > out.little <- lm(Y ~ SG + VP + V10 + EP) > anova(out.r, out.little) Model df AIC BIC logLik Test L.Ratio p-value out.r 1 7 166.3819 175.4528 -76.19098 out.little 2 6 167.7402 175.5152 -77.87011 1 vs 2 3.358266 0.0669 > 1 - pchisq(2 * 3.358266, 1) [1] 0.00955232 > 1 - pchisq(3.358266, 1) [1] 0.06686844 > #### But this is one-tailed test, so > (1 - pchisq(3.358266, 1)) / 2 [1] 0.03343422 > > # So we accept H1 and keep the random effects!!!!! > out.r2 <- lme(Y ~ EP, random = ~ 1 | No) > summary(out.r2) Linear mixed-effects model fit by REML Data: NULL AIC BIC logLik 183.4306 189.0354 -87.7153 Random effects: Formula: ~1 | No (Intercept) Residual StdDev: 8.387862 1.88046 Fixed effects: Y ~ EP Value Std.Error DF t-value p-value (Intercept) -33.30626 3.287182 21 -10.13216 <.0001 EP 0.15757 0.005703 21 27.62679 <.0001 Correlation: (Intr) EP -0.582 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -1.6759908 -0.4857902 -0.0397993 0.5128182 1.8518206 Number of Observations: 32 Number of Groups: 10 > out <- lm(Y ~ No + EP - 1) > anova(out.r2, out) Model df AIC BIC logLik Test L.Ratio p-value out.r2 1 4 183.4306 189.0354 -87.71530 out 2 12 133.1165 145.6508 -54.55825 1 vs 2 66.31409 <.0001 Warning message: Fitted objects with different fixed effects. REML comparisons are not meaningful. in: anova.lme(out.r2, out) > out.r2d2 <- lme(Y ~ EP, random = ~ 1 | No, method = "ML") > anova(out.r2d2, out) Model df AIC BIC logLik Test L.Ratio p-value out.r2d2 1 4 178.6625 184.5255 -85.33126 out 2 12 141.6956 159.2845 -58.84781 1 vs 2 52.96689 <.0001 > # nonnested comparison so not clear what this means > # classical likelihood theory invalid >