Describe 襷_狩螻朱 here
螳牛 企
狩 螻 覈(Mixed Effect Model) 螻 螻(fixed effect) 覓伎 螻(random effect) 伎 譬覲襯 る. A 螻 螻, B 覓伎 螻殊企.
Y = AX + BZ + e
HLM れ元 覈(Multilevel Model) 讌螻 螳, 螳瑚骸 豌 螻 襯 螻 襭襯 覿蠍 覈企. 覈 覲企 ク(硫0)螻 蠏螻(硫1)螳 るジ 蠏 襯 螻 .
Y = 硫0 + 硫1X + e
硫0 = 粒00 + 粒01Z + u0
硫1 = 粒10 + 粒11Z + u1
HLM 狩 螻 覈朱 れ . 襷 蠏 蠏 覃 螳.
Y = (粒00 + 粒01Z + u0) + (粒10 + 粒11Z + u1)X + e
願 螳覃 螳.
Y = 粒00 + 粒10X + 粒01Z + 粒11ZX + u0 + u1X + e
企ゼ れ 狩 覈 蠍磯朱 覦蠑碁 螳.
Y = a0 + a1X + a2Z + a3ZX + b0 + b1X + e
lme4
螳 nlme れ lme 覲企 lme4 れ lmer 襯 蟆 蟠. 誤 る 豢. 朱 襷襯 谿瑚.
nlme
nlme れ 觜 狩 螻 覈(nonlinear mixed effect model) 讌. 蠍一 nlme襯 伎 螻 覈((Hierarchical Linear Model:
HLM) る 覦覯 覲願. HLM 狩 螻 覈朱 伎 覦覯 螳牛 螳 蟆企.
襾殊 nlme れ襯 れ碁.
> library(nlme)
襭 襷り鍵
nlme れ 襭襯 覿れ碁.
MathAchieve 襭願,
MathAchSchool 蟲 襭企. Bryk Rodenbush(1992) HLM 豈 襭企.
> data(MathAchieve)
> data(MathAchSchool)
Bryk Rodenbush HLM 襦蠏碁螻 襴 nlme 螳 譴 襭襯 磯 襷れ . 襾殊 覿 襭襯 襷れ企慨. 一 襭 蟲 覯, 蟆曙 譴(socioeconomical status:SES), 煙 觸 HLM 覿 一危壱朱 襷. 企 Bryk手 .
> Bryk = as.data.frame(MathAchieve[c("School","SES","MathAch")])
tapply 襯 伎 蟆曙 譴 蟲覲 蠏 螻壱.
> attach(MathAchieve)
> mses = tapply(SES, School, mean)
> detach(MathAchieve)
Bryk 一危 蟲覲 蠏 щ譴. 豌讌語 襷 蠏 蟲 蠏 SES襯 щ譴. 蠏碁Μ螻 讌語 螳 蟲 蠏 SES SES ク谿襯 蟲.
> Bryk$mses = mses[as.character(Bryk$School)]
> Bryk$cses = Bryk$SES - Bryk$mses
觜訣 覦覯朱 蟲 襭 蟲 譬襯(螻給渚蟲, 豺危襴螻 蟲)襯 觸 Bryk 一危壱 щ碁.
> sector = MathAchSchool$Sector
> names(sector) = row.names(MathAchSchool)
> Bryk$sector = sector[as.character(Bryk$School)]
蟲 覿襯 伎磯企襦 factor襦 覦蠖譴.
> Bryk$sector = factor(Bryk$sector, levels = c("Public", "Catholic"))
contrast coding 蠍 contrasts 襯 . 伎 蠏 Bryk$sector Public 0, Catholic 1襦 貊.
> contrasts(Bryk$sector)
Catholic
Public 0
Catholic 1
覿
Bryk 一危 襭 れ願朱 覿 れ. 覿 覈 螳. 螳 襷覃 蟲 蠏 SES 蟲 譬襯 磯殊 SES 煙 蟯螻螳 覲 蟆 企 覈企.
(MathAch) = 硫0 + 硫1(cse) + e
硫0 = 粒00 + 粒01(mses) + 粒02(sector) + u0
硫1 = 粒10 + 粒11(mses) + 粒12(sector) + u1
覈 狩 螻 覈朱 覦蠑碁 螳.
(MathAch) = 粒00 + 粒01(mses) + 粒02(sector) + u0 + (粒10 + 粒11(mses) + 粒12(sector) + u1)(cses) + e
= 粒00 + 粒01(mses) + 粒02(sector) + 粒10(cses) + 粒11(mses)(cses) + 粒12(sector)(cses) + u1(cses) + u0 + e
覈 螻 螻 覿覿襷 R 蟯螻朱 れ 磯 螳.
MathAch ~ 1 + mses + sector + cses + mses:cses + sector:cses
ク 覈朱 譯殊 蠍磯蓋朱 覩襦 觜手, 語 譴 れ 磯 豌 .
MathAch ~ mses*cses + sector*cses
覓伎 螻朱 R 蟯螻朱 豌 . "| School" 覿 伎 覓伎 螻手 蟲 譴願鍵 覓語企.
~ 1 + cses | School
狩 螻 覈 覿 lme 襯 伎.
> bl = lme(MathAch ~ mses*cses + sector*cses, random=~cses|School, data=Bryk)
伎
るジ 覿螻 襷谿螳讌襦 summary 襯 伎覃 覿 蟆郁骸襯 覲 .
> summary(bl)
Linear mixed-effects model fit by REML
Data: Bryk
AIC BIC logLik
46523.66 46592.45 -23251.83
Random effects:
Formula: ~cses | School
Structure: General positive-definite, Log-Cholesky parametrization
StdDev Corr
(Intercept) 1.5426150 (Intr)
cses 0.3182015 0.391
Residual 6.0597955
Fixed effects: MathAch ~ mses * cses + sector * cses
Value Std.Error DF t-value p-value
(Intercept) 12.127931 0.1992919 7022 60.85510 0e+00
mses 5.332875 0.3691684 157 14.44564 0e+00
cses 2.945041 0.1556005 7022 18.92694 0e+00
sectorCatholic 1.226579 0.3062733 157 4.00485 1e-04
mses:cses 1.039230 0.2988971 7022 3.47688 5e-04
cses:sectorCatholic -1.642674 0.2397800 7022 -6.85076 0e+00
Correlation:
(Intr) mses cses sctrCt mss:cs
mses 0.256
cses 0.075 0.019
sectorCatholic -0.699 -0.356 -0.053
mses:cses 0.019 0.074 0.293 -0.026
cses:sectorCatholic -0.052 -0.027 -0.696 0.077 -0.351
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-3.1592608 -0.7231893 0.0170471 0.7544510 2.9582205
Number of Observations: 7185
Number of Groups: 160
蟆郁骸襦 蠏 れ 磯 豌 .
(MathAch) = 硫0 + 硫1(cse) + e
硫0 = 12.13 + 5.33(mses) + 1.23(sector) + u0
硫1 = 2.95 + 1.04(mses) - 1.64(sector) + u1
u0 ~ N(0, 1.54)
u1 ~ N(0, 0.32)
e ~ N(0, 6.06)