OpenMx General Help
http://openmx.psyc.virginia.edu/taxonomy/term/7/0
enStaying informed with OpenMx
http://openmx.psyc.virginia.edu/thread/470
<p>The easiest way to keep up with the latest changes to the OpenMx software is to subscribe to receive email notification of any news updates. Assuming that you are logged in, click on the "My account" link on the left-hand panel of your screen. Next click on "Subscriptions" and then "Content types". Enable the checkbox for "News" and click on "Save". Once you have followed these steps, you will start receiving an email whenever something is posted under the "Recent News" section of the website (the top left panel, underneath the Guinea Pig). If you are concerned about inbox cluttering, it's ok you can expect a fairly low frequency of announcements.</p>
http://openmx.psyc.virginia.edu/thread/470#commentsOpenMx General HelpTue, 30 Mar 2010 14:24:47 +0000mspiegel470 at http://openmx.psyc.virginia.eduWelcome to the OpenMx General Help Forum
http://openmx.psyc.virginia.edu/thread/17-welcome-openmx-general-help-forum
<p>This forum is designed for general questions about how to use OpenMx. If you can't find another place where your question fits, then this is the place to be!</p>
http://openmx.psyc.virginia.edu/thread/17-welcome-openmx-general-help-forum#commentsOpenMx General HelpFri, 31 Jul 2009 18:51:09 +0000Steve17 at http://openmx.psyc.virginia.eduSpecifying Unique mxFitFunction
http://openmx.psyc.virginia.edu/thread/3972
<p>Hi,<br />
I am new to 2.0 and am playing around with specifying a non-standard fit function, and have hit some road bumps in trying to start with specifying the ML fit through mxFitFunctionAlgebra. Attached is the reproducible script. Error message is:</p>
<p>Error: The job for model 'One Factor' exited abnormally with the error message: MxComputeGradientDescent: fitfunction One Factor.fitfunction is not finite ()</p>
<p>If mxFitFunctionAlgebra() is used, does it have to include a gradient specification?</p>
<p>Thanks for your help.<br />
Ross<br />
mx version 4157,R 3.1.2, Mac OSX.</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/openmx_q.R">openmx_q.R</a></td><td>1.04 KB</td> </tr>
</tbody>
</table>
http://openmx.psyc.virginia.edu/thread/3972#commentsOpenMx General HelpTue, 31 Mar 2015 22:18:06 +0000jacobucc3972 at http://openmx.psyc.virginia.eduRestricted Model Cholesky; how to drop/fix parameters?
http://openmx.psyc.virginia.edu/thread/3968
<p>Hello everyone,</p>
<p>I'm a graduate student currently learning OpenMX, and I am unfortunately still a novice at OpenMX and genetic modeling in general. I've so far successfully run multivariate Cholesky analyses with OpenMX in R studio, and gotten interpretable data.</p>
<p>However, I am now trying to drop parameters on my current Cholesky model, to get a "best fit" reduced model for my data. I am having trouble understanding how I might do this; I understand it would involve fixing certain parameters at zero, but given my code, I am completely at a loss as to how I might go about this.</p>
<p>If anyone has the time, would they be able to help me understand how? Or, alternatively, point me in the direction of a Cholesky model code that could easily fix parameters? My thanks; my code is shown below.</p>
<p>nvar <- 4 # number of variables<br />
tnvar <-8 # number of variables*max family size<br />
nlower <-tnvar*(tnvar+1)/2 # number of free elements in a lower matrix tnvar*tnvar<br />
Vars <- c("v1","v2","v3","v4")<br />
selVars <- paste(Vars,c(rep(1,nvar),rep(2,nvar)),sep="")<br />
# This yields a list of the 6 variables for analysis<br />
#v11 v21 v31 v41 v12 v22 v32 v42<br />
mzData <- as.matrix(subset(twindata, zygosity==1, selVars))<br />
dzData <- as.matrix(subset(twindata, zygosity==2, selVars))<br />
#Print Descriptive Statistics<br />
#-------------------------------------------------------------------------<br />
summary(mzData)<br />
summary(dzData)<br />
### Fit Multivariate ACE Model with RawData and Matrices Input ###<br />
ACE_Cholesky_Model <- mxModel("ACE_Cholesky",<br />
mxModel("ACE",<br />
# Matrices a, c, and e to store a, c, and e path coefficients<br />
mxMatrix( type="Lower", nrow=nvar, ncol=nvar, free=TRUE, values=.6, name="a" ),<br />
mxMatrix( type="Lower", nrow=nvar, ncol=nvar, free=TRUE, values=.6, name="c" ),<br />
mxMatrix( type="Lower", nrow=nvar, ncol=nvar, free=TRUE, values=.6, name="e" ),<br />
# Matrices A, C, and E compute variance components<br />
mxAlgebra( a %*% t(a), name="A" ),<br />
mxAlgebra( c %*% t(c), name="C" ),<br />
mxAlgebra( e %*% t(e), name="E" ),<br />
# Algebra to compute total variances and standard deviations (diagonal only)<br />
mxAlgebra( A+C+E, name="V" ),<br />
mxMatrix( type="Iden", nrow=nvar, ncol=nvar, name="I"),<br />
mxAlgebra( solve(sqrt(I*V)), name="iSD"),<br />
# Matrix & Algebra for expected means vector<br />
mxMatrix( type="Full", nrow=1, ncol=nvar, free=TRUE, values= 0, name="Mean" ),<br />
mxAlgebra( cbind(Mean,Mean), name="expMean"),<br />
# Algebra for expected variance/covariance matrix in MZ<br />
mxAlgebra( rbind ( cbind(A+C+E , A+C),<br />
cbind(A+C , A+C+E)), name="expCovMZ" ),<br />
# Algebra for expected variance/covariance matrix in DZ<br />
mxAlgebra( rbind( cbind(A+C+E , 0.5%x%A+C),<br />
cbind(0.5%x%A+C , A+C+E)), name="expCovDZ" )<br />
),<br />
mxModel("MZ",<br />
mxData( observed=mzData, type="raw" ),<br />
mxFIMLObjective( covariance="ACE.expCovMZ", means="ACE.expMean", dimnames=selVars )<br />
),<br />
mxModel("DZ",<br />
mxData( observed=dzData, type="raw" ),<br />
mxFIMLObjective( covariance="ACE.expCovDZ", means="ACE.expMean", dimnames=selVars )<br />
),<br />
mxAlgebra( MZ.objective + DZ.objective, name="modelfit" ),<br />
mxAlgebraObjective("modelfit")<br />
)<br />
ACE_Cholesky_Fit <- mxRun(ACE_Cholesky_Model)<br />
ACE_Cholesky_Summ <- summary(ACE_Cholesky_Fit)<br />
ACE_Cholesky_Summ<br />
### Generate Multivariate Cholesky ACE Output ###<br />
parameterSpecifications(ACE_Cholesky_Fit)<br />
expectedMeansCovariances(ACE_Cholesky_Fit)<br />
tableFitStatistics(ACE_Cholesky_Fit)<br />
ACEpathMatrices <- c("ACE.a","ACE.c","ACE.e","ACE.iSD","ACE.iSD %*% ACE.a","ACE.iSD %*% ACE.c","ACE.iSD %*% ACE.e")<br />
ACEpathLabels <- c("pathEst_a","pathEst_c","pathEst_e","sd","stPathEst_a","stPathEst_c","stPathEst_e")<br />
formatOutputMatrices(ACE_Cholesky_Fit,ACEpathMatrices,ACEpathLabels,Vars,3)<br />
ACEcovMatrices <- c("ACE.A","ACE.C","ACE.E","ACE.V","ACE.A/ACE.V","ACE.C/ACE.V","ACE.E/ACE.V")<br />
ACEcovLabels <- c("covComp_A","covComp_C","covComp_E","Var","stCovComp_A","stCovComp_C","stCovComp_E")<br />
formatOutputMatrices(ACE_Cholesky_Fit,ACEcovMatrices,ACEcovLabels,Vars,3)<br />
# Genetic and Environmental Correlations<br />
ACEcorMatrices <- c("solve(sqrt(ACE.I*ACE.A)) %*% ACE.A %*% solve(sqrt(ACE.I*ACE.A))",<br />
"solve(sqrt(ACE.I*ACE.C)) %*% ACE.C %*% solve(sqrt(ACE.I*ACE.C))",<br />
"solve(sqrt(ACE.I*ACE.E)) %*% ACE.E %*% solve(sqrt(ACE.I*ACE.E))",<br />
"solve(sqrt(ACE.I*ACE.V)) %*% ACE.V %*% solve(sqrt(ACE.I*ACE.V))")<br />
ACEcorLabels <- c("corA","corC","corE","cor")<br />
formatOutputMatrices(ACE_Cholesky_Fit,ACEcorMatrices,ACEcorLabels, Vars, 4)</p>
http://openmx.psyc.virginia.edu/thread/3968#commentsOpenMx General HelpWed, 18 Mar 2015 03:03:19 +0000Lux Whitehaven3968 at http://openmx.psyc.virginia.eduOpenMx performance on CentOS server
http://openmx.psyc.virginia.edu/thread/3967
<p>I just run the demo script of the package and I don't modify the script.</p>
<p>when I run the demo script AlternativeApproaches.R on my computer, the running cpu is around 100% and completed in 10 seconds.<br />
input:<br />
time Rscript AlternativeApproaches.R<br />
output:<br />
real 0m2.431s<br />
user 0m3.752s<br />
sys 0m0.093s</p>
<p>But when I run the script on my company CentOS server, the running cpu is above 500% and completed in more than 15 minutes.<br />
input:<br />
time Rscript AlternativeApproaches.R<br />
output:<br />
real 2m39.438s<br />
user 15m6.753s<br />
sys 0m2.392s</p>
<p>it waste a lot of time to complete the mxRun() function.<br />
I have checked the param of mxRun() he mxOption(), but I didn't find out what param involved to this problem.<br />
what should I do to improve the performance of the script(almost all the demo script) when I run it on my server?</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/1.png">run_on_server.png</a></td><td>2.38 KB</td> </tr>
<tr class="even"><td><a href="http://openmx.psyc.virginia.edu/sites/default/files/2.png">run_on_my_pc.png</a></td><td>4.89 KB</td> </tr>
</tbody>
</table>
http://openmx.psyc.virginia.edu/thread/3967#commentsOpenMx General HelpTue, 17 Mar 2015 08:46:13 +0000hiliang3967 at http://openmx.psyc.virginia.eduSEM, Binary and Categorical Data in independent variables
http://openmx.psyc.virginia.edu/thread/3956
<p>Dear all, Please help me fixing this problem. </p>
<p>The data set has (please see example diagram)<br />
+ 3 continuous variables(X1, X2, X3) for a latent variable (intercept)<br />
+ 3 mediators (one binary X8 and two categorical variables X6, X7)<br />
+ 1 dependent variable (X4).</p>
<p>This coding was based on the post about Categorical Data in both independent and dependent variables <a href="http://openmx.psyc.virginia.edu/thread/3883" title="http://openmx.psyc.virginia.edu/thread/3883">http://openmx.psyc.virginia.edu/thread/3883</a></p>
<p>When I run SEM.R model I have following error message.</p>
<p>Error in mxRAMObjective(A = "A", S = "S", M = "M", thresholds = "Threshold") :<br />
argument 'F' is not a string (the name of the 'F' matrix)</p>
<p>When I delete #Threshold matrix from the SEM.R, I have the following error message. </p>
<p>Error: The following error occurred while evaluating the subexpression '`Linear Growth Curve Model Path Specification.I` - `Linear Growth Curve Model Path Specification.A`' during the evaluation of 'expVars' in model 'Linear Growth Curve Model Path Specification' : non-conformable arrays</p>
<p>#Threshold matrix<br />
mxMatrix(type = "Full", nrow = 1, ncol = 7, free = c(T, T, T, T, T, T, T),<br />
values = c(-0.18173563, -1.27430357,-1.75717640, 0.37933827,-0.01542988, -0.82819033, -0.12312234), byrow = T, dimnames = list(c(), c("X1","X2","X3","X4","X6","X7","X8")),<br />
name = "Threshold"),<br />
#Means and covaraince matrix<br />
mxRAMObjective(A="A", S="S", M="M", thresholds = "Threshold")</p>
<p>I know you are busy! But I will return you back! I appreciate your time!</p>
<p>Hyoshin,<br />
University of Maryland</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/example1.txt">example1.txt</a></td><td>17.99 KB</td> </tr>
<tr class="even"><td><a href="http://openmx.psyc.virginia.edu/sites/default/files/SEM.R">SEM.R</a></td><td>2.95 KB</td> </tr>
<tr class="odd"><td><a href="http://openmx.psyc.virginia.edu/sites/default/files/example_0.pdf">example.pdf</a></td><td>98.36 KB</td> </tr>
</tbody>
</table>
http://openmx.psyc.virginia.edu/thread/3956#commentsOpenMx General HelpMon, 23 Feb 2015 19:38:55 +0000HYOSHIN3956 at http://openmx.psyc.virginia.eduAccess Kalman filter generated process state estimates online (mxExpectationStateSpace)
http://openmx.psyc.virginia.edu/thread/3952
<p>I am using the Kalman filter implementation (mxExpectationStateSpace) to fit a time-discrete vector auto-regressive model to single subjects' multivariate time series. If I'm not mistaken, the Kalman filter generates (predicted and updated) process state estimates for each but the first time point. Is it possible to pull these state estimates out online while the data are being filtered?<br />
This would seem to provide the opportunity to include interactions between the (latent) processes over time. Currently, I am allowing the parameters of my bivariate process model (e.g., the auto- and cross-regressive effects) to be moderated by a third observed time-varying variable which I include as fixed. Therefore, temporal dependencies in this third variable, measurement error etc. cannot be accounted for. It would be much more convenient if it could be treated as a (latent) random variable. </p>
<p>Thanks, Janne</p>
<p>PS: Looking forward to the implementation of thresholds for discrete data!</p>
http://openmx.psyc.virginia.edu/thread/3952#commentsOpenMx General HelpFri, 13 Feb 2015 14:05:50 +0000janneadolf3952 at http://openmx.psyc.virginia.eduBackground of data set in OpenMx
http://openmx.psyc.virginia.edu/thread/3951
<p>I can see several twin data sets that come with OpenMx, for example, the DZO data described by following page:</p>
<p><a href="http://openmx.psyc.virginia.edu/docs/OpenMx/latest/_static/Rdoc/dzoData.html" title="http://openmx.psyc.virginia.edu/docs/OpenMx/latest/_static/Rdoc/dzoData.html">http://openmx.psyc.virginia.edu/docs/OpenMx/latest/_static/Rdoc/dzoData....</a></p>
<p>Would anyone please provide more background about this data? The sample size seems to indicate that it is not simulated data, but no descriptions are given for the variables.</p>
<p>I would appreciate it. Thanks.</p>
http://openmx.psyc.virginia.edu/thread/3951#commentsOpenMx General HelpSun, 08 Feb 2015 20:34:02 +0000wuhao_osu3951 at http://openmx.psyc.virginia.eduProblem with definition variables with state space expectation?
http://openmx.psyc.virginia.edu/thread/3948
<p>Am I doing something wrong? I was surprised when my model seemed to be ignoring my definition variables, but then I also notice that mxEval interprets them all as NA... this is using a build from yesterday, 1st Feb 2015, on 64 bit windows.</p>
<p>data(demoOneFactor)<br />
nvar <- ncol(demoOneFactor)<br />
varnames <- colnames(demoOneFactor)<br />
demoOneFactorInputs <- cbind(demoOneFactor, V1=rnorm(nrow(demoOneFactor)))<br />
ssModel <- mxModel(model="State Space Inputs Manual Example",<br />
mxMatrix("Full", 1, 1, TRUE, .3, name="A"),<br />
mxMatrix("Full", 1, 1, TRUE, values=1, name="B"),<br />
mxMatrix("Full", nvar, 1, TRUE, .6, name="C", dimnames=list(varnames, "F1")),<br />
mxMatrix("Zero", nvar, 1, name="D"),<br />
mxMatrix("Diag", 1, 1, FALSE, 1, name="Q"),<br />
mxMatrix("Diag", nvar, nvar, TRUE, .2, name="R"),<br />
mxMatrix("Zero", 1, 1, name="x0"),<br />
mxMatrix("Diag", 1, 1, FALSE, 1, name="P0"),<br />
mxMatrix("Full", 1, 1, FALSE, labels="data.V1", name="u"),<br />
mxData(observed=demoOneFactorInputs, type="raw"),<br />
mxExpectationStateSpace("A", "B", "C", "D", "Q", "R", "x0", "P0", u="u"),<br />
mxFitFunctionML()<br />
)<br />
ssRun <- mxRun(ssModel)</p>
<p>mxEval(data.V1, ssRun, compute=T, defvar.row=1)</p>
http://openmx.psyc.virginia.edu/thread/3948#commentsOpenMx General HelpMon, 02 Feb 2015 12:34:33 +0000CharlesD3948 at http://openmx.psyc.virginia.eduidentifying bivariate outliers
http://openmx.psyc.virginia.edu/thread/3899
<p>Hi,</p>
<p>I am trying to detect and identify bivariate outliers in a dataset using OpenMx, in order to see whether specific outliers have significant contribution. Preferrably the output would be like that of %p in old Mx.<br />
(i.e. 8 columns with:<br />
1) -2lnL,<br />
2) Mahalanobis,<br />
3) estimated Z,<br />
4) number of observations in data set,<br />
5) number of data points in vector,<br />
6) optimization details,<br />
7) whether or not likelihood was calculable, and<br />
8) model number if there are multiple models)</p>
<p>I have already tried using the vector=TRUE argument in FIMLobjective (as suggested in <a href="http://openmx.psyc.virginia.edu/thread/584" title="http://openmx.psyc.virginia.edu/thread/584">http://openmx.psyc.virginia.edu/thread/584</a>), however ID number is not included and I am unsure whether the output is in the same order as in the data file. </p>
<p>Any help would be appreciated, thanks. </p>
http://openmx.psyc.virginia.edu/thread/3899#commentsOpenMx General HelpFri, 26 Sep 2014 01:28:08 +0000ywyh3899 at http://openmx.psyc.virginia.eduCategorical Data in both independent and dependent variables
http://openmx.psyc.virginia.edu/thread/3883
<p>I have a data set with six binary variables, which I am trying to determine the temporal relationship. I was using lavaan R package, where they suggested to use dummy variable for endogenous variables (independent) and use ordered for exogenous (dependent variables). I was using the model as described in pdf file. I have gotten following results: </p>
<p>lavaan (0.5-16) converged normally after 31 iterations</p>
<p> Number of observations 51</p>
<p> Estimator DWLS Robust<br />
Minimum Function Test Statistic 5.699 7.295<br />
Degrees of freedom 7 7<br />
P-value (Chi-square) 0.575 0.399<br />
Scaling correction factor 1.006<br />
Shift parameter 1.632<br />
for simple second-order correction (Mplus variant)</p>
<p>Model test baseline model:</p>
<p> Minimum Function Test Statistic 61.153 45.447<br />
Degrees of freedom 14 14<br />
P-value 0.000 0.000</p>
<p>User model versus baseline model:</p>
<p> Comparative Fit Index (CFI) 1.000 0.991<br />
Tucker-Lewis Index (TLI) 1.055 0.981</p>
<p>Root Mean Square Error of Approximation:</p>
<p> RMSEA 0.000 0.029<br />
90 Percent Confidence Interval 0.000 0.153 0.000 0.178<br />
P-value RMSEA <= 0.05 0.654 0.486</p>
<p>According to lavaan since it was using DWLS, AIC and BIC are calculated. However, we had someone analyze the data before for us was using AIC and BIC to compare which temporal relationship is better at explaining our data. So I decided to try OpenMx, I am very new to path analysis and OpenMx, so I am not quite sure if I am treating the variables correctly. I have attached the code and dataset and the model was run and gave me some estimates, however, RMSEA was not computed. And the estimates for each path was different compared to lavaan. At this point, I am not sure how to compare my results from these two methods and if it's even comparable since OpenMx I turned everything into ordinal but in lavaan I used dummy variables. And why is that OpenMx didn't calcualte RMSEA for categorical data.</p>
<p>rl</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/model.R">model.R</a></td><td>2.79 KB</td> </tr>
<tr class="even"><td><a href="http://openmx.psyc.virginia.edu/sites/default/files/Models.pdf">Models.pdf</a></td><td>19 KB</td> </tr>
<tr class="odd"><td><a href="http://openmx.psyc.virginia.edu/sites/default/files/path input alt1.csv">path input alt1.csv</a></td><td>707 bytes</td> </tr>
</tbody>
</table>
http://openmx.psyc.virginia.edu/thread/3883#commentsOpenMx General HelpTue, 26 Aug 2014 21:15:14 +0000rl3883 at http://openmx.psyc.virginia.edumatrix logarithm function for mxAlgebra
http://openmx.psyc.virginia.edu/thread/3459
<p>Any chance of this being implemented at some point? Would seem to be consistent with the omxExponential implementation. Currently I optimize some free parameters over the range 0 to -inf, which is exponentially scaled, and I suspect this probably poses optimization difficulties....</p>
http://openmx.psyc.virginia.edu/thread/3459#commentsOpenMx General HelpThu, 26 Jun 2014 12:10:17 +0000CharlesD3459 at http://openmx.psyc.virginia.eduMultiple group analysis
http://openmx.psyc.virginia.edu/thread/3440
<p>Hi,</p>
<p>I hope this is not asked yet. Is there a maximum number of groups that can be specified with multiple group analysis on OpenMx? For example, 100 groups? And are there special steps to be taken when doing multiple group analysis if a number of groups is exceeded (e.g. 50 or 100)? </p>
<p>Thank you.</p>
<p>metavid</p>
http://openmx.psyc.virginia.edu/thread/3440#commentsOpenMx General HelpWed, 25 Jun 2014 17:48:55 +0000metavid3440 at http://openmx.psyc.virginia.eduDoes OpenMx support multilevel, ordinal/binary outcomes/indicators with sampling weights?
http://openmx.psyc.virginia.edu/thread/3321
<p>Hi,</p>
<p>I am hoping to perform a multilevel SEM on complex-sampling survey data, with known weight and binary outcome and ordinal independent variables. </p>
<p>Similar posts on this forum don't seem to support that this is simple to do on OpenMx, but any advice would be much appreciated. (<a href="http://openmx.psyc.virginia.edu/thread/2348" title="http://openmx.psyc.virginia.edu/thread/2348">http://openmx.psyc.virginia.edu/thread/2348</a>, <a href="http://openmx.psyc.virginia.edu/thread/861#comment-form" title="http://openmx.psyc.virginia.edu/thread/861#comment-form">http://openmx.psyc.virginia.edu/thread/861#comment-form</a>) </p>
<p>Thank you. </p>
http://openmx.psyc.virginia.edu/thread/3321#commentsOpenMx General HelpThu, 19 Jun 2014 18:22:03 +0000yoosoo3321 at http://openmx.psyc.virginia.eduObtain number of Objective function evaluations
http://openmx.psyc.virginia.edu/thread/3122
<p>Hi,</p>
<p>I am interested in obtaining both the number of major iterations and the overall number of objective function evaluations (how many times is the log likelihood and its gradient computed).<br />
I found model@output$iterations and model@output$evaluations. model@output$iterations is the number of major iterations. model@output$evaluations contains a vector with two integer entries. Does somebody know what the entries are?</p>
http://openmx.psyc.virginia.edu/thread/3122#commentsOpenMx General HelpMon, 26 May 2014 16:55:29 +0000jkarch3122 at http://openmx.psyc.virginia.edu