trivariate model with C for phenotype2 = 0

10 replies [Last post]
izza's picture
Offline
Joined: 08/12/2014

Hi,
I am conducting a trivariate twin analysis and after running ACE model my estimates of C for males are significant for phenotypes 1 and 3 but not significant for phenotype 2. AE model results in significant worsening of the goodness of fit.
I have run ACE model with c21, c22 and c32 fixed to 0 using the attached script.
Is that correct way of doing it or is there another way?
Any comments will be appreciated
Many thanks!

AttachmentSize
Ace.R13.87 KB
RobK's picture
Offline
Joined: 04/19/2011
I assume you're trying to fit

I assume you're trying to fit a model with the influence of C on phenotype #2 set to zero, correct? Here's what I get when I inspect your mxMatrix pathCm:

> pathCm
LowerMatrix 'cm' 
 
$labels
     [,1]   [,2]   [,3]  
[1,] "c11m" NA     NA    
[2,] "c21m" "c31m" NA    
[3,] "c22m" "c32m" "c33m"
 
$values
     [,1] [,2] [,3]
[1,]  1.0  0.0    0
[2,]  0.8  0.8    0
[3,]  1.0  0.8    1
 
$free
     [,1]  [,2]  [,3]
[1,] TRUE FALSE FALSE
[2,] TRUE  TRUE FALSE
[3,] TRUE  TRUE  TRUE
 
$lbound: No lower bounds assigned.
 
$ubound: No upper bounds assigned.

From the way you have the matrix labeled, you would want to set c21 and c31 to zero, since those would be the two paths that go from a latent C variable to phenotype #2 in the Cholesky factorization. More than likely, you wanted to define your path matrices with argument byrow=TRUE, for example,

pathCm <- mxMatrix(name = "cm", type = "Lower", nrow = 3, ncol = 3, free = TRUE, values = c(1, .8, 1, .8, .8, 1),
labels = c("c11m","c21m","c22m","c31m","c32m","c33m"),byrow=TRUE)

Then, the labeling and start values look a lot more sensible:
> pathCm
LowerMatrix 'cm' 
 
$labels
     [,1]   [,2]   [,3]  
[1,] "c11m" NA     NA    
[2,] "c21m" "c22m" NA    
[3,] "c31m" "c32m" "c33m"
 
$values
     [,1] [,2] [,3]
[1,]  1.0  0.0    0
[2,]  0.8  1.0    0
[3,]  0.8  0.8    1
 
$free
     [,1]  [,2]  [,3]
[1,] TRUE FALSE FALSE
[2,] TRUE  TRUE FALSE
[3,] TRUE  TRUE  TRUE
 
$lbound: No lower bounds assigned.
 
$ubound: No upper bounds assigned.

With byrow=TRUE, you would instead fix c21 and c22 to zero.

izza's picture
Offline
Joined: 08/12/2014
influence of C on phenotype #2 set to zero

Yes that is correct. They look more sensible, thank you!
I've made a mistake there because I was trying to free the significant parameters but not those set to zero, therefore:

CholAceModel <- omxSetParameters(CholAceModel, labels=c("c21m","c22m","c32m"), free=F, values = c( 0, 0, 0) )
CholAceModel <- omxSetParameters(CholAceModel, labels=c("c11m","c31m","c33m"), free=T, values =c(1, .8, 1 ))

Can they stay free when you fix them to zero?

neale's picture
Offline
Joined: 07/31/2009
Subtle identification issue

I think in this case you need to fix 3,2 to zero. If the second Cholesky factor does not affect the second phenotype (2,2 is fixed) then Cholesky factors 2 and 3 only do one thing, affect phenotype 3. So the model would be under identified unless you fix 3,2 as well. What you have:

CholAceModel <- omxSetParameters(CholAceModel, labels=c("c21m","c22m","c32m"), free=F, values = c( 0, 0, 0) )
CholAceModel <- omxSetParameters(CholAceModel, labels=c("c11m","c31m","c33m"), free=T, values = c(1, .8, 1 ))

is correct. I'm not sure if this is what you went with in the end.

RobK's picture
Offline
Joined: 04/19/2011
Oops. You're right.

Oops. You are correct that it's necessary to also fix 3,2 to zero for the sake of identification. My mistake.

izza's picture
Offline
Joined: 08/12/2014
path by path

I went with that first but Rob, in the comment above, pointed out that it gives me a wrong matrix.
Ended up specifying path by path:

CholAceModel <- omxSetParameters(CholAceModel, labels="c11m", free=T, values = 1)
CholAceModel <- omxSetParameters(CholAceModel, labels="c21m", free=F, values = 0)
CholAceModel <- omxSetParameters(CholAceModel, labels="c22m", free=F, values = 0)
CholAceModel <- omxSetParameters(CholAceModel, labels="c31m", free=T, values = .8)
CholAceModel <- omxSetParameters(CholAceModel, labels="c32m", free=F, values = 0)
CholAceModel <- omxSetParameters(CholAceModel, labels="c33m", free=T, values = 1)

which gives me the following:

@labels
[,1] [,2] [,3]
[1,] "c11m" NA NA
[2,] "c21m" "c22m" NA
[3,] "c31m" "c32m" "c33m"

@values
[,1] [,2] [,3]
[1,] 1.0 0 0
[2,] 0.0 0 0
[3,] 0.8 0 1

@free
[,1] [,2] [,3]
[1,] TRUE FALSE FALSE
[2,] TRUE TRUE FALSE
[3,] TRUE TRUE TRUE

@lbound: No lower bounds assigned.

@ubound: No upper bounds assigned.

The values for C estimates that I am getting now are not significant though, so not sure if that is correct?

Many thanks!

tbates's picture
Offline
Joined: 07/31/2009
which matrix? and umxLabel()

Your output is censored a little: you say
@free
T F F
T T F
T T T

but that doesn't show the matrix name. What do you see if you ask for:

yourModel$matrixName$free

???

Also ensure you are not getting errors in between the setparameter statements. really, a list of labels you want to fix should work fine, and most are in the state you want anyhow.

($ assumes you're using the 2.0 beta, if not replace $ with @ )

PS: umxLabel() is a massive help for stuff like this. It will label matrices of any type correctly (also labels all the paths of RAM models.

The labels are "rn_cn", i.e., for a matrix "A", cell [1,1] is labeled "A_r1c1"

This makes it fool-proof to get and set parameters by label, and removes dozens of error prone lines of code from scripts.

Also names RAM paths as "var_to_var" and "var_with_var", so "extraversion_to_depression" etc.

Given a matrix model, it will dig inside and label all your matrices in one hit.

grab it as

install.packages("devtools") # if you don't already have it
library(devtools)
install_github("tbates/umx")
library(umx)
 
?umxLabel gives some examples.

neale's picture
Offline
Joined: 07/31/2009
Free matrix looks odd

The labels & values look as I would expect. The free matrix does not. Elements 2,1 2,2 and 3,2 should be FALSE, should they not?

izza's picture
Offline
Joined: 08/12/2014
Yes they should be FALSE but

Yes they should be FALSE but for some reason they are still free.
Any suggestions how to change that?

RobK's picture
Offline
Joined: 04/19/2011
omxSetParameters()

What are you typing at the R prompt to see this?:

@labels
[,1] [,2] [,3]
[1,] "c11m" NA NA
[2,] "c21m" "c22m" NA
[3,] "c31m" "c32m" "c33m"
 
@values
[,1] [,2] [,3]
[1,] 1.0 0 0
[2,] 0.0 0 0
[3,] 0.8 0 1
 
@free
[,1] [,2] [,3]
[1,] TRUE FALSE FALSE
[2,] TRUE TRUE FALSE
[3,] TRUE TRUE TRUE
 
@lbound: No lower bounds assigned.
 
@ubound: No upper bounds assigned.

If you're inspecting pathCm, then the changes you made with omxSetParameters() won't be reflected there. That's because your omxSetParameters() statements act upon the parameters in CholAceModel, not on those in pathCm. To see the matrix of C paths for males in CholAceModel, you'd type something like CholAceModel$MZMmodel.cm. You can also try omxGetParameters(CholAceModel), which by default returns the values of free parameters only from the given MxModel.

izza's picture
Offline
Joined: 08/12/2014
Many thanks

I was indeed inspecting the wrong matrix.
Thank you for your comments!