1

我试图弄清楚如何在 R 的 OpenMx 包中的潜在增长曲线模型中正确添加斜率和截距的预测器。

我想在一个非常简单的增长曲线模型中预测性别的斜率和截距。为了这个问题,假设它是此处文档中描述的模型。

我会添加什么来包含斜率和截距的时不变预测器?在 MPlus 中,我会写i on male;,我会估计从性别变量到潜在截距的路径。要在 OpenMx 中做同样的事情,我是否只需添加该路径规范?我是否需要覆盖任何默认值,以便我不估计这个清单变量的方差或平均路径(或者我这样做)?

为了便于参考,下面是简单增长曲线的代码,以及我为预测器添加的代码。但是,当我添加预测变量时,我得到错误“协方差矩阵不是正定的”。这也是我在真实数据中看到的。

注意,这个问题是在 OpenMx 论坛上交叉发布的。

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)
4

1 回答 1

0

我相信我想通了——必须根据 Kline 的 SEM 书(2011)中的这张图来指定预测变量的方差和平均结构路径: 具有两个预测变量的 LGC 模型

在 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
                         )

克莱恩,RB (2011)。结构方程建模原理与实践。吉尔福德出版社。

于 2013-11-21T17:53:59.903 回答