Hello,
I was wondering if there is an easy way to tell OpenMx to estimate all of the correlations among a set of exogenous variables, rather than specifying each of the correlations line-by-line in mxPath statements.
For example, suppose exogenous variables are:
IVs <- c("COREREL", "JOBPAY", "SEX_2")
I tried to automate a way to include the exogenous correlations for an arbitrary number of variables as:
These.Pairs <- combn(IVs, 2)
Here <- NA
for(i in 1:dim(These.Pairs)[2])
{
Here <- rbind(Here, paste("mxPath(from=", These.Pairs[1,i], ", to=", These.Pairs[2,i], ", arrows=2, free=TRUE),", sep=""))
}
Here <- na.omit(rbind(Here))
which produces:
> Here
[,1]
"mxPath(from=COREREL, to=JOBPAY, arrows=2, free=TRUE),"
"mxPath(from=COREREL, to=SEX_2, arrows=2, free=TRUE),"
"mxPath(from=JOBPAY, to=SEX_2, arrows=2, free=TRUE),"
attr(,"na.action")
Here
1
attr(,"class")
[1] "omit"
The structure of the mxPath statements is correct, but I've not been able to appropriately "feed" OpenMx the information contained in "Here." I'm guessing there is an easier way to do this or a way to get OpenMx to understand the "Here" object. Any thoughts would be appreciated.
Thanks,
Ken