saving confidence intervals to a separate file
Posted on
Gunnar
Joined: 02/21/2019
Forums
Hello, in asimulation loop I want o to save results for instance confidence intervals for each run in separate file. Hos to do this is rather easy in eg.g. lavaan buit I have trouibles as newbie to find out how to specify the matrix cells for the parameter values i want to save. An example from Jaks book on Meta SEM:
pathmodel= mxModel(title,obs,matrixB,matrixP,matrixI, Ind_pos,Ind_neg,conf,algebraS,exp,fit)
pathmodelOut = mxRun(pathmodel, intervals = TRUE)
pathmodel= mxModel(title,obs,matrixB,matrixP,matrixI, Ind_pos,Ind_neg,conf,algebraS,exp,fit)
pathmodelOut = mxRun(pathmodel, intervals = TRUE)
# retrieve the output
summary(pathmodelOut)
results in (among other output) this;
confidence intervals: lbound estimate ubound note b31 0.39939069 0.64232806 0.88527142 b32 -0.50352850 -0.30476191 -0.10599531 b43 0.12624700 0.29585799 0.46546898
How can I specify these estimates as e.g. matric cells and save in a separate file?
You can save the model
pathmodelSumm <- summary(pathmodelOut)
, and extract the cells you want from the element of `pathmodelSumm` that stores the confidence-interval table.
Log in or register to post comments
In reply to You can save the model by AdminRobK
saving confidence intervals to a separate file
Summary of Path model
free parameters:
name matrix row col Estimate Std.Error A
1 b31 B 3 1 0.6423280 0.12280667
2 b32 B 3 2 -0.3047620 0.10047876
3 b43 B 4 3 0.2958579 0.08574016
4 Path model.P[1,1] P 1 1 0.8022115 0.11124744
5 Path model.P[1,2] P 1 2 -0.3565385 0.10230405
6 Path model.P[2,2] P 2 2 1.1983654 0.16618284
7 Path model.P[3,3] P 3 3 1.0918754 0.15141626
8 Path model.P[4,4] P 4 4 1.2796472 0.17745574
confidence intervals:
lbound estimate ubound note
b31 0.39887350 0.64232796 0.88578253
b32 -0.50387525 -0.30476198 -0.10564865
b43 0.12599465 0.29585794 0.46572124
Path model.P[1,1] 0.61833179 0.80221150 1.06727282
Path model.P[1,2] -0.58940484 -0.35653849 -0.17279121
Path model.P[2,2] 0.92353384 1.19836537 1.59494917
Path model.P[3,3] 0.84150214 1.09187541 1.45306408
Path model.P[4,4] 0.98614251 1.27964720 1.70326762
and I would like to specify, similar to if it was a matrix with values for rows and columns, or sometyhing like that, so I could extraxt just the lines with the confidence interval for b31, b32 and b43. But I do not see how to get information on how to define these elements, or "cells", or "rows" ( if you could treat it as a matrix). Maybe this is elementary, I apologize for me being in the beginning of the learning curve,
Log in or register to post comments
In reply to saving confidence intervals to a separate file by Gunnar
model introspection
Does this help?
Log in or register to post comments
saving confidence intervals to a separate file - found out how t
1) rename the summary tp spomething simpler; summodel
2) use names(summodel) to see the objects
3) explore which object has the confidence intervals: it is $CI
4) extract the part I want to use by writing
summodel$CI[c(1:3),c(1:3)]
Thanks for the advice and sorry to have taken your time!
Log in or register to post comments