Fit Functions
http://openmx.psyc.virginia.edu/taxonomy/term/25/0
enCustom R fit function with algebras - possible?
http://openmx.psyc.virginia.edu/thread/2803
<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>
<p># Define the objective function in R</p>
<p>objFunction <- function(model, state) {<br />
# browser()<br />
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>
<p># Define the expectation function</p>
<p>fitFunction <- mxFitFunctionR(objFunction)</p>
<p># Define the model</p>
<p>tmpModel <- mxModel('exampleModel', A, B,testalg, fitFunction)</p>
<p># Fit the model and print a summary</p>
<p>tmpModelOut <- mxRun(tmpModel)<br />
summary(tmpModelOut)</p>
http://openmx.psyc.virginia.edu/thread/2803#commentsFit FunctionsSat, 05 Apr 2014 07:41:55 +0000CharlesD2803 at http://openmx.psyc.virginia.edumodel fit for generalized sem model in R?
http://openmx.psyc.virginia.edu/thread/2681
<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>
http://openmx.psyc.virginia.edu/thread/2681#commentsFit FunctionsTue, 18 Mar 2014 22:57:18 +00002681 at http://openmx.psyc.virginia.eduP-values for coefficients
http://openmx.psyc.virginia.edu/thread/2403
<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>
http://openmx.psyc.virginia.edu/thread/2403#commentsFit FunctionsMon, 28 Oct 2013 17:57:45 +0000bean112403 at http://openmx.psyc.virginia.eduFit Indices in OpenMx path modeling
http://openmx.psyc.virginia.edu/thread/2204
<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>
http://openmx.psyc.virginia.edu/thread/2204#commentsFit FunctionsWed, 10 Jul 2013 22:34:41 +0000HAMED2204 at http://openmx.psyc.virginia.eduusing mxRun (unsafe=TRUE) to skip error and continue loop?
http://openmx.psyc.virginia.edu/thread/1989
<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>
http://openmx.psyc.virginia.edu/thread/1989#commentsFit FunctionsThu, 07 Mar 2013 21:36:29 +0000Jean1989 at http://openmx.psyc.virginia.educurious lack of warning/error
http://openmx.psyc.virginia.edu/thread/1949
<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>
<table id="attachments" class="sticky-enabled">
<thead><tr><th>Attachment</th><th>Size</th> </tr></thead>
<tbody>
<tr class="odd"><td><a href="http://openmx.psyc.virginia.edu/sites/default/files/curiousProblem.R">curiousProblem.R</a></td><td>1.99 KB</td> </tr>
<tr class="even"><td><a href="http://openmx.psyc.virginia.edu/sites/default/files/dz.csv">dz.csv</a></td><td>1.58 KB</td> </tr>
</tbody>
</table>
http://openmx.psyc.virginia.edu/thread/1949#commentsFit FunctionsSun, 24 Feb 2013 19:14:00 +0000carey1949 at http://openmx.psyc.virginia.eduModel to base comparisons on for chi-square goodness-of-fit?
http://openmx.psyc.virginia.edu/thread/1823
<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>
http://openmx.psyc.virginia.edu/thread/1823#commentsFit FunctionsThu, 03 Jan 2013 14:34:01 +0000Karin1823 at http://openmx.psyc.virginia.eduInterpretation of chi-square goodness-of-fit
http://openmx.psyc.virginia.edu/thread/1779
<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>
http://openmx.psyc.virginia.edu/thread/1779#commentsFit FunctionsFri, 07 Dec 2012 10:47:02 +0000Karin1779 at http://openmx.psyc.virginia.eduBest fit indices
http://openmx.psyc.virginia.edu/thread/1761
<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>
http://openmx.psyc.virginia.edu/thread/1761#commentsFit FunctionsSat, 01 Dec 2012 14:13:51 +0000LearnSEM81761 at http://openmx.psyc.virginia.educomparing -2LL for classic and Open Mx
http://openmx.psyc.virginia.edu/thread/1456
<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>
http://openmx.psyc.virginia.edu/thread/1456#commentsFit FunctionsWed, 18 Jul 2012 08:28:14 +0000ebejer1456 at http://openmx.psyc.virginia.eduComparing nested ACE models
http://openmx.psyc.virginia.edu/thread/1218
<p>Hello!</p>
<p>I hope someone can help with a rather simple question:<br />
When you compare the fits of an ACE model to the nested AE, CE and E submodels should you then compare the E model to the AE (or CE) sbmodel or to the ACE model?<br />
I would tend to compare the E model to the "nextlarger" submodel to test for a significant deterioration of the fit, but I have the impression that others compare all models to the ACE model.</p>
<p>Thanks for your help</p>
<p>Henning</p>
http://openmx.psyc.virginia.edu/thread/1218#commentsFit FunctionsTue, 03 Jan 2012 14:46:16 +0000henning1218 at http://openmx.psyc.virginia.eduChi-Square Confidence Interval
http://openmx.psyc.virginia.edu/thread/1110
<p>Dear all, </p>
<p>I used the following line to obtain a confidence interval around the chi-square, but I received an error that this key is not found in the mxOptions. </p>
<p>model1a = mxOption(model1,"Chi-Square Confidence Intervals", "Yes")</p>
<p>Indeed, when I ask for "getOption('mxOptions')" the option does not seem to exist. Is this true? Or am I doing something wrong?</p>
<p>Thanks in advance!<br />
Suzanne</p>
http://openmx.psyc.virginia.edu/thread/1110#commentsFit FunctionsFri, 07 Oct 2011 13:58:00 +0000suzannejak1110 at http://openmx.psyc.virginia.eduindividual likelihood statistics (classic Mx MX%P)
http://openmx.psyc.virginia.edu/thread/1027
<p>Is there some way to export the likelihood function for a vector of observations equivalent to the 1st column of the classic Mx MX%P= command?</p>
http://openmx.psyc.virginia.edu/thread/1027#commentsFit FunctionsWed, 20 Jul 2011 13:17:37 +0000t0mpr1c31027 at http://openmx.psyc.virginia.edugxe in the presence of rge unrestricted baseline model
http://openmx.psyc.virginia.edu/thread/838
<p>Hello -<br />
I'm using a gxe in the presence of rge model and was wondering if I need to first run an unretricted baseline model to determine the minimized value of -2lnL of the data. If so, does anyone have a script for this?</p>
<p>I do not think I can use a bivariate unrestricted baseline model for this as I am using the gxe in the presence of rge in an atypical way. I am including two traits (continuous variables) and one moderator (categorical variable) so that I can examine the influence of the moderator on the covariance between the two traits. Given the altered use of the model, I wasn't sure if I need to (or can) run an unrestricted baseline model first. </p>
<p>Thank you!</p>
http://openmx.psyc.virginia.edu/thread/838#commentsFit FunctionsTue, 15 Mar 2011 15:47:28 +0000jenslane838 at http://openmx.psyc.virginia.eduSRMR with missing data
http://openmx.psyc.virginia.edu/thread/825
<p>I'm trying to create a function to calculate SRMR, but I'm not sure how to do this when there are missing data. Does anyone have suggestions about what observed covariance matrix to use when there are missing data (or does anyone know what mplus or amos use to get SRMR with missing data)?</p>
<p>Also (and I'm sure this is much easier), how can I get the predicted covariance matrix among observed variables in OpenMx? I'm sure this is obvious, but I couldn't figure out how to pull this out of the output.</p>
<p>Thanks!</p>
http://openmx.psyc.virginia.edu/thread/825#commentsFit FunctionsFri, 04 Mar 2011 13:58:30 +0000rlucas825 at http://openmx.psyc.virginia.edu