Fit Functions
https://openmx.ssri.psu.edu/taxonomy/term/25/0
enmxCompare function
https://openmx.ssri.psu.edu/node/4311
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>Hi,</p>
<p>I tried to compare two CFA models using the mxCompare function. Unfortunately, I received the message:</p>
<p>Error in refSummary$modelName : $ operator is invalid for atomic vectors</p>
<p>At first I thought I had some code error but I run an example located in the help for mxCompare function, that is:</p>
<p>data(demoOneFactor)<br />
manifests <- names(demoOneFactor)<br />
latents <- c("G1")<br />
model1 <- mxModel(model="One Factor", type="RAM",<br />
manifestVars = manifests,<br />
latentVars = latents,<br />
mxPath(from = latents, to=manifests),<br />
mxPath(from = manifests, arrows = 2),<br />
mxPath(from = latents, arrows = 2, free = FALSE, values = 1.0),<br />
mxData(cov(demoOneFactor), type = "cov", numObs = 500)<br />
)</p>
<p>fit1 <- mxRun(model1)</p>
<p>latents <- c("G1", "G2")<br />
model2 <- mxModel(model="Two Factor", type="RAM",<br />
manifestVars = manifests,<br />
latentVars = latents,<br />
mxPath(from = latents[1], to=manifests[1:3]),<br />
mxPath(from = latents[2], to=manifests[4:5]),<br />
mxPath(from = manifests, arrows = 2),<br />
mxPath(from = latents, arrows = 2, free = FALSE, values = 1.0),<br />
mxData(cov(demoOneFactor), type = "cov", numObs=500)<br />
)<br />
fit2 <- mxRun(model2)</p>
<p>mxCompare(fit1, fit2)</p>
<p>In this situation, I received the same error message.<br />
Error in refSummary$modelName : $ operator is invalid for atomic vectors<br />
What's wrong?</p>
<p>best regards,<br />
Krzysztof</p>
</div>
</div></div></div>Fri, 10 Nov 2017 11:32:17 +0000krzysiek4311 at https://openmx.ssri.psu.eduRMSEA in multiple-group analysis
https://openmx.ssri.psu.edu/thread/4169
<div class="field field-name-upload field-type-file field-label-hidden"><div class="field-items"><div class="field-item even"><table class="sticky-enabled">
<thead><tr><th>Attachment</th><th>Size</th> </tr></thead>
<tbody>
<tr class="odd"><td><span class="file"><img class="file-icon" alt="PDF icon" title="application/pdf" src="/modules/file/icons/application-pdf.png" /> <a href="https://openmx.ssri.psu.edu/sites/default/files/RMSEA.pdf" type="application/pdf; length=204647" title="RMSEA.pdf">RMSEA.pdf</a></span></td><td>199.85 KB</td> </tr>
</tbody>
</table>
</div></div></div><div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>Hi,</p>
<p>It seems that OpenMx uses the same formula of RMSEA for both single- and multiple-group analyses. According to Steiger (1998), the RMSEA should be adjusted by a factor of sqrt(K) where K is the no. of groups.</p>
<p>The attached PDF includes the test suggested by Steiger (1998, p. 417):<br />
1. Construct two identical arbitrary data sets (random numbers will suffice).<br />
2. Test one sample with a simple model, for example, a single factor model, and record the RMSEA value.<br />
3. Construct a two-sample model, where each group is tested with the same model used in Step 2, but with no parameters constrained to be equal across populations.<br />
4. The two-sample RMSEA reported by the software should of course be identical to the one-sample value, because two (in theory) completely independent samples have yielded identical fit to two independent versions of the same model. If it is not, check whether multiplying the value by sqrt(2) yields an identical value. If it does, then it is highly likely that the software is generating incorrect values by using the single-sample formula inappropriately.<br />
5. If the test in Step 4 confirms that an error is present, multiply all point estimates and interval estimates of the RMSEA by sqrt(2) to obtain correct values.</p>
<p>Steiger, J. H. (1998). A note on multiple sample extensions of the RMSEA fit index. Structural Equation Modeling: A Multidisciplinary Journal, 5(4), 411–419. http://doi.org/10.1080/10705519809540115</p>
<p>Best,<br />
Mike</p>
</div>
</div></div></div>Thu, 04 Aug 2016 03:10:55 +0000Mike Cheung4169 at https://openmx.ssri.psu.eduScaled chi-square
https://openmx.ssri.psu.edu/thread/4091
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>Hi all,</p>
<p>Wondering if Satorra / Satorra-Bentler scaled chi-square is available in OpenMx or not? i.e., ML with robust corrections to the test statistics and standard errors in the case of non-normal data. Ideally, I'd like to see if the difference test for model comparisons is available. Only thing I found in the forums was this post from quite a while ago: http://openmx.psyc.virginia.edu/thread/530</p>
<p>Many thanks!<br />
Carl</p>
</div>
</div></div></div>Tue, 19 Jan 2016 03:03:38 +0000falkcarl4091 at https://openmx.ssri.psu.eduEquating means and variances across MZs, DZs and Siblings
https://openmx.ssri.psu.edu/thread/4059
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>Hi everyone!<br />
I have a question about equating means and variances. I am working with a small twin data set (about 400 MZ, 700 DZ and 400 siblings - individuals not twin pairs). I am trying to run some simple univariate analyses for a couple of different variables, but for some of the variables, I can see in the assumption checking that the fit gets worse if I try to equate the variances for MZs, DZs and siblings (means are ok to eqaute). Even if I leave out (or not equate) the siblings and just try to eqaute the variance for the MZs and the DZs, the fit still gets worse. What can I do? Thank you very much for your help!</p>
</div>
</div></div></div>Sun, 11 Oct 2015 11:22:48 +0000Harry19804059 at https://openmx.ssri.psu.eduCIs when RMSEA = 0
https://openmx.ssri.psu.edu/thread/3947
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>Hi all,</p>
<p>I noticed that when RMSEA = 0, the CIs come out as NA. Why is that? Is it a bug? Or are CIs theoretically undefined when RMSEA=0?</p>
</div>
</div></div></div>Fri, 30 Jan 2015 18:25:35 +0000fife3947 at https://openmx.ssri.psu.eduCustom R fit function with algebras - possible?
https://openmx.ssri.psu.edu/thread/2803
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>My attempts to specify a custom R objective function with mxFitFunctionR (using latest build from the git mirror) are not working, because it seems as though the model that gets passed into the fitfunction is with all the algebras unevaluated. Am I doing something wrong, or thinking about this completely wrong? Is there a way I can achieve similar with the algebras evaluated? Below is a minimal example modified from the mxFitFunctionR example. Thanks!</p>
<p>A <- mxMatrix(nrow = 4, ncol = 1, values = c(6:9), free = TRUE, name = 'A')<br />
B <- mxMatrix(nrow = 4, ncol = 1, values = c(10:13), free = FALSE, labels=paste0("testalg[",1:4,",1]"),name = 'B')<br />
testalg<-mxAlgebra(A%x%2,name="testalg")<br />
squared <- function(x) { x ^ 2 }</p>
<h1>Define the objective function in R</h1>
<p>objFunction <- function(model, state) {</p>
<h1>browser()</h1>
<p>values <- model[['B']]@values<br />
print("i")<br />
return(squared(values[1,1] - 4) + squared(values[2,1] + 3)+<br />
squared(values[3,1] - 30)+squared(values[4,1] - 2))<br />
}</p>
<h1>Define the expectation function</h1>
<p>fitFunction <- mxFitFunctionR(objFunction)</p>
<h1>Define the model</h1>
<p>tmpModel <- mxModel('exampleModel', A, B,testalg, fitFunction)</p>
<h1>Fit the model and print a summary</h1>
<p>tmpModelOut <- mxRun(tmpModel)<br />
summary(tmpModelOut)</p>
</div>
</div></div></div>Sat, 05 Apr 2014 07:41:55 +0000CharlesD2803 at https://openmx.ssri.psu.edumodel fit for generalized sem model in R?
https://openmx.ssri.psu.edu/thread/2681
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>Hi All,</p>
<p>Can R perform sem models (with generalized outcomes; mine are binary) and give me some kind of model fit, such as something analogous to the RMSEA or CFI that you'd get in sem with continuous outcomes?</p>
<p>I have four waves of data and I'm examining employment status and rearrest as endogenous outcome variables. I have built and run a generalized structural equation model (-gsem-) in stata. All is well with the model, except I can't evaluate the model as a whole. Of course there are smaller tests that compare models such as the AIC/BIC, likelihood ratio tests, Wald, but these only compare models as opposed to evaluating the fit.</p>
<p>So my questions are: (1) does R do gsem (non-continuous outcomes) and have a way of evaluating the overall model? (2) if it does not have a way of evaluating the model overall, what should I present in a report along with the obvious findings? and (3) anyone familiar with any papers that have used sem with generalized outcomes? I've searched and can't find any published or unpublished. I imagine looking at one and seeing what they report would be very helpful.</p>
<p>Thank very much.</p>
<p>Nate</p>
</div>
</div></div></div>Tue, 18 Mar 2014 22:57:18 +0000Anonymous2681 at https://openmx.ssri.psu.eduP-values for coefficients
https://openmx.ssri.psu.edu/thread/2403
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>Hello,</p>
<p>I have estimated my SEM model in OpenMx. For two days I was looking for answer but I haven't solved it.<br />
How can I obtain p-values for coefficients to check significance of my variables?</p>
<p>Unfortunately, I can't attach my data due to confidentiality agreement.</p>
<p>Thank you,</p>
</div>
</div></div></div>Mon, 28 Oct 2013 17:57:45 +0000bean112403 at https://openmx.ssri.psu.eduFit Indices in OpenMx path modeling
https://openmx.ssri.psu.edu/thread/2204
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>Hello,</p>
<p>I am using OpenMx for latent variable path modeling. I have faced two problems in the results of the summary() function, about which any help would be much appreciated:</p>
<p>1- When I use the "raw" data type in my mxData() function, some of the resulted fit indices (i.e., RMSEA, CFI, TLI, and Chi-square) returns "NA" as the output! However, when I change my data type to "cov" in the mxData() function, the problem is resolved and it gives me some non-"NA" values for those fit indices. I have tested this on the examples in the "OpenMxUserGuide" and I have seen the same problem there too. Is there any reason for this? or is it a bug in the OpenMx?</p>
<p>2- The summary() function reports very limited number of fit indices (i.e., chi-square, AIC, BIC, CFI, TLI, and RMSEA). However, many other common fit indices that reviewers usually ask for them are missing from the output of summary() (e.g., GFI, AGFI, SRMR, NFI, NNFI, 95% CI for RMSEA). I was wondering is there is any function/solution for calculating these missing fit indices in OpenMx?</p>
<p>Thank you,</p>
</div>
</div></div></div>Wed, 10 Jul 2013 22:34:41 +0000HAMED2204 at https://openmx.ssri.psu.eduusing mxRun (unsafe=TRUE) to skip error and continue loop?
https://openmx.ssri.psu.edu/thread/1989
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>Hi,</p>
<p>I'm running a simulation in which a model will be fit to the simulated data 1000 times by running a loop.</p>
<p>However, some simulated data will make the model return error, like below:<br />
Error: The job for model 'myModel' exited abnormally with the error message: Objective function returned a value of NaN at iteration 52.23.</p>
<p>May I use the option unsafe=TRUE in mxRun to skip error and continue the loop?</p>
<p>Thank you.</p>
<p>Best,<br />
Jean</p>
</div>
</div></div></div>Thu, 07 Mar 2013 21:36:29 +0000Jean1989 at https://openmx.ssri.psu.educurious lack of warning/error
https://openmx.ssri.psu.edu/thread/1949
<div class="field field-name-upload field-type-file field-label-hidden"><div class="field-items"><div class="field-item even"><table class="sticky-enabled">
<thead><tr><th>Attachment</th><th>Size</th> </tr></thead>
<tbody>
<tr class="odd"><td><span class="file"><img class="file-icon" alt="Binary Data" title="application/octet-stream" src="/modules/file/icons/application-octet-stream.png" /> <a href="https://openmx.ssri.psu.edu/sites/default/files/curiousProblem.R" type="application/octet-stream; length=2039" title="curiousProblem.R">curiousProblem.R</a></span></td><td>1.99 KB</td> </tr>
<tr class="even"><td><span class="file"><img class="file-icon" alt="File" title="text/csv" src="/modules/file/icons/text-x-generic.png" /> <a href="https://openmx.ssri.psu.edu/sites/default/files/dz.csv" type="text/csv; length=1615" title="dz.csv">dz.csv</a></span></td><td>1.58 KB</td> </tr>
</tbody>
</table>
</div></div></div><div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>In fitting a bivariate threshold model using a definition variable, OpenMx converged but the final result gave the following predicted covariance matrix<br />
InitT1 InitT2<br />
InitT1 1.00000 1.48088<br />
InitT2 1.48088 1.00000</p>
<p>Obviously not positive definite. Yet I did not get any warnings or errors.</p>
<p>Script and data attached.</p>
<p>Greg</p>
</div>
</div></div></div>Sun, 24 Feb 2013 19:14:00 +0000carey1949 at https://openmx.ssri.psu.eduModel to base comparisons on for chi-square goodness-of-fit?
https://openmx.ssri.psu.edu/thread/1823
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>I fitting twins data and comparing an ACE model (say) to the fully saturated model, using the chi-square from this as a measure of goodness-of-fit.</p>
<p>I have ten parameters in the fully saturated model (2 x 3 covariance parameters and 2 x 2 mean parameters) and four in the ACE model (a,c & e plus overall mean), so am comparing to a chi(6).</p>
<p>I am worried that in comparing this models as a goodness-of-fit test I am to some extent testing whether an overall mean should be fitted (as distinct from MZ mean 1, MZ mean 2, DZ mean 1, DZ mean 2) rather than just whether the ACE model is a good fit.</p>
<p>Would it be better to test whether the means can be equated and, if so, equate them and compare the difference in deviance between a fully-saturated-apart-from-means model with seven parameters and the four-parameter ACE model to a chi(3)?</p>
<p>Thankyou</p>
<p>Karin</p>
</div>
</div></div></div>Thu, 03 Jan 2013 14:34:01 +0000Karin1823 at https://openmx.ssri.psu.eduInterpretation of chi-square goodness-of-fit
https://openmx.ssri.psu.edu/thread/1779
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>I am fitting ACE and ADE families of models and comparing them to the fully saturated model. I am getting results like this:</p>
<p>observed statistics: 2965<br />
estimated parameters: 4<br />
degrees of freedom: 2961<br />
-2 log likelihood: 848.4525<br />
saturated -2 log likelihood: 844.858<br />
number of observations: 2266<br />
chi-square: 3.594549<br />
p: 1</p>
<p>I am a bit confused by the interpretation of the chi-squared statistic and its degrees of freedom. Before, I have seen output from classic Mx where the df for the chi-square statistic would be three for an ACE model, because it had six observed statistics (i.e. four variances and two covariances from the MZ and DZ covariance matrices) and three estimated parameters (not estimating means).</p>
<p>Here, the df are given as 2961 and all of the p-values for the different models round to 1, because of the very high df. This makes the chi-squared test virtually useless for assessing model fit. Am I missing something here? Is there anything else I could do?</p>
<p>Thankyou</p>
<p>Karin</p>
</div>
</div></div></div>Fri, 07 Dec 2012 10:47:02 +0000Karin1779 at https://openmx.ssri.psu.eduBest fit indices
https://openmx.ssri.psu.edu/thread/1761
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>Hi!</p>
<p>I am in a learning phase for SEM and was wondering which are the best fit statistics to consider while judging a model fit. I know that SEM programs produce a variety of model fit indices and wanted to understand which ones deserve more weightage. I would appreciate some thoughts on this topic.</p>
<p>Thanks!</p>
</div>
</div></div></div>Sat, 01 Dec 2012 14:13:51 +0000LearnSEM81761 at https://openmx.ssri.psu.educomparing -2LL for classic and Open Mx
https://openmx.ssri.psu.edu/thread/1456
<div class="field field-name-taxonomy-forums field-type-taxonomy-term-reference field-label-above"><div class="field-label">Forums: </div><div class="field-items"><div class="field-item even"><a href="/forums/opensem-forums/fit-functions">Fit Functions</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><div class="tex2jax">
<p>Hi,</p>
<p>I have been comparing simple models between Mx and OpenMx and I get the exact same results using the same data for an univariate ACE model but as soon as I add a definition variable, path coefficients and fit indices start to differ considerably. Can someone please tell me how or how to find out how the calculation of likelihood may or may not differ between the two programs?</p>
<p>I thought this may be partly due to differences in dealing with unmet assumptions, or calculation of definition variables? Or a model misspecification?</p>
<p>Jane</p>
</div>
</div></div></div>Wed, 18 Jul 2012 08:28:14 +0000ebejer1456 at https://openmx.ssri.psu.edu