Sun, 11/22/2009 - 20:29

hi,

I think this model should run successfully.

# Fig2.12 from John Loehlin edition 4, p85

require(OpenMx)

# Get the data

names = c("A","C","D")

data=matrix(c(1, .3, .4, .3, 1, .35, .4, .35, 1), nrow=3, byrow=TRUE, dimnames=list(r=names, c=names))

# Get the manifest variable names from the data

manifests = row.names(data)

# Latents (in this case just B)

latents = c("B")

# Describe the model

model = mxModel("prob2-12", type="RAM",

manifestVars = manifests,

latentVars = latents,

mxPath(from = "A", to="B"), # factor loadings

mxPath(from = "B", to= c("C", "D") ), # factor loadings

mxPath(from = c("B", "C", "D"), arrows=2), # residual variances

mxData(data, type="cov",numObs=100)

)

# Run the model and save the fit

fit = mxRun(model)

# Running prob2-12

# Error: The job for model 'prob2-12' exited abnormally with the error message: Backing out of parameter space region where expected covariance is non-positive-definite.

# Output the summary

summary(fit)

# expecting a->b = .5855; b->c = .5223; b->d = .6831

No variance of variable "A" has been specified. Despite the absence of starting values for the parameters, the following modified statement is sufficient to let it run:

mxPath(from = c("A","B", "C", "D"), arrows=2), # residual variances

but the estimates are off per your expectations:

name matrix row col Estimate Std.Error A B A 0.6796807 0.19038822 A C B 0.4413833 0.13523748 A D B 0.5885115 0.17372490 S A A 0.9999998 0.10054987 S C C 0.7374998 0.09533513 S D D 0.5333327 0.12144355 S B B 0.8854357 0.37899839

1

2

3

4

5

6

7

I don't have Loehlin (er, well, nor his book) in front of me, but perhaps specifications are off?

Thanks Mike!

Diagram is drawn in with the residual variances, but without the variance of A: correct figure now provided :-)

We could helpfully throw an error when there are variables in the model which are not constants but which have no variance.

Also, you can leave variables in the data, but not model any relationships for them. Of course such orphans are legal, but when accompanied by a code green or worse, it might be handy to say "I see varX in the data but not the model"

e.g. where a warning would be helpful

RAM type models will use default starting values if none are given for free parameters. They can be changed by modifying options('mxRAMDefaultDouble') and options('mxRAMDefaultSingle'), which are both set to 1 by default.