Imagine you have a simple one-factor measurement error model - just one latent variable u with say 5 indicators. How would you make the residual variance of the indicators a function of u? For example, a linear function of u. Is this possible using OpenMx?

There are a couple of ways you could do something like this.

First, in the item factor analysis utilities (AKA item response theory,

`mxExpectationBA81()`

) you can have access to the latent variable estimates via a dynamic data interface. Some further details are in the appendices of Pritikin et al. (2014, DOI: 10.1177/0013164414554615).Second, you could write an

`mxAlgebra()`

that computes the factor scores, and then make the residual variance a function of those factor scores. This would not be terribly hard for all-continuous data. However, it would be difficult for ordered categorical data, and you could run into a recursion problem. The factor scores are a function of the residual variances, which you want to be a function of the factor scores. You'd probably have to write a compute plan (e.g., with`mxCompute()`

) to make sure things happen in the right order. At some point, you're also just writing your own EM algorithm (see`mxComputeEM()`

).I am a little curious about why you'd want to do this. The only use-case I can think of is a way to handle binary observed variables: the variance of a binary variable is p*(1-p) where p is the probability of a correct response, and in this case would be the factor score. The built-in utilities for item response theory, ordered categorical data thresholds, and weighted least squares would all be better though.

Hope that gets you started!

You will probably find what you need on the wiki.