Escolar Documentos
Profissional Documentos
Cultura Documentos
Spring 2014
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
1 / 69
Outline
1.
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
2 / 69
Outline
1.
2.
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
2 / 69
Outline
1.
2.
3.
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
2 / 69
Outline
1.
2.
3.
4.
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
2 / 69
Outline
1.
2.
3.
4.
5.
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
2 / 69
Outline
1.
2.
3.
4.
5.
6.
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
2 / 69
Outline
1.
2.
3.
4.
5.
6.
7.
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
2 / 69
R packages
Packages incorporate functions, data and documentation.
You can produce packages for private or in-house use or you can
contribute your package to the Comprehensive R Archive Network
(CRAN), http://cran.R-project.org
We will be using the lme4 package from R-forge. Install it from the
Packages menu item or with
> install.packages("lme4")
or
> library(lme4)
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
..
.
..
.
..
3 / 69
Accessing documentation
To be added to CRAN, a package must pass a series of quality control
checks. In particular, all functions and data sets must be
documented. Examples and tests can also be included.
The data function provides names and brief descriptions of the data
sets in a package.
> data ( package = " lme4 " )
Data sets in package 'lme4':
Dyestuff
Dyestuff2
Pastes
Penicillin
cake
cbpp
sleepstudy
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
4 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
5 / 69
Yield
Min.
:1440
1st Qu.:1469
Median :1530
Mean
:1528
3rd Qu.:1575
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
6 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
7 / 69
Batch
C
B
A
D
F
1450
1500
1550
1600
The line joins the mean yields of the six batches, which have been
reordered by increasing mean yield.
The vertical positions are jittered slightly to reduce overplotting. The
lowest yield for batch A was observed on two distinct preparations
from that batch.
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
..
.
..
.
..
8 / 69
3Q
0.779
Max
1.830
Random effects:
Groups
Name
Variance Std.Dev.
Batch
(Intercept) 1764
42.0
Residual
2451
49.5
Number of obs: 30, groups: Batch, 6
Fixed effects:
Estimate Std. Error t value
(Intercept)
1527.5
19.4
78.8
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
Fitted model fm1 has one fixed-eect parameter, the mean yield, and
..
Spring 2014
..
.
..
9 / 69
B
0.39126
C
D
28.56223 -23.08454
E
F
56.73319 -44.99529
> fitted(fm1)
1
2
3
4
5
6
7
8
9
10
11
1509.9 1509.9 1509.9 1509.9 1509.9 1527.9 1527.9 1527.9
.
.1527.9
. . . . . 1527.9
. . . . . .1556.1
. .
.
.. 19
..
.. .. .. ..20
.. .. .. .. .. 21
.. .. .. .. .. 22
..
12
13
14
15
16
17
18
Douglas
Bates (Stat.
850) 1556.1 1504.4Simple
scalar 1504.4
models
Spring1584.2
2014
1556.1
1556.1
1556.1
1504.4
1504.4 1504.4 1584.2
.
..
.
..
.
..
10 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
11 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
12 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
13 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
14 / 69
1 1 1 1 1 . . . . .
. . . . . 1 1 1 1 1
. . . . . . . . . .
. Douglas
. . .Bates
. . (Stat.
. . 850)
. .
.
.
1
.
.
.
1
.
.
.
1
.
.
.
1
.
.
.
1
.
.
.
.
1
. . . . . . .
. . . . . . .
. . . . . . .
1 1 1scalar
1 .models
. .
Simple
.
.
.
.
.
.
.
.
.
.
...
.
.
.
.
.
.
..
. .
. .
. .
. .. ...
. .
.
..
.
.
.
.
. . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
15 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
16 / 69
50
..
.
..
.
..
100
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
17 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
18 / 69
BIC
337.5
['lmerMod']
Scaled residuals:
Min
1Q Median
-1.431 -0.797 0.148
3Q
0.772
Max
1.804
Random effects:
Groups
Name
Variance Std.Dev.
Batch
(Intercept) 1388
37.3
Residual
2451
49.5
Number of obs: 30, groups: Batch, 6
Fixed effects:
Estimate Std. Error t value
(Intercept)
1527.5
17.7
86.3
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Douglas
Bates parentheses
(Stat. 850)
Simple assignment
scalar models
(The
extra
around the
cause the valueSpring
to 2014
be
.
..
.
..
.
..
.
..
19 / 69
Verbose fitting
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
20 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
21 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
22 / 69
Batch
10
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
23 / 69
BIC
173.1
['lmerMod']
Scaled residuals:
Min
1Q Median
-1.7950 -0.7940 -0.0823
3Q
0.6803
Max
2.1264
Random effects:
Groups
Name
Variance Std.Dev.
Batch
(Intercept) 0.0
0.00
Residual
13.3
3.65
Number of obs: 30, groups: Batch, 6
Fixed effects:
Estimate Std. Error t value
(Intercept)
5.666
0.667
8.49
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
24 / 69
Call:
lm(formula = Yield ~ 1, data = Dyestuff2)
Residuals:
Min
1Q Median
-6.558 -2.901 -0.301
3Q
2.485
Max
7.768
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)
5.666
0.678
8.35 3.3e-09
Residual standard error: 3.72 on 29 degrees of freedom
> logLik(lm1)
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
25 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
26 / 69
d
1
1
1
1
1
1
e
1
1
1
1
1
1
f
1
1
1
1
1
1
g
1
1
1
1
1
1
h
1
1
1
1
1
1
i
1
1
1
1
1
1
j
1
1
1
1
1
1
k
1
1
1
1
1
1
l
1
1
1
1
1
1
m
1
1
1
1
1
1
n
1
1
1
1
1
1
o
1
1
1
1
1
1
p
1
1
1
1
1
1
q
1
1
1
1
1
1
r
1
1
1
1
1
1
s
1
1
1
1
1
1
t
1
1
1
1
1
1
u
1
1
1
1
1
1
v
1
1
1
1
1
1
w
1
1
1
1
1
1
x
1
1
1
1
1
1
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
..
.
..
.
..
m
t
o
k
h
b
a
n
l
d
Plate
c
p
e
v
r
q
f
w
j
i
u
x
s
g
18
20
22
24
26
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
28 / 69
3Q
0.5838
Max
2.9796
Random effects:
Groups
Name
Variance Std.Dev.
plate
(Intercept) 0.717
0.847
sample
(Intercept) 3.731
1.932
Residual
0.302
0.550
Number of obs: 144, groups: plate, 24 sample, 6
Fixed effects:
Estimate Std. Error t value
(Intercept)
22.972
0.809
28.4
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
29 / 69
d
e
f
g
h
0.337391 0.025953 -0.441203 -1.375516 0.804547
l
m
n
o
p
0.493109 1.427422 0.493109 0.960266 0.025953
t
u
v
w
x
0.960266 -0.908360 -0.285484 -0.596922 -1.219797
$sample
A
B
2.187058 -1.010476
C
D
E
F
1.937899 -0.096895 -0.013842 -3.003744
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
30 / 69
plate
m
t
o
k
b
a
h
n
l
d
c
p
e
r
v
q
f
w
j
i
u
x
s
g
2
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
31 / 69
5
10
15
20
25
50
100
Z'
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
32 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
33 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
34 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
35 / 69
strength:
batch
:
cask
:
sample :
num 62.8
Factor w/
Factor w/
Factor w/
56.9 ...
1 1 2 2 2 2 ...
2 2 ...
2 3 3 4 4 5 5 ...
A
B
C
D
E
F
G
H
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
2
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
...
.
.
.
.
.
.
..
..
.
]]
. .
. .
. .
. .
. .
. .
.. . ..
.. .. ..
. .
.
.
.
.
.
.
...
.. ..
.
. . . . . . . .
.. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
36 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
37 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
38 / 69
H
A
C
F
G
D
B
I
J
H:b
H:c
H:a
A:c
A:a
A:b
C:c
C:b
C:a
F:a
F:c
F:b
G:a
G:b
G:c
D:c
D:b
D:a
B:a
B:c
B:b
I:b
I:c
I:a
J:b
J:a
J:c
E:c
E:a
E:b
54
56
58
60
62
64
66
Paste strength
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
39 / 69
3Q
0.4720
Max
1.3897
Random effects:
Groups
Name
Variance Std.Dev.
sample
(Intercept) 8.434
2.904
batch
(Intercept) 1.657
1.287
Residual
0.678
0.823
Number of obs: 60, groups: sample, 30 batch, 10
Fixed effects:
Estimate Std. Error t value
(Intercept)
60.053
0.677
88.7
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
40 / 69
sample
0
D:c
I:b
H:b
C:c
F:a
H:c
C:b
G:a
A:c
A:a
B:a
A:b
B:c
G:b
F:c
J:b
E:c
J:a
F:b
J:c
H:a
D:b
I:c
B:b
C:a
G:c
D:a
E:a
E:b
I:a
5
5
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
41 / 69
10
20
30
10
20
30
40
50
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
42 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
43 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
44 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
45 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
46 / 69
3Q
0.4653
Max
1.3885
Random effects:
Groups
Name
Variance Std.Dev.
sample
(Intercept) 9.977
3.159
Residual
0.678
0.823
Number of obs: 60, groups: sample, 30
Fixed effects:
Estimate Std. Error t value
(Intercept)
60.053
0.586
102
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
47 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
..
.
..
.
..
48 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
..
.
..
.
..
49 / 69
9
1
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
50 / 69
70
68
17
15
57
33
46
85
71
12
99
146
83
152
261
311
244
298
271
263
57
10
177
216
87
7
5
92
85
119
260
40
36
171
250
272
229
26
100
32
88
19
71
133
240
69
196
84
157
66
186
209
120
80
304
264
81
251
49
20
302
236
226
205
266
214
28
287
136
277
8
76
50
100
150
200
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
51 / 69
3Q
0.533
Max
5.634
Random effects:
Groups
Name
Variance Std.Dev.
classid (Intercept)
99.2
9.96
schoolid (Intercept)
77.5
8.80
Residual
1028.2
32.07
Number of obs: 1190, groups: classid, 312 schoolid, 107
Fixed effects:
Estimate Std. Error t value
(Intercept)
57.43
1.44
39.8
Douglas Bates (Stat. 850)
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
52 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
53 / 69
Model-building approach
Note that these unbalanced data have, for the most part, very few
classes per school (sometimes as few as 1) and very few students per
class (also sometimes as few as 1). Under these circumstances, it is
optimistic to expect to be able to partition the variability across
students, classes and schools.
We should consider adding fixed-eects terms and perhaps removing
one of the random-eects terms.
We will start by incorporating fixed-eects terms then revisit the need
for both random-eects terms.
We will begin with the fixed-eects terms adopted as a final model in
chapter 4 of West, Welch and Galecki (2007).
For brevity, we only display the output of model fits as this contains
enough information to reconstruct the call to lmer.
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
54 / 69
3Q
0.552
Max
4.273
Random effects:
Groups
Name
Variance Std.Dev.
classid (Intercept) 81.6
9.03
schoolid (Intercept) 77.8
8.82
Residual
734.4
27.10
Number of obs: 1190, groups: classid, 312 schoolid, 107
Fixed effects:
Estimate Std. Error t value
(Intercept) 285.0580
11.0208
25.87
mathkind
-0.4709
0.0223 -21.13
minorityY
-7.7559
2.3850
-3.25
sexF
-1.2346
1.6574
-0.74
Douglas Bates (Stat. 850)
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
55 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
56 / 69
3Q
0.565
Max
4.252
Random effects:
Groups
Name
Variance Std.Dev.
classid (Intercept) 81.1
9.01
schoolid (Intercept) 77.6
8.81
Residual
734.5
27.10
Number of obs: 1190, groups: classid, 312 schoolid, 107
Fixed effects:
Estimate Std. Error t value
(Intercept) 284.7035
11.0087
25.86
mathkind
-0.4714
0.0223 -21.17
minorityY
-7.7805
2.3839
-3.26
ses
5.2570
1.2446
4.22
Douglas Bates (Stat. 850)
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
57 / 69
3Q
0.557
Max
4.247
Random effects:
Groups
Name
Variance Std.Dev.
classid (Intercept) 82.8
9.10
schoolid (Intercept) 75.0
8.66
Residual
734.6
27.10
Number of obs: 1190, groups: classid, 312 schoolid, 107
Fixed effects:
Estimate Std. Error t value
(Intercept) 282.4193
10.8406
26.05
mathkind
-0.4703
0.0223 -21.14
minorityY
-8.2909
2.3389
-3.54
ses
5.3646
1.2407
4.32
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
58 / 69
30
20
10
10
..
.
..
20
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
59 / 69
With many levels of the grouping factor, use a normal probability plot of
the prediction intervals for the random eects.
> qqmath(ranef(fm8, condVar = TRUE))$classid
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
60 / 69
20
10
10
..
.
..
20
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
61 / 69
BIC
11446
Scaled residuals:
Min
1Q Median
-6.025 -0.647 -0.027
3Q
0.572
Max
4.128
Random effects:
Groups
Name
Variance Std.Dev.
schoolid (Intercept) 97.9
9.89
Residual
789.1
28.09
Number of obs: 1190, groups: schoolid, 107
Fixed effects:
Estimate Std. Error t value
(Intercept) 282.3041
10.9014
25.90
mathkind
-0.4705
0.0224 -21.03
minorityY
-7.7958
2.3504
-3.32
ses
5.5195
1.2492
4.42
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
62 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
63 / 69
..
..
.. .. .. ..
.. .. .. ..
.. .. .. ..
..
Spring 2014
..
..
..
..
64 / 69
A preliminary model
Linear mixed model fit by REML
Formula: gr.pt ~ (1 | id) + (1 | instr) + (1 | dept)
Data: anon.grades.df
AIC
BIC
logLik deviance REMLdev
3447389 3447451 -1723690 3447374 3447379
Random effects:
Groups
Name
Variance Std.Dev.
id
(Intercept) 0.3085
0.555
instr
(Intercept) 0.0795
0.282
dept
(Intercept) 0.0909
0.301
Residual
0.4037
0.635
Number of obs: 1685394, groups: id, 54711; instr, 7915; dept, 102
Fixed effects:
Estimate Std. Error t value
(Intercept)
3.1996
0.0314
102
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
65 / 69
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
66 / 69
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
67 / 69
Spring 2014
68 / 69
For lmer a simple, scalar random eects term is of the form (1|F).
The number of random eects generated by the i th such term is the
number of levels, ni , of F (after dropping unused levels those
that do not occur in the data. The idea of having such levels is not as
peculiar as it may seem if, say, you are fitting a model to a subset of
the original data.)
Such a term contributes ni columns to Z . These columns are the
indicator columns of the grouping factor.
Such a term contributes a diagonal block i2 I ni to . The multipliers
i2 can be dierent for dierent terms. The term contributes exactly
one element (which happens to be i /) to .
..
.
..
.
..
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
Spring 2014
.
..
.
..
.
..
.
..
69 / 69