mxEval

5 replies [Last post]
tbates's picture
Offline
Joined: 07/31/2009
tbates's picture
Offline
Joined: 07/31/2009
Should mxEval() pass through

Should mxEval() pass through the dimNames of algebra results?

if I
mxEval(expCovMZ, twinACEFit)

I get a matrix, but without names

They were set on the algebra
mxAlgebra(rbind (cbind(A+C+E , A+C),
cbind(A+C , A+C+E)), dimnames = list(selVars, selVars), name="expCovMZ"),

And are in the model Fit:

twinACEFit@algebras$expCovMZ
mxAlgebra 'expCovMZ'
@formula: rbind(cbind(A + C + E, A + C), cbind(A + C, A + C + E))
@result:
[,1] [,2] [,3] [,4]
[1,] 0.790535801 -0.004704324 0.617627914 -0.001694689
[2,] -0.004704324 0.004559813 -0.001694689 0.004015630
[3,] 0.617627914 -0.001694689 0.790535801 -0.004704324
[4,] -0.001694689 0.004015630 -0.004704324 0.004559813
dimnames:
[[1]]
[1] "bmi1" "ht1" "bmi2" "ht2"

[[2]]
[1] "bmi1" "ht1" "bmi2" "ht2"

Steve's picture
Offline
Joined: 07/30/2009
Nice catch. The dimnames

Nice catch. The dimnames printed with the output will be helpful.

tbates's picture
Offline
Joined: 07/31/2009
Tangentially, I remain

Tangentially, I remain confused about why the matrix examples print out no fit statistics... is that a bug, or on the to-do list, or left to the user to figure out?

reduction: run trunk/demo/UnivariateTwinAnalysis_MatrixRaw.R

> summary(twinAEFit)
  name    matrix row col parameter estimate error estimate
1 mean expMeanMZ   1   1         21.3929339       53.45028
2    a         X   1   1          0.7856859       71.82837
3    e         Z   1   1          0.4159882      110.59854
 
Observed statistics:  0 
Estimated parameters:  3 
Degrees of freedom:  -3 
AIC:  
BIC:  
adjusted BIC: 
RMSEA:  

Oh-yes, also, adjusted-BIC is not printed for a simple factor model.

require(OpenMx)
data(demoOneFactor)
manifests <- names(demoOneFactor)
latents <- c("G")
factorModel <- mxModel("One Factor", type="RAM",
+       manifestVars = manifests,
+       latentVars = latents,
+       mxPath(from=latents, to=manifests),
+       mxPath(from=manifests, arrows=2),
+       mxPath(from=latents, arrows=2,
+             free=F, values=1.0),
+       mxData(cov(demoOneFactor), type="cov",
+             numObs=500))
summary(mxRun(factorModel))
...
Observed statistics:  15 
Estimated parameters:  10 
Degrees of freedom:  5 
AIC:  -3658.281 
BIC:  -1839.677 
adjusted BIC: 
RMSEA:  0.03088043

tbates's picture
Offline
Joined: 07/31/2009
Significant Bug? Hi, I think

Significant Bug? Hi, I think the complete lack of fit statistics on these matrix models is a significant bug, no?

mspiegel's picture
Offline
Joined: 07/31/2009
Whoops, yes it seems

Whoops, yes it seems reasonable that the dimnames will appear on the result of an algebra. This was an oversight on my part. I'll add a ticket for this issue.