我正在试图找出如何在R的OpenMx包中的潜在增长曲线模型中正确添加斜率预测器和截距。
我想在一个非常简单的增长曲线模型中预测斜率和截距,比如性别。为了这个问题,让我们说它是文档here中描述的模型。
我要添加什么来包括斜率和截距的时间不变预测器?在MPlus中,我会写i on male;
,我会估计从性别变量到潜在拦截的路径。要在OpenMx中执行相同的操作,我只需添加该路径规范吗?我是否需要覆盖任何默认值,以便我不估计此清单变量的方差或平均路径(或者我这样做)?
为便于参考,下面是简单增长曲线的代码,以及我为预测变量添加的内容。然而,当我添加预测器时,我得到错误'协方差矩阵不是正定的'。这也是我在实际数据中看到的。
n.b。,这个问题在OpenMx论坛上是cross posted。
myLongitudinalData=data.frame(x1=rnorm(100),
x2=rnorm(100),
x3=rnorm(100),
x4=rnorm(100),
x5=rnorm(100),
male=round(runif(100,0,1)))
require(OpenMx)
growthCurveModel <- mxModel("Linear Growth Curve Model Path Specification",
type="RAM",
mxData(
myLongitudinalData,
type="raw"
),
manifestVars=c("x1","x2","x3","x4","x5"),
latentVars=c("intercept","slope"),
# residual variances
mxPath(
from=c("x1","x2","x3","x4","x5"),
arrows=2,
free=TRUE,
values = c(1, 1, 1, 1, 1),
labels=c("residual","residual","residual","residual","residual")
),
# latent variances and covariance
mxPath(
from=c("intercept","slope"),
arrows=2,
connect="unique.pairs",
free=TRUE,
values=c(1, 1, 1),
labels=c("vari", "cov", "vars")
),
# intercept loadings
mxPath(
from="intercept",
to=c("x1","x2","x3","x4","x5"),
arrows=1,
free=FALSE,
values=c(1, 1, 1, 1, 1)
),
# slope loadings
mxPath(
from="slope",
to=c("x1","x2","x3","x4","x5"),
arrows=1,
free=FALSE,
values=c(0, 1, 2, 3, 4)
),
# manifest means
mxPath(
from="one",
to=c("x1", "x2", "x3", "x4", "x5"),
arrows=1,
free=FALSE,
values=c(0, 0, 0, 0, 0)
),
# latent means
mxPath(
from="one",
to=c("intercept", "slope"),
arrows=1,
free=TRUE,
values=c(1, 1),
labels=c("meani", "means")
)
) # close model
growthCurveFit <- mxRun(growthCurveModel)
summary(growthCurveFit)
我尝试添加预测变量 - 我将性别变量添加到清单变量,然后创建从它到潜在变量的路径定义(向下):
growthCurveModel2 <- mxModel("Linear Growth Curve Model Path Specification",
type="RAM",
mxData(
myLongitudinalData,
type="raw"
),
manifestVars=c("x1","x2","x3","x4","x5","male"),
latentVars=c("intercept","slope"),
# residual variances
mxPath(
from=c("x1","x2","x3","x4","x5"),
arrows=2,
free=TRUE,
values = c(1, 1, 1, 1, 1),
labels=c("residual","residual","residual","residual","residual")
),
# latent variances and covariance
mxPath(
from=c("intercept","slope"),
arrows=2,
connect="unique.pairs",
free=TRUE,
values=c(1, 1, 1),
labels=c("vari", "cov", "vars")
),
# intercept loadings
mxPath(
from="intercept",
to=c("x1","x2","x3","x4","x5"),
arrows=1,
free=FALSE,
values=c(1, 1, 1, 1, 1)
),
# slope loadings
mxPath(
from="slope",
to=c("x1","x2","x3","x4","x5"),
arrows=1,
free=FALSE,
values=c(0, 1, 2, 3, 4)
),
# manifest means
mxPath(
from="one",
to=c("x1", "x2", "x3", "x4", "x5"),
arrows=1,
free=FALSE,
values=c(0, 0, 0, 0, 0)
),
# latent means
mxPath(
from="one",
to=c("intercept", "slope"),
arrows=1,
free=TRUE,
values=c(1, 1),
labels=c("meani", "means")
),
mxPath(
from="male",
to=c("intercept", "slope"),
arrows=1,
free=TRUE,
values=c(1,1),
labels=c("iOnMale", "sOnMale"))
) # close model
growthCurveFit2 <- mxRun(growthCurveModel2)
summary(growthCurveFit2)
答案 0 :(得分:0)
我相信我想出来了 - 必须指定预测变量的方差和平均结构路径,与Kline的SEM书(2011)中的这个图一致:
在MPlus中,我认为回归潜在斜率和预测器上的截距的默认值是将平均结构路径设置为0,将方差路径设置为1。 我不是100%肯定这一点,但这给了我一个相同的参数化和非常相似的估计。所以,我将这个片段添加到上面的第二个模型中:
#Predictor mean structure
mxPath(
from="one",
to="male",
arrows=1,
free=FALSE,
values = 0
),
#Predictor Variance
mxPath(
from="male",
arrows=2,
free=FALSE,
values = 1
)
Kline,R。B.(2011)。结构方程模型的原理与实践。吉尔福德出版社。