对于我的论文,我很有可能需要某种混合效果规范。我对 SPSS 有一些(非语法)经验,但觉得它不足以满足我的分析。我对 Stata 有非常基本的了解,并决定对该软件包进行更多实验。
我决定尝试在 Stata 中复制 SPSS 的结果作为基本模型。我有 65 所学校的 4059 名学生的数据,调查学生的入门级分数 ( standlrt) 对他们的期末考试分数 ( normexam) 的影响。
在之前的课程中,简要介绍了多级建模,我的老师为我提供了 SPSS 中的语法。
MIXED
normexam WITH standlrt
/FIXED = standlrt
/PRINT = SOLUTION TESTCOV
/RANDOM INTERCEPT standlrt | SUBJECT(school) COVTYPE(VC) .
现在我尝试在 Stata 中复制这些结果,但结果并不一致。Beta 的大小甚至有时甚至符号都不同。
首先我xtset school用来表示我的数据是聚集的。然后我用
xtmixed normexam standlrt || school: standlrt.
这些不一致的结果可能是什么原因造成的?
提前致谢!
附言。这不是家庭作业,我希望我正确地指定了我的第一个问题。
pps。一种可能性可能是“问题”有多个最优值,但我认为在这样一个基本模型中情况并非如此,也因为它是一个单变量回归。此外,估计时执行的迭代过程可能会产生不同的结果,但我认为这会产生很大的影响,比如符号变化。
编辑
这是我的Stata输出
xtmixed normexam standlrt || school: standlrt
Mixed-effects REML regression Number of obs = 4059
Group variable: school Number of groups = 65
Obs per group: min = 2
avg = 62.4
max = 198
Wald chi2(1) = 768.21
Log restricted-likelihood = -4667.8385 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
normexam | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
standlrt | .5570213 .0200971 27.72 0.000 .5176317 .5964108
_cons | -.0080944 .0400842 -0.20 0.840 -.086658 .0704691
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
school: Independent |
sd(standlrt) | .1214197 .0191066 .0891958 .1652852
sd(_cons) | .3032317 .0309434 .2482638 .3703699
-----------------------------+------------------------------------------------
sd(Residual) | .7440605 .0083943 .7277885 .7606962
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(2) = 438.60 Prob > chi2 = 0.0000
这是我的 SPSS 输出
-2 Restricted Log Likelihood 9335,677
Type III Tests of Fixed Effects(a)
|---------|------------|--------------|-------|----|
|Source |Numerator df|Denominator df|F |Sig.|
|---------|------------|--------------|-------|----|
|Intercept|1 |60,466 |,041 |,841|
|---------|------------|--------------|-------|----|
|standlrt |1 |56,936 |768,207|,000|
|---------|------------|--------------|-------|----|
a. Dependent Variable: normexam = final exam scores.
Estimates of Fixed Effects(a)
|---------|--------|----------|------|------|----|-----------------------------------|
|Parameter|Estimate|Std. Error|df |t |Sig.|95% Confidence Interval |
| | | | | | |-----------------------|-----------|
| | | | | | |Lower Bound |Upper Bound|
|---------|--------|----------|------|------|----|-----------------------|-----------|
|Intercept|-,008094|,040084 |60,466|-,202 |,841|-,088262 |,072073 |
|---------|--------|----------|------|------|----|-----------------------|-----------|
|standlrt |,557021 |,020097 |56,936|27,717|,000|,516777 |,597266 |
|---------|--------|----------|------|------|----|-----------------------|-----------|
a. Dependent Variable: normexam = final exam scores.
Covariance Parameters
Estimates of Covariance Parameters(a)
|-------------------------------------|--------|----------|------|----|-----------------------------------|
|Parameter |Estimate|Std. Error|Wald Z|Sig.|95% Confidence Interval |
| |--------| | | | |-----------------------|-----------|
| | | | | |Lower Bound |Upper Bound|
|----------------------------|--------|--------|----------|------|----|-----------------------|-----------|
|Residual |,553626 |,012492 |44,319|,000|,529676 |,578659 |
|----------------------------|--------|--------|----------|------|----|-----------------------|-----------|
|Intercept [subject = school]|Variance|,091949 |,018766 |4,900 |,000|,061635 |,137174 |
|----------------------------|--------|--------|----------|------|----|-----------------------|-----------|
|standlrt [subject = school] |Variance|,014743 |,004640 |3,177 |,001|,007956 |,027319 |
|----------------------------|--------|--------|----------|------|----|-----------------------|-----------|
a. Dependent Variable: normexam = final exam scores.
如您所见,对数似然是相同的。此外,固定效应表是相同的。然而,随机效应是不同的。我的解释还不是很熟练,但结果似乎有所不同。
这些是方差-协方差矩阵的设置
Model
covariance(vartype) variance-covariance structure of the random
effects
vartype Description
-------------------------------------------------------------------------
independent one variance parameter per random effect, all
covariances zero; the default unless a factor
variable is specified
exchangeable equal variances for random effects, and one
common pairwise covariance
identity equal variances for random effects, all
covariances zero; the default for factor
variables
unstructured all variances and covariances distinctly
estimated
我在网上读到COVTYPE(VC) requests the default (variance component) structure for random effects, which assumes all random effects are independent.