Sat, 04/20/2013 - 10:26

Anyone know of a function to take a RAM model and an entry and exit point and output a total effect?

i.e., given A model m1 = A<->B; B->C; A->C

`pathEffect(m1, from="A", to= "C")`

Would output the product of paths `(a-c) + (a-b * b-c)`

If not, it might be a handy addition, and encourage people to report the expected effects in their model rather than just fit. i.e., "All things being equal, this model of our theory suggests that an increase of 50 kg/day of saccharin would decrease lifespan by 1-second, via the following pathways..."

Let me propose a slightly more general formulation of this idea that should still address your concern.

Suppose we wrote a helper function that would allow you to specify a value for a subset of variables in the model and find the conditional mean implied by the model for the rest of the variables.

So what you'd then actually be saying is that a person exactly at the mean saccharine intake would have a predicted lifespan of X seconds, someone with mean+50 mg intake would have a predicted lifespan of X-1 seconds.

So consider:

A similar function could be constructed for the conditional covariance matrix, which might be useful for multiple imputation and maybe some simulation studies. If we work from the covariance matrices, this could work for normal but non-path models as well (although you might not be able to predict latent variables in that case).

Would that do what you want it to do?

So the goal would be that from a crazy image like this, we could readout: "Achieving a one SD increase in Reading is implied to raise income for a person on average earnings by £5000/yr"

so I'd write a wrapper that did this:

Okay.

This is a hacked-together version (the actual meat of it is like three lines, but I do a lot of error-checking for it) that computes the conditional mean and (if requested) conditional covariance for each row passed to the data. It's been quickly tested, and seems to be correct in the few cases I've run for it.

For the conditional mean, that means you'll get back all the data are given with anything missing filled in.

If you give it a RAM model, it will also estimate regression-based scores for each of the latent variables, and tack those columns onto the model. It actually differs from Mike Hunter's method listed in a previous thread (see http://openmx.psyc.virginia.edu/thread/1294#comment-3791 ) only in that it also takes means into account, and imputes any missing value, rather than just the latents.

It doesn't handle definition variables yet--if you want that feature, let me know and I'll get to it when I have a chance.

For your problem, what you probably want is a wrapper like:

For anyone else needing this function, it's good for quick computation of factor scores or prediction of missing values. It'll also compute conditional covariance matrices if you want to do multiple imputation or anything like that.

Thanks tim! - perfect for what we wanted, but with a lot more power!

I added it to the umx library...

https://github.com/tbates/umx

Definition variables would be useful – and I guess those are just the cases where it's harder to manually derive predicted effects, esp with covariance between the definition vars and some of the outcomes.

I think this is a real selling point for OpenMx. Couple of examples using this for imputation or factor scores would be great. Sounds like with imputation, this would give RAM models a similar functionality to Mplus's Bayesian posterior approach. Another selling point.

A distinct function that would also be useful would be a function to take a data-less model (i.e., just a stack of mxPaths, as one might see in a paper, for instance) and both work out the implied relations via path tracing, but also return an equivalent dataset.

One could then use this to generate test case datasets.

Anyhow, just to say: great stuff! And thank you

t

Thanks tim! - perfect for what we wanted, but with a lot more power!

I added it to the umx library...

https://github.com/tbates/umx

Definition variables would be useful – and I guess those are just the cases where it's harder to manually derive predicted effects, esp with covariance between the definition vars and some of the outcomes.

I think this is a real selling point for OpenMx. Couple of examples using this for imputation or factor scores would be great. Sounds like with imputation, this would give RAM models a similar functionality to Mplus's Bayesian posterior approach. Another selling point.

A distinct function that would also be useful would be a function to take a data-less model (i.e., just a stack of mxPaths, as one might see in a paper, for instance) and both work out the implied relations via path tracing, but also return an equivalent dataset.

One could then use this to generate test case datasets.

Anyhow, just to say: great stuff! And thank you

t

Interesting. I can' think of anything offhand, but I like the idea! You could even go one step further and compute confidence intervals for this total effect (using a Monte Carlo confidence interval). The monteCarloMed function in semTools implements this currently, but it forces you to explicitly specify the paths of interest.

Alex