fit@output$confidenceIntervals doesn't give estimate, just lbound and ubound

7 replies [Last post]
tbates's picture
Offline
Joined: 07/31/2009

hi all,
If you do "summary(fit)$CI" you get the upper, lower, and estimate:
lbound estimate ubound
top.a_std[1,1] -0.68048731 -0.6216239 -0.5515234

but "fit@output$confidenceIntervals" gives just the upper and lower:
lbound ubound
top.a_std[1,1] -0.68048731 -0.5515234

Because summary takes ages to run on big models, it would be nice if "fit@output$confidenceIntervals" had the estimate in there as well: Also good for consistency.

Best, t

tbates's picture
Offline
Joined: 07/31/2009
help making a helper to do this

hi all,
So working backwards from the various things that a CI can be called (a label, a matrix address...) Labels are straight forward, but I could use a suggestion for getting the estimate for a cell, where the CI was pointed at a location rather than a label.

So.. how can I treat "top.a_std[1,1]" in such a way that I can look up its value i.e.

mxEval(top.a_std[1,1], fit)

tried this to no avail...
get("fit@submodels$top.a_std[1,1]")

tbates's picture
Offline
Joined: 07/31/2009
solved imxEvalByName("top.c[1,1]", fit11)

imxEvalByName("top.c[1,1]", fit11)

tbates's picture
Offline
Joined: 07/31/2009
vectorised versions of imxEvalByName

I'm using the following functions
hasSquareBrackets()
imxEvalByName()

Any interest in vectorised versions of these? Especially imxEvalByName(), which seems a great candidate for taking lists of names?

mspiegel's picture
Offline
Joined: 07/31/2009
Why not use lapply(c('foo',

Why not use lapply(c('foo', 'bar','baz'), imxEvalByName, model) ?

Ryne's picture
Offline
Joined: 07/31/2009
I'll bring it up at a future

I'll bring it up at a future dev team meeting. Seems reasonable at first glance, but also means that we're adding redundant info into the big and getting bigger output slot. In the mean time, you can sidestep summary and just grab fit@output$estimate when you access fit@output$confidenceIntervals.

tbrick's picture
Offline
Joined: 07/31/2009
I have to say, I don't think this is a good road to start down

I have to say, I don't think this is a good road to start down, and I think a helper function is the better solution here.

The @output slot is not really intended to be accessed directly by the user; its format is determined primarily by the way the C back-end returns data to R.

We do put some extra information in there for advanced users, but the primary way we expect users to access the output is through the fitted mxModel that's returned and the summary function. I don't think we really want to start down the road of formatting it for readability, partly because it's already large, but more because that's not its function. If we format one thing to be human readable, we have to worry about formatting the rest of it the same way, and that's why we have summary() in the first place.

I think if you want quick access to a formatted table made from info that's contained in the @output slot without using summary(), the way to do it is to write a helper function that pulls the parts you want out of @output and formats them pleasantly for display.

In this case, it's pretty easy--as Ryne says, it's really just a matter of getting the estimates and the CIs and tossing them together into a table.

mhunter's picture
Offline
Joined: 07/31/2009
I tend to agree with Tim

I tend to agree with Tim Brick here.

If running summary() on a model takes too long to run once, then a helper function to do only some of the things the summary() function does should solve the problem. If, however, you are repeatedly calling summary() on a model to inspect aspects of the model and you are frustrated that calling summary() on the model takes too long, then I would recommend running summary() once on the model and putting that into another object. For example

modsum <- summary(myModelFit)
modsum
modsum$CI

Then you don't have to re-run summary() on the model and re-calculate all the summary information to re-inspect the summary information. You just inspect the object that holds all this information without re-calculating it all over again.