Attachment | Size |
---|---|
MVcor3var_ IP_CP_OpenMx.R | 55.19 KB |
For anyone interested in running multivariate genetic models with sex as a moderating variable, here is a script
based on the correlated factors approach to ensure that the order of the variables does not affect the ability of the model to account for the DZOS data.
(Ref: Neale et al., Multivariate genetic analysis of sex-lim and G x E interaction, Twin Research & Human Genetics, 2006 ).
The author is dr.Frühling Rijsdijk, who has approved of the sharing of the script.
Thank you for the script! It is indeed very useful.
I know it's been quite a while since it was posted, but I'd like to ask you a detailed question. The within-trait cross-twin covariance (for DZOS pairs) is here defined as:
am %%(CorMFa%%Raf)%*% t(af)
. As far as I understand, here Raf is a genetic correlation between traits in female pairs and CorMFa is a genetic correlation within a trait, but across DZOS pairs. In this case we get two double-headed arrows in the path, and this is not allowed as far as I remember. Am I misunderstanding something?Thank you.
Julia
I am going to try to use this script for 4 ordinal variables . I have a question about the variables. The first 4 are:
T1SEX T2SEX T1AGE T2AGE
which I assume means "twin 1 sex" "twin 2 sex" "twin 1 age" "twin 2 age".
-Correct?
Then we have:
T1M T2M T1F T2F
-Is this "trait 1 males, trait 2 males, trait 1 females, trait 2 females" ?
Then we have:
T1T T2T ZYG ZYGSEX
Thanks,
Tom
On a related but different note, I adapted a script from the Boulder Workshop to run a Bivariate Correlated Factor Sex Limitation Model with no opposite sex twins. While mostly successful, the model is not estimating means for males- therefore I am missing two parameters- and the output for the standardized estimates seems to have redundant estimates. Could someone help point me to the error in my script that causing this?
In addition, I receive the error "The Hessian at the solution does not appear to be convex (Mx status RED). " Which I am hoping will stop when I fix the script.
Thank you for your help,
Roxmanda
The warning about the Hessian, plus your suspicion of redundant estimates, makes me suspect some kind of model unidentification. When I construct the MxModel in the script (without MxData objects) and run
omxGetParameters(HetRgAceModel)
, I getDoes that look wrong in any way? Also, what do you get when you run
mxCheckIdentification(HetRgAceFit, TRUE)
?From looking at the script, I only see one thing amiss, but it would imply too few parameters instead of too many. Namely, from the way "expMeanGf" and "expMeanGm" are defined, the two phenotypes would have the same mean within each sex. Is that what you want? I suspect it isn't, since the parameterization of the within-person covariance structure allows the two phenotypes to have different variances. If my suspicion is correct, then you probably want to do something like
It would be helpful if you posted the model's output, and point out where results seem to be missing and where they seem to be redundant.
Rob,
You are a huge life saver! You are correct that I was missing two means so that I would have male and female means for each trait. Now that I have fixed the code omxGetParameters(HetRgAceModel) produces:
Now my output is:
I have not figure out how to paste output in the forums yet...
So this Hessian issue.... When I run mxCheckIdentification(HetRgAceFit, TRUE), I get:
"Error: Identification check is not possible for models with 'MxFitFunctionAlgebra', 'MxFitFunctionRow', and 'MxFitFunctionR' fit functions. If you have a multigroup model, use mxFitFunctionMultigroup."
I have been trying to use mxFitFunctionMultigroup but I am suck again. Previously I used:
So I removed the mxAlgebra and mxFitFunctionAlgebra lines for:
obj <- mxFitFunctionMultigroup(cbind("MZf", "DZf","MZm", "DZm" ))
But then I get the error: Error in checkAtAssignment("MxFitFunctionMultigroup", "groups", "matrix") :
assignment of an object of class “matrix” is not valid for @‘groups’ in an object of class “MxFitFunctionMultigroup”; is(value, "MxOptionalCharOrNumber") is not TRUE"
Thank you for your help, again!
Amanda
I edited your post to tag syntax and output with 'code' HTML tag. This tag causes the text to be displayed in a fixed-width "typewriter" font, which makes it easier to read; also, on our forum, it applies R syntax highlighting to the text.
Four of the free parameters are at their lower bounds. It's very possible that the optimizer has found a local minimum, subject to the parameter bounds. The Hessian won't necessarily be convex if the solution is on a boundary, so the warning about status Red may well be technically accurate but not cause for concern (except I wouldn't put too much trust in the standard errors). You could try eliminating the lower bound on those parameters, though the interpretability of your results might suffer. Maybe a better course of action is to just drop C from the model for both sexes.
Use
c()
in place ofcbind()
, and try again.