> #1
> (x <- testFactors(models[[1]]))

Call: testFactors(model = models[[1]]) 

Term (Intercept) 

Adjusted mean:
         
40.36243 

Linear hypothesis test

Hypothesis:
(Intercept) = 0

Model 1: restricted model
Model 2: score ~ 1 + (1 | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 8885.026 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 lmer(formula = score ~ 1 + (1 | school), data = Snijders) 
------

Linear hypothesis matrix

            (Intercept)
(Intercept)           1

------

Adjusted values

Term (Intercept) 

Adjusted mean:
         
40.36243 
---

------
Chisq Test: 
            Df Chisq Pr(>Chisq)    
(Intercept)  1  8885  < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #2
> (x <- testFactors(models[[2]],levelslme))

Call: testFactors(model = models[[2]], levels = levelslme) 

Term (Intercept) 

Adjusted mean:
          
-2.567735 

Linear hypothesis test

Hypothesis:
- sexM = 0

Model 1: restricted model
Model 2: score ~ sex + (1 | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 56.87741 4.6384e-14 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 lmer(formula = score ~ sex + (1 | school), data = Snijders) 

Values of predictor variables.
 
Specified combinations of factor levels:

     F  M
sex1 1 -1
------

Linear hypothesis matrix

            (Intercept) sexM
(Intercept)           0   -1

------

Adjusted values

Term (Intercept) 

Adjusted mean:
          
-2.567735 
---

------
Chisq Test: 
            Df  Chisq Pr(>Chisq)    
(Intercept)  1 56.877  4.638e-14 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #3
> (x <- testFactors(models[[3]]))

Call: testFactors(model = models[[3]]) 

Term (Intercept) 

Adjusted mean:
         
40.70921 

Linear hypothesis test

Hypothesis:
(Intercept)  + 2.25869947047483e - 15 IQ = 0

Model 1: restricted model
Model 2: score ~ IQ + (IQ | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 17747.28 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 lmer(formula = score ~ IQ + (IQ | school), data = Snijders) 
------

Linear hypothesis matrix

            (Intercept)           IQ
(Intercept)           1 2.258699e-15

------

Adjusted values

Term (Intercept) 

Adjusted mean:
         
40.70921 
---

------
Chisq Test: 
            Df Chisq Pr(>Chisq)    
(Intercept)  1 17747  < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #4
> (x <- testFactors(models[[4]]))

Call: testFactors(model = models[[4]]) 

Term (Intercept) 

Adjusted mean:
         
40.54716 

Linear hypothesis test

Hypothesis:
(Intercept)  + 27.811980760822 SES = 0

Model 1: restricted model
Model 2: score ~ SES + (1 | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 11119.66 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 lmer(formula = score ~ SES + (1 | school), data = Snijders) 
------

Linear hypothesis matrix

            (Intercept)      SES
(Intercept)           1 27.81198

------

Adjusted values

Term (Intercept) 

Adjusted mean:
         
40.54716 
---

------
Chisq Test: 
            Df Chisq Pr(>Chisq)    
(Intercept)  1 11120  < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #5
> (x <- testFactors(models[[5]],levelslme))

Call: testFactors(model = models[[5]], levels = levelslme) 

Term (Intercept) 

Adjusted mean:
          
-2.645588 

Linear hypothesis test

Hypothesis:
- sexM - 2.25869947047483e - 15 IQ:sexM - 27.811980760822 SES:sexM - 6.28189062173248e - 14 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: score ~ IQ * SES * sex + (IQ | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 92.01081 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 lmer(formula = score ~ IQ * SES * sex + (IQ | school), data = Snijders) 

Values of predictor variables.
 
Specified combinations of factor levels:

     F  M
sex1 1 -1

---
 
Specified values of covariates:
          IQ          SES 
2.258699e-15 2.781198e+01 
------

Linear hypothesis matrix

            (Intercept) IQ SES sexM IQ:SES       IQ:sexM  SES:sexM   IQ:SES:sexM
(Intercept)           0  0   0   -1      0 -2.258699e-15 -27.81198 -6.281891e-14

------

Adjusted values

Term (Intercept) 

Adjusted mean:
          
-2.645588 
---

------
Chisq Test: 
            Df  Chisq Pr(>Chisq)    
(Intercept)  1 92.011  < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #6
> (x <- testFactors(models[[6]],levelslme))

Call: testFactors(model = models[[6]], levels = levelslme) 

Term (Intercept) 

Adjusted mean:
          
-2.567735 

Linear hypothesis test

Hypothesis:
sexF - sexM = 0

Model 1: restricted model
Model 2: score ~ 0 + sex + (1 | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 56.87741 4.6384e-14 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 lmer(formula = score ~ 0 + sex + (1 | school), data = Snijders) 

Values of predictor variables.
 
Specified combinations of factor levels:

     F  M
sex1 1 -1
------

Linear hypothesis matrix

            sexF sexM
(Intercept)    1   -1

------

Adjusted values

Term (Intercept) 

Adjusted mean:
          
-2.567735 
---

------
Chisq Test: 
            Df  Chisq Pr(>Chisq)    
(Intercept)  1 56.877  4.638e-14 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #7
> (x <- testFactors(models[[7]]))

Call: testFactors(model = models[[7]]) 

Term (Intercept) 

Adjusted mean:
             
1.335069e-14 

Linear hypothesis test

Hypothesis:
2.25869947047483e - 15 IQ = 0

Model 1: restricted model
Model 2: score ~ 0 + IQ + (IQ | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 5391.264 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 lmer(formula = score ~ 0 + IQ + (IQ | school), data = Snijders) 
------

Linear hypothesis matrix

                      IQ
(Intercept) 2.258699e-15

------

Adjusted values

Term (Intercept) 

Adjusted mean:
             
1.335069e-14 
---

------
Chisq Test: 
            Df  Chisq Pr(>Chisq)    
(Intercept)  1 5391.3  < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #8
> (x <- testFactors(models[[8]]))

Call: testFactors(model = models[[8]]) 

Term (Intercept) 

Adjusted mean:
         
9.231344 

Linear hypothesis test

Hypothesis:
27.811980760822 SES = 0

Model 1: restricted model
Model 2: score ~ 0 + SES + (1 | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 363.5457 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 lmer(formula = score ~ 0 + SES + (1 | school), data = Snijders) 
------

Linear hypothesis matrix

                 SES
(Intercept) 27.81198

------

Adjusted values

Term (Intercept) 

Adjusted mean:
         
9.231344 
---

------
Chisq Test: 
            Df  Chisq Pr(>Chisq)    
(Intercept)  1 363.55  < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #9
> (x <- testFactors(models[[9]],levelslme))

Call: testFactors(model = models[[9]], levels = levelslme) 

Term (Intercept) 

Adjusted mean:
          
-2.645588 

Linear hypothesis test

Hypothesis:
sexF - sexM - 2.25869947047483e - 15 IQ:sexM - 27.811980760822 SES:sexM - 6.28189062173248e - 14 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: score ~ 0 + IQ * SES * sex + (IQ | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 92.01081 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 lmer(formula = score ~ 0 + IQ * SES * sex + (IQ | school), data = Snijders) 

Values of predictor variables.
 
Specified combinations of factor levels:

     F  M
sex1 1 -1

---
 
Specified values of covariates:
          IQ          SES 
2.258699e-15 2.781198e+01 
------

Linear hypothesis matrix

            IQ SES sexF sexM IQ:SES       IQ:sexM  SES:sexM   IQ:SES:sexM
(Intercept)  0   0    1   -1      0 -2.258699e-15 -27.81198 -6.281891e-14

------

Adjusted values

Term (Intercept) 

Adjusted mean:
          
-2.645588 
---

------
Chisq Test: 
            Df  Chisq Pr(>Chisq)    
(Intercept)  1 92.011  < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #10
> (x <- testFactors(models[[10]],levelslme))

Call: testFactors(model = models[[10]], levels = levelslme) 

Term (Intercept) 

Adjusted mean:
          
0.9355213 

Linear hypothesis test

Hypothesis:
- sexM - 2.25869947047483e - 15 IQ:sexM - 27.811980760822 SES:sexM - 6.28189062173248e - 14 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: round(score) ~ IQ * SES * sex + (1 | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 90.11358 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 glmer(formula = round(score) ~ IQ * SES * sex + (1 | school),      data = Snijders, family = "poisson") 

Values of predictor variables.
 
Specified combinations of factor levels:

     F  M
sex1 1 -1

---
 
Specified values of covariates:
          IQ          SES 
2.258699e-15 2.781198e+01 
------

Linear hypothesis matrix

            (Intercept) IQ SES sexM IQ:SES       IQ:sexM  SES:sexM   IQ:SES:sexM
(Intercept)           0  0   0   -1      0 -2.258699e-15 -27.81198 -6.281891e-14

------

Adjusted values

Term (Intercept) 

Adjusted mean:
          
0.9355213 
---

------
Chisq Test: 
            Df  Chisq Pr(>Chisq)    
(Intercept)  1 90.114  < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #5.b
> (x <- testFactors(models[[5]],terms.formula=~sex*IQ))

Call: testFactors(model = models[[5]], terms.formula = ~sex * IQ) 

Term (Intercept) 

Adjusted mean:
         
40.95164 

Linear hypothesis test

Hypothesis:
(Intercept)  + 2.25869947047483e - 15 IQ  + 27.811980760822 SES  + 0.5 sexM  + 6.28189062173248e - 14 IQ:SES  + 1.12934973523741e - 15 IQ:sexM  + 13.905990380411 SES:sexM  + 3.14094531086624e - 14 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: score ~ IQ * SES * sex + (IQ | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 18561.68 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------

Term sex 

Adjusted mean at contrasts of sex:
          
-2.645588 

Linear hypothesis test

Hypothesis:
- sexM - 2.25869947047483e - 15 IQ:sexM - 27.811980760822 SES:sexM - 6.28189062173248e - 14 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: score ~ IQ * SES * sex + (IQ | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 92.01081 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------

Term IQ 

Adjusted slope for IQ:
         
2.278546 

Linear hypothesis test

Hypothesis:
IQ  + 27.811980760822 IQ:SES  + 0.5 IQ:sexM  + 13.905990380411 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: score ~ IQ * SES * sex + (IQ | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 820.4994 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------

Term sex:IQ 

Adjusted slope for IQ at contrasts of sex:
          
0.2806691 

Linear hypothesis test

Hypothesis:
- IQ:sexM - 27.811980760822 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: score ~ IQ * SES * sex + (IQ | school)

  Df   Chisq Pr(>Chisq)  
1                        
2  1 4.22498   0.039833 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 lmer(formula = score ~ IQ * SES * sex + (IQ | school), data = Snijders) 
------

Linear hypothesis matrix

            (Intercept)           IQ      SES sexM       IQ:SES       IQ:sexM  SES:sexM   IQ:SES:sexM
(Intercept)           1 2.258699e-15 27.81198  0.5 6.281891e-14  1.129350e-15  13.90599  3.140945e-14
sex                   0 0.000000e+00  0.00000 -1.0 0.000000e+00 -2.258699e-15 -27.81198 -6.281891e-14
IQ                    0 1.000000e+00  0.00000  0.0 2.781198e+01  5.000000e-01   0.00000  1.390599e+01
sex:IQ                0 0.000000e+00  0.00000  0.0 0.000000e+00 -1.000000e+00   0.00000 -2.781198e+01

------

Adjusted values

Term (Intercept) 

Adjusted mean:
         
40.95164 
---

Term sex 

Adjusted mean at contrasts of sex:
          
-2.645588 
---

Term IQ 

Adjusted slope for IQ:
         
2.278546 
---

Term sex:IQ 

Adjusted slope for IQ at contrasts of sex:
          
0.2806691 
---

------
Chisq Test: 
            Df     Chisq Pr(>Chisq)    
(Intercept)  1 18561.682    < 2e-16 ***
sex          1    92.011    < 2e-16 ***
IQ           1   820.499    < 2e-16 ***
sex:IQ       1     4.225    0.03983 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #5.c
> (x <- testFactors(models[[5]],levelslme,covariates=c(IQ=3,SES=20)))

Call: testFactors(model = models[[5]], levels = levelslme, covariates = c(IQ = 3,      SES = 20)) 

Term (Intercept) 

Adjusted mean:
          
-1.751157 

Linear hypothesis test

Hypothesis:
- sexM - 3 IQ:sexM - 20 SES:sexM - 60 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: score ~ IQ * SES * sex + (IQ | school)

  Df   Chisq Pr(>Chisq)   
1                         
2  1 7.51592  0.0061156 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 lmer(formula = score ~ IQ * SES * sex + (IQ | school), data = Snijders) 

Values of predictor variables.
 
Specified combinations of factor levels:

     F  M
sex1 1 -1

---
 
Specified values of covariates:
 IQ SES 
  3  20 
------

Linear hypothesis matrix

            (Intercept) IQ SES sexM IQ:SES IQ:sexM SES:sexM IQ:SES:sexM
(Intercept)           0  0   0   -1      0      -3      -20         -60

------

Adjusted values

Term (Intercept) 

Adjusted mean:
          
-1.751157 
---

------
Chisq Test: 
            Df  Chisq Pr(>Chisq)   
(Intercept)  1 7.5159   0.006116 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #5.d
> (x <- testFactors(models[[5]],levelslme,covariates=0))

Call: testFactors(model = models[[5]], levels = levelslme, covariates = 0) 

Term (Intercept) 

Adjusted mean:
          
-3.044488 

Linear hypothesis test

Hypothesis:
- sexM = 0

Model 1: restricted model
Model 2: score ~ IQ * SES * sex + (IQ | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 16.13897  5.886e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 lmer(formula = score ~ IQ * SES * sex + (IQ | school), data = Snijders) 

Values of predictor variables.
 
Specified combinations of factor levels:

     F  M
sex1 1 -1

---
 
Specified values of covariates:
 IQ SES 
  0   0 
------

Linear hypothesis matrix

            (Intercept) IQ SES sexM IQ:SES IQ:sexM SES:sexM IQ:SES:sexM
(Intercept)           0  0   0   -1      0       0        0           0

------

Adjusted values

Term (Intercept) 

Adjusted mean:
          
-3.044488 
---

------
Chisq Test: 
            Df  Chisq Pr(>Chisq)    
(Intercept)  1 16.139  5.886e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #10.b
> (x <- testFactors(models[[10]],terms.formula=~sex*IQ))

Call: testFactors(model = models[[10]], terms.formula = ~sex * IQ) 

Term (Intercept) 

Adjusted mean:
         
40.45182 

Linear hypothesis test

Hypothesis:
(Intercept)  + 2.25869947047483e - 15 IQ  + 27.811980760822 SES  + 0.5 sexM  + 6.28189062173248e - 14 IQ:SES  + 1.12934973523741e - 15 IQ:sexM  + 13.905990380411 SES:sexM  + 3.14094531086624e - 14 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: round(score) ~ IQ * SES * sex + (1 | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 233488.2 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------

Term sex 

Adjusted mean at contrasts of sex:
          
0.9355213 

Linear hypothesis test

Hypothesis:
- sexM - 2.25869947047483e - 15 IQ:sexM - 27.811980760822 SES:sexM - 6.28189062173248e - 14 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: round(score) ~ IQ * SES * sex + (1 | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 90.11358 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------

Term IQ 

Adjusted slope for IQ:
           
0.05638535 

Linear hypothesis test

Hypothesis:
IQ  + 27.811980760822 IQ:SES  + 0.5 IQ:sexM  + 13.905990380411 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: round(score) ~ IQ * SES * sex + (1 | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 993.4522 < 2.22e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------

Term sex:IQ 

Adjusted slope for IQ at contrasts of sex:
            
0.008716501 

Linear hypothesis test

Hypothesis:
- IQ:sexM - 27.811980760822 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: round(score) ~ IQ * SES * sex + (1 | school)

  Df   Chisq Pr(>Chisq)  
1                        
2  1 6.34163   0.011794 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 glmer(formula = round(score) ~ IQ * SES * sex + (1 | school),      data = Snijders, family = "poisson") 
------

Linear hypothesis matrix

            (Intercept)           IQ      SES sexM       IQ:SES       IQ:sexM  SES:sexM   IQ:SES:sexM
(Intercept)           1 2.258699e-15 27.81198  0.5 6.281891e-14  1.129350e-15  13.90599  3.140945e-14
sex                   0 0.000000e+00  0.00000 -1.0 0.000000e+00 -2.258699e-15 -27.81198 -6.281891e-14
IQ                    0 1.000000e+00  0.00000  0.0 2.781198e+01  5.000000e-01   0.00000  1.390599e+01
sex:IQ                0 0.000000e+00  0.00000  0.0 0.000000e+00 -1.000000e+00   0.00000 -2.781198e+01

------

Adjusted values

Term (Intercept) 

Adjusted mean:
         
40.45182 
---

Term sex 

Adjusted mean at contrasts of sex:
          
0.9355213 
---

Term IQ 

Adjusted slope for IQ:
           
0.05638535 
---

Term sex:IQ 

Adjusted slope for IQ at contrasts of sex:
            
0.008716501 
---

------
Chisq Test: 
            Df      Chisq Pr(>Chisq)    
(Intercept)  1 2.3349e+05    < 2e-16 ***
sex          1 9.0114e+01    < 2e-16 ***
IQ           1 9.9345e+02    < 2e-16 ***
sex:IQ       1 6.3416e+00    0.01179 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #10.c
> (x <- testFactors(models[[10]],levelslme,covariates=c(IQ=3,SES=20)))

Call: testFactors(model = models[[10]], levels = levelslme, covariates = c(IQ = 3,      SES = 20)) 

Term (Intercept) 

Adjusted mean:
          
0.9608506 

Linear hypothesis test

Hypothesis:
- sexM - 3 IQ:sexM - 20 SES:sexM - 60 IQ:SES:sexM = 0

Model 1: restricted model
Model 2: round(score) ~ IQ * SES * sex + (1 | school)

  Df   Chisq Pr(>Chisq)  
1                        
2  1 6.20952   0.012707 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 glmer(formula = round(score) ~ IQ * SES * sex + (1 | school),      data = Snijders, family = "poisson") 

Values of predictor variables.
 
Specified combinations of factor levels:

     F  M
sex1 1 -1

---
 
Specified values of covariates:
 IQ SES 
  3  20 
------

Linear hypothesis matrix

            (Intercept) IQ SES sexM IQ:SES IQ:sexM SES:sexM IQ:SES:sexM
(Intercept)           0  0   0   -1      0      -3      -20         -60

------

Adjusted values

Term (Intercept) 

Adjusted mean:
          
0.9608506 
---

------
Chisq Test: 
            Df  Chisq Pr(>Chisq)  
(Intercept)  1 6.2095    0.01271 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> #10.d
> (x <- testFactors(models[[10]],levelslme,covariates=0))

Call: testFactors(model = models[[10]], levels = levelslme, covariates = 0) 

Term (Intercept) 

Adjusted mean:
          
0.9157287 

Linear hypothesis test

Hypothesis:
- sexM = 0

Model 1: restricted model
Model 2: round(score) ~ IQ * SES * sex + (1 | school)

  Df    Chisq Pr(>Chisq)    
1                           
2  1 20.70022  5.371e-06 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------
> summary(x)

Adjusted values for factor combinations in model:
 glmer(formula = round(score) ~ IQ * SES * sex + (1 | school),      data = Snijders, family = "poisson") 

Values of predictor variables.
 
Specified combinations of factor levels:

     F  M
sex1 1 -1

---
 
Specified values of covariates:
 IQ SES 
  0   0 
------

Linear hypothesis matrix

            (Intercept) IQ SES sexM IQ:SES IQ:sexM SES:sexM IQ:SES:sexM
(Intercept)           0  0   0   -1      0       0        0           0

------

Adjusted values

Term (Intercept) 

Adjusted mean:
          
0.9157287 
---

------
Chisq Test: 
            Df Chisq Pr(>Chisq)    
(Intercept)  1  20.7  5.371e-06 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
------------
> 
> ## Steve Kohler's example
> jeff <- read.table("behaviorHB.txt", header=T)
> for(j in c("Trial","Tank","Obs")) jeff[,j]<- factor(jeff[,j])
> ## start with a model that ignores random effects and omits the 3-way interaction
> lm1 <- lm(normMoves~Heron+Bass+Day+Heron:Bass+Heron:Day+Bass:Day, data=jeff)
> (Moves.means <- interactionMeans(lm1, factors=list("Heron","Bass")))
  Heron  Bass adjusted mean
1  none  none     46.410714
2  once  none     12.571429
3 twice  none      8.357143
4  none  once     17.250000
5  once  once     15.660714
6 twice  once     11.071429
7  none twice     15.482143
8  once twice     14.000000
9 twice twice     15.696429
> ## custom contrasts in phia
> noHeron.vs.others <- list(Heron=c(2,-1,-1))
> noBass.vs.others <- list(Bass=c(2,-1,-1))
> Honce.vs.Htwice <- list(Heron=c(0,1,-1))
> Bonce.vx.Btwice <- list(Bass=c(0,1,-1))
> noBass.vs.Bonce <- list(Bass=c(1,-1,0))
> ## the following gives the 3 "partial interactions" comparing the no-Heron
> ## treatment to the others for each level of Bass
> testInteractions(lm1,custom=noHeron.vs.others, fixed="Bass", adjustment="none")
F Test: 
P-value adjustment method: none
                Value  Df Sum of Sq       F    Pr(>F)    
 none : Heron1 71.893   1     12060 40.2105 4.951e-09 ***
 once : Heron1  7.768   1       141  0.4694    0.4947    
twice : Heron1  1.268   1         4  0.0125    0.9112    
Residuals             112     33591                      
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> ## the following gives the 3 individual contrasts ("partial interactions")
> ## comparing the Bass control to Bass present for each level of Heron
> testInteractions(lm1,custom=noBass.vs.others, fixed="Heron", adjustment="none")
F Test: 
P-value adjustment method: none
                Value  Df Sum of Sq       F    Pr(>F)    
 none : Bass1  60.089   1      8425 28.0906 5.868e-07 ***
 once : Bass1  -4.518   1        48  0.1588    0.6910    
twice : Bass1 -10.054   1       236  0.7863    0.3771    
Residuals             112     33591                      
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> ## the following are "product interactions"
> testInteractions(lm1,custom=c(noHeron.vs.others,noBass.vs.Bonce), adjustment="none")
F Test: 
P-value adjustment method: none
                Value  Df Sum of Sq      F    Pr(>F)    
Heron1 : Bass1 64.125   1      4797 15.995 0.0001142 ***
Residuals             112     33591                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> testInteractions(lm1,custom=c(noHeron.vs.others,Bonce.vx.Btwice), adjustment="none")
F Test: 
P-value adjustment method: none
               Value  Df Sum of Sq      F Pr(>F)
Heron1 : Bass1   6.5   1        49 0.1643  0.686
Residuals            112     33591              
> testInteractions(lm1,custom=c(noBass.vs.others,Honce.vs.Htwice), adjustment="none")
F Test: 
P-value adjustment method: none
                Value  Df Sum of Sq      F Pr(>F)
Bass1 : Heron1 5.5357   1        36 0.1192 0.7305
Residuals             112     33591              
> ## examine a model that includes random effects
> lmm1 <- lmer(normMoves~Heron+Bass+Day+Heron:Bass+Heron:Day+Bass:Day+(1|Trial)+(1|Tank:Trial), data=jeff)
> ## the following gives the 3 "partial interactions" comparing the no-Heron
> ## treatment to the others for each level of Bass
> testInteractions(lmm1,custom=noHeron.vs.others, fixed="Bass", adjustment="none")
Chisq Test: 
P-value adjustment method: none
                Value Df   Chisq Pr(>Chisq)    
 none : Heron1 71.893  1 35.1301  3.084e-09 ***
 once : Heron1  7.768  1  0.4101     0.5219    
twice : Heron1  1.268  1  0.0109     0.9168    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> ## the following gives the 3 individual contrasts ("partial interactions")
> ## comparing the Bass control to Bass present for each level of Heron
> testInteractions(lmm1,custom=noBass.vs.others, fixed="Heron", adjustment="none")
Chisq Test: 
P-value adjustment method: none
                Value Df   Chisq Pr(>Chisq)    
 none : Bass1  60.089  1 24.5415  7.272e-07 ***
 once : Bass1  -4.518  1  0.1387     0.7095    
twice : Bass1 -10.054  1  0.6870     0.4072    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> ## the following are "product interactions"
> testInteractions(lmm1,custom=c(noHeron.vs.others,noBass.vs.Bonce), adjustment="none")
Chisq Test: 
P-value adjustment method: none
                Value Df  Chisq Pr(>Chisq)    
Heron1 : Bass1 64.125  1 13.974  0.0001853 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> testInteractions(lmm1,custom=c(noHeron.vs.others,Bonce.vx.Btwice), adjustment="none")
Chisq Test: 
P-value adjustment method: none
               Value Df  Chisq Pr(>Chisq)
Heron1 : Bass1   6.5  1 0.1436     0.7047
> testInteractions(lmm1,custom=c(noBass.vs.others,Honce.vs.Htwice), adjustment="none")
Chisq Test: 
P-value adjustment method: none
                Value Df  Chisq Pr(>Chisq)
Bass1 : Heron1 5.5357  1 0.1041     0.7469
> ## examine a glm that does not include random effects
> ## the model assumes that Moves values are Poisson distributed
> ## an offset is included to account for loss of fish within a trial
> glm1 <- glm(Moves~Heron+Bass+Day+Heron:Bass+Heron:Day+Bass:Day, offset=log(Fish), family="poisson", data=jeff)
> ## look at the cell means
> (Moves.means <- interactionMeans(glm1, factors=list("Heron","Bass")))
  Heron  Bass adjusted mean
1  none  none      8.453047
2  once  none      2.559665
3 twice  none      1.630959
4  none  once      3.454754
5  once  once      2.881576
6 twice  once      2.199138
7  none twice      3.133247
8  once twice      2.630672
9 twice twice      3.085623
> ## the following gives the 3 "partial interactions" comparing the no-Heron
> ## treatment to the others for each level of Bass
> testInteractions(glm1,custom=noHeron.vs.others, fixed="Bass", adjustment="none")
Chisq Test: 
P-value adjustment method: none
                 Value  Df    Chisq Pr(>Chisq)    
 none : Heron1 17.1159   1 343.5360  < 2.2e-16 ***
 once : Heron1  1.8834   1  13.1550  0.0002867 ***
twice : Heron1  1.2094   1   1.2052  0.2722939    
Residuals              112                        
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> ## examine glmm with random effects, and assumes Moves values are Poisson distributed
> ## an additional random effect for each observation is included to account for overdispersion
> ## log(Fish) is included as an offset to account for loss of fish within a trial
> glmm1 <- glmer(Moves~Heron+Bass+Day+Heron:Bass+Heron:Day+Bass:Day+(1|Trial)+(1|Tank:Trial)+(1|Obs), offset=log(Fish), family="poisson", data=jeff)
> ## look at the cell means
> (Moves.means <- interactionMeans(glmm1, factors=list("Heron","Bass")))
  Heron  Bass adjusted mean
1  none  none     6.5999344
2  once  none     1.3793810
3 twice  none     0.8812827
4  none  once     2.4124537
5  once  once     2.1641249
6 twice  once     1.5007162
7  none twice     1.9077261
8  once twice     1.7587460
9 twice twice     2.1770041
> ## the following gives the 3 "partial interactions" comparing the no-Heron
> ## treatment to the others for each level of Bass
> testInteractions(glmm1,custom=noHeron.vs.others, fixed="Bass", adjustment="none")
Chisq Test: 
P-value adjustment method: none
                Value Df   Chisq Pr(>Chisq)    
 none : Heron1 35.833  1 27.4183  1.639e-07 ***
 once : Heron1  1.792  1  0.7236     0.3950    
twice : Heron1  0.951  1  0.0053     0.9417    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> 
