You are here

Can mxSE() calculate the standard error for a formula containing definition variables?

3 posts / 0 new
Last post
Veronica_echo's picture
Offline
Joined: 02/23/2018 - 01:57
Can mxSE() calculate the standard error for a formula containing definition variables?

Hi everyone,

Hope you are enjoying the winter break!

I am trying to estimate a derived parameter using mxEval() and mxSE(). The function mxEval() works well, but mxSE() reports a warning message as below and produces NA for the standard error.

"1: In mxSE(paste0("instant_rate_est", j), model = model, ... :
Some diagonal elements of the repeated-sampling covariance matrix of the point estimates are less than zero or NA.
I know, right? Set details=TRUE and check the 'Cov' element of this object. "

I installed the last version of OpenMx and here are the lines I am using:
Loads1 <- mxMatrix("Full", 1, 1, free = F, labels = paste0(data.T1), name = "t1")
Loads2 <- mxMatrix("Full", 1, 1, free = F, labels = paste0(data.T2), name = "t2")
midT1 <- mxAlgebra(t2 - t1, name = mid_t1)
slp_est1 <- mxAlgebraFromString(paste0("mueta2 * mid_t1"), name = paste0("instant_rate_est", 1))

In the formula, "mueta2" is a free parameter, so my guess is it was caused by the definition variables "data.T1" and "data.T2", but I am not sure. Any advice on how to avoid such warning messages and have SE values?

Thank you so much for your attention.

mhunter's picture
Offline
Joined: 07/31/2009 - 15:26
Should work in theory

Hi Veronica,

mxSE() should, in theory, work for models with definition variables. Did you do what the warning/error message suggested?

mxSE() starts from the standard errors of the model and then makes a linear approximation to the standard errors of arbitrary algebraic functions of those free parameters. The warning/error message is saying the at least one of original standard errors is zero or NA. Look at the output from mxSE(..., details=TRUE); in particular at the Cov part. Is one of the diagonal elements zero or NA? Alternatively, you could look at the summary() of the model and see if one of the parameters has an NA or zero standard error.

If the model does not have all of its standard errors then you can't really use mxSE. The NA just propagates through and makes everything it touches an NA.

Mike

AdminNeale's picture
Offline
Joined: 03/01/2013 - 14:09
Check quotes syntax

It's not easy to tell from the code snippet that you provided, but
midT1 <- mxAlgebra(t2 - t1, name = mid_t1)
should perhaps be
midT1 <- mxAlgebra(t2 - t1, name = "mid_t1")
unless mid_T1 is previously defined as a character constant.

Now, mxSE accepts a lot of possible objects: "x can be the name of an algebra, a bracket address, named entity or arbitrary expression." I wonder if you have a bit of a hybrid here, partly parameter and partly reference to another kind of object. To be on the safe side, I would use an mxAlgebra to compute the quantity you desire, and then simply mxSE(myMxAlgebra'sName).