Common Pathways model with age moderation

4 replies [Last post]
koak's picture
Offline
Joined: 05/10/2012

Hello

I am wondering if it is possible to apply the age moderation script from Boulder (attached) to the Common Pathways model? I have tried to do it but end up with multiple problems (one of which is how to add an age moderation to the f component - but that is almost the least of my worries) - my attempt is also attached. Any help would be greatly appreciated.

Thank you in advance

Karen

AttachmentSize
ModTwinMaRawCon.R10.52 KB
Common Pathways - with age moderator.R19.27 KB
koak's picture
Offline
Joined: 05/10/2012
Dummy data set for common pathways with age moderation

Hello Mike

Thank you so much for looking at this. Attached is a dummy data set and a revised script with a couple of changes I realised were needed.

Thank you

Karen

AttachmentSize
DASS_Data_Dummy.csv 47.9 KB
Common Pathways - with age moderator.R 12.76 KB
neale's picture
Offline
Joined: 07/31/2009
It runs now

I fixed a few things and have it running. The key issue was around the size of the b matrix of regression parameters, which I figure needs to be nv x 2, so that b %*% rbind(Age,Age^2) ends up with dimensions nv x 1. This in turn needs to be transposed to be added to twin 1 and twin 2 expected (grand) means. Note that I figure you want different regression parameters on the Age and Age^2 covariates for each of the different variables (but the same for both twins).

The key to figuring this out was looking at the matrices it was having trouble getting to conform:

Error: The following error occurred while evaluating the subexpression 'ADE.Mean + MZ.AgeR' during the evaluation of 'MZ.expMean1' in model 'ADE_Common' : non-conformable arrays
> ADE_Common_Model$ADE.Mean
FullMatrix 'Mean' 
 
@labels
     [,1]      [,2]      [,3]     [,4]      [,5]      [,6]    
[1,] "Depress" "Anxiety" "Stress" "Depress" "Anxiety" "Stress"
 
@values
         [,1]     [,2]     [,3]     [,4]     [,5]     [,6]
[1,] 1.787415 1.552974 2.407627 1.787415 1.552974 2.407627
 
@free
     [,1] [,2] [,3] [,4] [,5] [,6]
[1,] TRUE TRUE TRUE TRUE TRUE TRUE
 
@lbound: No lower bounds assigned.
 
@ubound: No upper bounds assigned.
 
> ADE_Common_Model$MZ.AgeR
mxAlgebra 'AgeR' 
@formula:  ADE.b %*% rbind(Age, Age^2) 
@result: (not yet computed) <0 x 0 matrix>
dimnames: NULL
> ADE_Common_Model$ADE.b
FullMatrix 'b' 
 
@labels
     [,1]  [,2] 
[1,] "l11" "q11"
 
@values
     [,1] [,2]
[1,] 0.01 0.01
 
@free
     [,1] [,2]
[1,] TRUE TRUE
 
@lbound: No lower bounds assigned.
 
@ubound: No upper bounds assigned.

I also commented out some bits that weren't working - they were sort of post-processing things not necessary to fit the model and which would be more efficient to do with mxEval() calls after the model has been fitted.

AttachmentSize
koak.R 12.64 KB
koak's picture
Offline
Joined: 05/10/2012
Thank you and some further questions

Thank you so much for this, Mike

I have made a couple of further changes which I realized were needed, and still have some further questions which I would appreciate any assistance with.

1. In the standard Common Pathways model the variance for the latent variable is constrained to be 1. Where should this constraint be applied when including the age moderation? At the moment I have it placed at the latent and moderated latent path coefficients but I am not sure if this is correct. Also then when multiplying by age or age group, this means the total variance does not =1

2. Currently my f values (the path coefficients from the latent to each of the specific variables ) is negative – this is causing a bit of havoc when calculating the total variance- any ideas on what I am doing wrong???

3. Should the f value be age moderated? If so, how would it be best to do this?

4. Currently I am unable to calculate the means for each age group as they are non-conformable arrays – I just can’t work out how to get them to be conformable – any ideas? (currently hashed out – MI)

5. My specific variance for each age group is also coming out with non-conformable arrays. I have tried changing the matrix size of “Unit” but this is not fixing the problem – again any ideas?

6. I would be really grateful if the equations for the following could be checked:
a. Total estimate by age (stestbyAgetotal)
b. Estimates for the latent variable by age (stestByAgeCommon)
c. Estimates for the each specific variable by age (eg I currently have AsI/VsI – is VsI the correct denominator?) (stestbyAgeSpecific)
d. Estimates from the latent variable to each of the specific variables including the calculation of f1 (stestByAgefromcommontospecific)

Thank you so much in advance
With much gratitude

Karen

AttachmentSize
Common Pathways - with age moderator_11Aug2013.R 12.62 KB
DASS_Data_dummy.csv 19.71 KB
neale's picture
Offline
Joined: 07/31/2009
Hard to help

... without C:/Users/karen.oakley/Dropbox/Analyses/DASS to test. Could you send it (or some dummy version thereof?