Hi there,
Now I have a problem about CI estimation in a common pathway model. I can not estimate the CI of the path coeffcients of latent factors. I added following codes to the script:
matIl <- mxMatrix( type="Iden", nrow=nf, ncol=nf, name="Il")
invSDl <- mxAlgebra( expression=solve(sqrt(IlV)), name="iSDl")
sta <- mxAlgebra(iSDl %% al, name="sta") # standarized path coefficients of A
stc <- mxAlgebra(iSDl %% cl, name="stc") # standarized path coefficients of C
ste <- mxAlgebra(iSDl %% el, name="ste") # standarized path coefficients of E
The nf denotes the number of latant factors. If I use the nv (the number of all components in the model), the results will only show the parameters of components, not the latant factor which I'm interesed with. But now, it reply with "Error in runHelper(model, frontendStart, intervals, silent, suppressWarnings, : Setting improper index (1) from vector of Rf_length 0". I don't know how can I settle it (If I remove these codes, the script could run smoothly without estimating the standardized path coefficients). How can I reivise the codes? Many thanks.
Best,
Lizhi
Are the latents constrained to have variance of 1 i.e., the a, c, and e inputs total 1?
No. How to constrained the latent variance to 1? Not the following codes?
matIl <- mxMatrix( type="Iden", nrow=nf, ncol=nf, name="Il")
invSDl <- mxAlgebra( expression=solve(sqrt(Il*V)), name="iSDl")
And why should the latents variance be fixed on 1. Actually, if I only estimatelatent path parameters, not their CI. The script could run smoothly. Many thanks.
It's pretty much impossible to troubleshoot without seeing the full script you're using.
It's likely the problem is connected to your
mxCI()
statement. Seeing that in the context of the full script would help with troubleshooting.To identify the scale of the latent variables, there needs to be a constraint on their variances (or alternately, on the paths running from latent to manifest variables). However, if you're adapting an existing script, the constraint on the latent variances is probably implicitly built-in.
Many thanks, Rob. Attached is my full script. It is a two factor common path way model. The problem is the part of CI setup, if I deleted this part, the script could run smoothly:
Standeraized parameters and CI
sta <- mxAlgebra(iSD %% al, name="sta")
stc <- mxAlgebra(iSD %% cl, name="stc")
ste <- mxAlgebra(iSD %*% el, name="ste")
StandardizedA <- mxAlgebra(A/V, name="StandardizedA")
StandardizedC <- mxAlgebra(C/V, name="StandardizedC")
StandardizedE <- mxAlgebra(E/V, name="StandardizedE")
CI <- mxCI(c('sta', 'stc', 'ste','StandardizedA', 'StandardizedC', 'StandardizedE'))
The matrix dimension of iSD (3x3x3) is different from that of "al“ (2x2x2), ”cl” or “el”. I'm still not clear why the multiply of "iSD" by "al" or "a" in the one trait ACE model indicate the standardization.
Full script as below:
(I edited the above post to make the script easier to read.)
Many thanks Rob. Do u know how can I set the CI of standardized latent factor path coeffecients?
We've had a tough time troubleshooting the problem you're reporting, since we don't have the data to run your script. Can you share your data, or maybe generate data that's similar to it?
Many thanks for your kind help, Rob! I have figured it out yestarday. It's about the matrix setting. For the "V" contains the varience of all the phenotype and latent factor, hence I make a new matrix which only contains the variance of latent factors, and then multiply this matrix with I (2x2) and al. The script runs successfully and the results seems correct.
Many thanks and best wishes,
Lizhi
There's something I forgot to mention. I think you might still be missing something crucial to model identification here. You don't actually have the MxConstraint needed for model identification. I guess it would be something like
which you would need to then put into your MxModel.
You mean the constraint of latent valence? Are the following codes enough, or I should add the code you suggested to it?
Matrix and Algebra for constraint on variance of latent phenotype
covarLP <- mxAlgebra( expression= al %% t(al) + cl %% t(cl) + el %*% t(el), name="CovarLP" )
varLP <- mxAlgebra( expression= diag2vec(CovarLP), name="VarLP" )
unit <- mxMatrix( type="Unit", nrow=2, ncol=1, name="Unit")
Something like this:
And you would need to put
indentifyingConstraint
somewhere in your MxModel.I see. Now I have put it in my MxModel. Many thanks Rob! :D
I believe that:
should really be
so that the matrices end up the same dimension as iSDI etc.
I note also that the standardization approach isn't ideal - and could cause problems with submodels if, e.g., one of the elements of V, which is used as a denominator in a division, is zero. This would happen if A C and E covariances (but not variances) were set to zero.
Many thanks. The pathAl, pathCl and pathEl are the matrix of latent factors. There are two latent factors in this model. Hence the dimension of matrix should be 2X2 rather than 3X3X3? But the nv denotes the number of observed traits.
Yep, should be 2x2, nf, I have fixed my post.