Monte Carlo Models PreviousNext
Mplus Discussion > Confirmatory Factor Analysis >
 Jeremy Miles posted on Tuesday, December 07, 2004 - 3:47 am

I was trying out the Monte Carlo modelling, in Mplus, using the first example from Muthen and Muthen - How To Use A Monte Carlo Study To Decide On Sample Size and Determine Power.

I get two error messages:

Your Text*** ERROR in Montecarlo command
Unknown option:

I stopped that error by changing gclasses to genclasses, but I'm not positive that's correct.

But then I get:

*** ERROR in Montecarlo command
Unknown option:

And I wasn't sure how to correct that one.

I'm using Mplus v3.11.



P.S. I've left the manual at home, and was trying to respond to this message, on a mailing list with a Monte Carlo simulation. Although if anyone thinks I'm wrong (or right) they could post to the list. (I think you have to join it, at, but it's not got a lot of traffic.
 Linda K. Muthen posted on Tuesday, December 07, 2004 - 6:41 am
GCLASSES has been changed to GENCLASSES. And NCLASSES has been changed to CLASSES in Version 3. If you are away from your user's guide in the future, the last chapter which summarizes all of the Mplus language can be found at under the Demo.
 Linda K. Muthen posted on Tuesday, December 07, 2004 - 8:25 am
One more thing. The Mplus Version 3 CD comes with all of the examples from the Mplus User's Guide plus Monte Carlo counterparts of most of these examples. These are a good place to start if you want to do a Monte Carlo study.
 Paul Tremblay posted on Thursday, November 10, 2005 - 2:13 pm
When conducting a monte carlo run such as the example 11.5 in the manual is there any way to obtain the population covariance matrix.
 BMuthen posted on Saturday, November 12, 2005 - 5:43 pm
This is not part of the output in a Monte Carlo analysis. You would use the MODEL POPULATION model from your Monte Carlo analysis in the MODEL command of a regular analysis with all parameters fixed to the population values. Use as data in this regular analysis a matrix of means zero, variances one, and covariances zero. Ask for RESIDUAL in the OUTPUT command. The estimated matrix you obtain is the population covariance matrix.
 CG posted on Thursday, January 18, 2007 - 9:32 am
I am interested in running a CFA model simulation in MPLUS. I have two questions:
1) I have external datafiles (like example 11.6) that I wish to read. While I've saved the data files as separate files, I can't get MPLUS to read in the successive datasets.
Here is an example, where the files are named MPLUS.rep1.dat, MPLUS.rep2.dat (following example 11.6)
TITLE: try1
data: FILE IS MPLUS.replist.DAT;
F2 BY Y6-Y10;

2) If the save data command is used, are the parameters that are saved standardized or unstandardized? If unstandardized, how can they be converted to standardized parameters?

thank you
 Linda K. Muthen posted on Thursday, January 18, 2007 - 9:49 am
Please send your output and license number to so I can see what error message you are getting.

The unstandardized coefficients are saved. You would have to standardize them if you want the standardized parameters.
 CG posted on Thursday, January 18, 2007 - 10:42 am
Thank you, I will send my output.

Regarding computing standardized parameters, can this be done using the MPLUS output information saved in the SAVEDATA file? If so, how?
 Linda K. Muthen posted on Friday, January 19, 2007 - 10:22 am
If you want to standardize the saved raw parameter estimates, you need to find the appropriate variances, turn them into standard deviations, and apply the proper formulas to each estimate.
 Gareth posted on Thursday, February 07, 2008 - 3:50 am
In the example for a growth model (normal, no missing data, with covariate) monte carlo study to determine sample size, could you tell me how
[x@0]; x@1;
corresponds to a mean of 0.5 and a variance of 0.25 for the dichotomous covariate?

If square brackets indicate means and x@1 indicates variance I'm not sure what I'm missing.

Thank you in advance
 Linda K. Muthen posted on Thursday, February 07, 2008 - 8:30 am
I think you will find that the CUTPOINTS option is used to make x a binary variable.
 Janke C. ten Holt posted on Wednesday, July 29, 2009 - 7:54 am
I would like to compare factor score estimates for different models (i.e., IRT, ordinary FA with ML estimation, and FA with WLSMV for categorical data) by running a Monte Carlo simulation.
For this, I need factor scores to be generated for every run of each model.
Is it true that this cannot be done in Mplus (since the savedata=fscores option is not available for type=montecarlo)?
And if so, could you suggest an alternative way of obtaining factor scores for each replication?

Thank you in advance
 Linda K. Muthen posted on Wednesday, July 29, 2009 - 1:44 pm
You would need to run the analysis for each data set separately if you want factor scores.
 Carol Parker posted on Wednesday, May 19, 2010 - 8:50 am

I am attempting to conduct a Monte Carlo study (using the external Monte Carlo procedure) in which I simulate data for two groups, each of which has a different underlying factor model (e.g., there are group-based differences in factor loadings). Subsequent to this I hope to analyze the data ignoring group membership. In step 1 of the procedure, the population values (e.g., of the factor loadings) in the output are consistent with what I've specified in my population model. However, the average estimates seem to be higher than what I would have anticipated, and I am concerned that this suggests I've made an error. On the other hand, this may be due to the fact that I have fixed an invariant factor loading to 1 in each of the groups in the subsequent model statement (i.e,. the model statement that follows the population model statement.) Should the average estimates in each group approximate the values specified in the population model, or is it likely that the discrepancies I'm concerned about are due to my identification constraint in the subsequent model statement? Thank you very much for your assistance with this!
 Linda K. Muthen posted on Thursday, May 20, 2010 - 11:34 am
Try using 10 replications and 10,000 observations. If the average values do not match the population values, then you are most likely doing something wrong. If you are fixing the first factor loading to one now but generated the data with all factor loadings free and the factor variance fixed to one, this may be an issue.
 Carol Parker posted on Thursday, May 20, 2010 - 2:16 pm
Thank you for your response. I tried what you suggested and had similar results. To clarify, my goal is to generate data for two groups, each with specified population values for factor loadings, residual variances, and factor means and variances. Subsequent to this I will analyze the data generated in step 1 (using type = montecarlo and the list.dat file created in the first step.) Since posting my question I found the following response to a question on another thread:

"Example 11.6 shows how to save data for a subsequent external Monte Carlo. You don't need the MODEL command if you are only saving the data. You do need the ANALYSIS command. Nothing in the MODEL command affects data generation."

If my goal is to generate data in the first step that will be saved and used in subsequent analyses, it sounds from this like I may not need to be concerned with the model statement in the first step that seems to be giving rise to the odd average parameter estimates? The average parameter values for the residual variances are consistent with the population values. The factor loadings are not, and the values of the factor loadings change depending upon which item I fix to 1. Furthermore, if I omit the model statement, my output does not include information on the population values of the parameters I specified in the population model statement -- I only get information on the item variances.
 Linda K. Muthen posted on Thursday, May 20, 2010 - 6:44 pm
Why do you need to use external Monte Carlo? This is usually done when internal Monte Carlo cannot be done.

You don't need the MODEL command when only generating data because the data are generated according to the model specified in the MODEL POPULATION command not the MODEL command.
 Daniel Gucciardi posted on Wednesday, October 12, 2011 - 5:53 pm
Dear Mplus Team and Forum Members,

Iím new to Monte Carlo simulations so any advice you could offer is greatly appreciated. Iíve performed a CFA of a 48-item questionnaire (correlated four-factor model) with 345 participants (CFI = .48, TLI = .45, SRMR = .09, RMSEA = .090, 90% CI = .087 to .093). Iíve subsequently revealed similar findings of inadequate model fit using ESEM.

Another reviewer has requested that I provide some justification for adequacy of the sample, referring me to the following paper:

Myers, Ahn, and Ying (2011)

Iíve also read Muthťn and Muthťnís (2002) paper. Iím interested in estimating the amount of power I will have with my fixed sample size of 345 participants. Thus, I was hoping you might be able to shed light on the following questions:

1. As there are no previous factor analytical studies of this measure, despite being employed in over 15 published studies now, is it justifiable for me to use the parameters from my CFA analysis as input for the population parameter estimates? My concern in this regard relates to the large degree of model misfit.

2. If using the parameters from my CFA model is not recommended, how else could I go about creating values for the population estimates with no other empirical data? Or is there some other method(s) that I could explore for estimating power post hoc?

Many thanks in advance.

 Linda K. Muthen posted on Thursday, October 13, 2011 - 9:22 am
If the model fits poorly, this will not work.

I question whether your data support four factors if the ESEM does not fit. You should do an EFA with these data to see how many factors are actually represented. If you are not using MLR, I would suggest that.
 Stephen Cox posted on Sunday, February 03, 2013 - 3:24 pm
Hi there - I am trying to install the runall utility so as to read in externally generated files for analysis. I have a 64-bit windows system, with which the runall utility appears incompatible.

Is this correct? Is there a version for the 64-bit version of Mplus?
 Linda K. Muthen posted on Sunday, February 03, 2013 - 3:48 pm
You should instead use external Monte Carlo. See Step 2 of Example 12.6. This has replaced RUNALL.
 Stephen Cox posted on Wednesday, February 06, 2013 - 4:50 pm
Thanks - I have made good progress.

I am having trouble getting my population defined correctly. Below is a simplified 2 factor CFA model I am testing using external monte carlo.

My problem is with defining the population covariance of the two latents (called global and study). The model runs if I do not include a population value, or leave the covariance statement out, but then sets the population value at 0 (thus the model does not fit).

If I include a population value, as shown below, the model does not converge (it says I have no free paramters).

What am I doing wrong?

file = resamplereplist.dat;
type = montecarlo;

Names = blah blah;
usevariables = blah blah;


global by ycopia8@1;
global by ycopia9*1.22 (p2);
global by ycopia10*1.054 (p3);
global by ycopia11*-.546 (p4);
study by ycopia15@1 (p5);
study by ycopia16*1.261 (p6);
study by ycopia17*1.216 (p7);
study by ycopia18*.654 (p8);
study with global*.514;

results = resamplea.dat;
 Linda K. Muthen posted on Thursday, February 07, 2013 - 9:47 am
Please send the output and your license number to
 Christopher Niileksela posted on Saturday, March 08, 2014 - 6:59 am
Hello - I am trying to run a monte carlo for a higher-order factor model. I am mostly interested in power for the factor loadings. I'm using standardized factor loadings from previous research for the model and had a question about how to set the residuals for the first-order factors. Right now, my model is:

F1 BY x1*.90 x2*.84 x3*.84;
F2 BY x4*.77 x5*.81 x6*.68;
F3 BY x7*.62 x8*.66;
F4 BY x9*.81 x10*.74;
higherOr BY F1*.85 F2*.63 F3*.86 F4*.84;


x1*.19; x2*.29; x3*.29;
x4*.41; x5*.34; x6*.54;
x7*.62; x8*.56;
x9*.34; x10*.45;

I am setting starting values for the indicator residuals by subtracting the squared 1st order factor loading from 1. My question is: Should the first-order factor variances be fixed using the same method, by subtracting the the squared second-order factor loading from 1 (as I have in the example above)? Or would the first order residual variances be set to 1? Something has to be fixed for the model to be identified, and I've searched to find out what the appropriate method would be for this. Any help would be greatly appreciated!
 Bengt O. Muthen posted on Monday, March 10, 2014 - 5:21 pm
I would assume that your original analysis has f1-f4 variances of 1 (it looks like it), which means that subtracting squared 1st-order loadings from 1 gives you the res-vars of the factor indicators. You can fix the 1st-order resvars to the values you show - those values don't need to be 1.
 Christopher Niileksela posted on Monday, March 10, 2014 - 5:57 pm
Thank you for the clarification!
 Joshua Wilson posted on Sunday, March 23, 2014 - 8:49 pm

I am trying to estimate Power based on a CFA model I estimated that had 10 continuous indicator variables, 3 latent factors, and a sample size of 179.

Is it acceptable to use the parameter estimates of the CFA model (generated from the SVALUES command) in BOTH of the following sections of the syntax for the montecarlo analysis?


 Linda K. Muthen posted on Monday, March 24, 2014 - 6:04 am
If that is your best estimate of your population parameter values, yes.
 Miel Ann posted on Tuesday, April 05, 2016 - 6:17 am
I was conducting a monte carlo simulation study. I have a question.

My research model is a three factors CFA with nine indicators.
The data set were generated using SAS (external data files, replication=500),
the data type is covariance matrix.

I would like to analyze 500 files at once by data type option (type=montecarlo covariance)
It is possible? or if not, is there an alterantive?
 Bengt O. Muthen posted on Tuesday, April 05, 2016 - 6:37 am
You can if you have a "replist" file and arrange things in line with "external Monte Carlo" - see "Step 2" of simulation examples in our UG.
 Miel Ann posted on Tuesday, April 05, 2016 - 8:05 am
Thank you for your reply.
However, my generated data type is covariance matrix (summary data)
So mplus output showed error message


TITLE: YB Method Within_Correct model
DATA: FILE =0.3B_L1replist.dat;
fw1 by y1-y2*0.8;
fw1 by y3*0.6;
fw2 by y4-y5*0.8;
fw2 by y6*0.6;
fw3 by y7-y9*0.8;
fw2 by y3*0.5;
fw3 by y6*0.5;
fw1 with fw2*0.5;
fw2 with fw3*0.5;
fw1 with fw3*0.5;
output: tech9;

*** ERROR in DATA command
External Monte Carlo requires individual raw data.
 Linda K. Muthen posted on Tuesday, April 05, 2016 - 8:20 am
Please send the output, the replist file, one data set, and your license number to
 Martin Taylor posted on Thursday, July 21, 2016 - 8:49 am
Having problems. Would someone please look over my syntax for errors? Thanks.

NAMES = u1-u30;
GENERATE = u1-u30(2);
nobs = 150;
nreps = 500;
SEED = 12345;
SAVE = dyad*.dat;
f1 BY u1-u15*.6;
f2 BY u16-u30*.6;


f1 WITH f2*.5;
u1 WITH u16*.25;
u2 WITH u17*.25;
u3 WITH u18*.25;
u4 WITH u19*.25;
u5 WITH u20*.25;
u6 WITH u21*.25;
u7 WITH u22*.25;
u8 WITH u23*.25;
u9 WITH u24*.25;
u10 WITH u25*.25;
u11 WITH u26*.25;
u12 WITH u27*.25;
u13 WITH u28*.25;
u14 WITH u29*.25;
u15 WITH u30*.25;

[u1$1*-.83 u1$2*.83];
[u2$1*-.83 u2$2*.83];
! dots are added here because I am
! over the kilobytes limit otherwise.
. . . .
. . . .
. . . .
[u29$1*-.83 u29$2*.83];
[u30$1*-.83 u30$2*.83];


 Linda K. Muthen posted on Thursday, July 21, 2016 - 2:00 pm
Please send the output and your license number to
 Martin Taylor posted on Thursday, July 21, 2016 - 2:26 pm
Hi Dr. Muthen,

Thank you for responding. But before I send off my output and license let me quickly ask if the answer to my problem is simple. Have any changes occurred between Mplus 7.4 (my version) and Mplus 6.11 with the WLSMV estimator, Monte Carlo function, or DIFFTEST features? I am consistently getting type I and power rates below a work I am trying to replicate and am looking for an explanation. I am getting no error messages.

 Linda K. Muthen posted on Thursday, July 21, 2016 - 3:13 pm
I do not think so.
 Mirela Bilc posted on Wednesday, February 13, 2019 - 8:23 am
My question refers to the criteria used to determine sample size. In your 2002 paper,it says that ĒThe first criterion is that parameter and standard error biases do not exceed 10 percent for any parameter in the model.Ē This means A: that parameter biases should not exceed 10% and standard error biases should not exceed 10% for any parameter or B: that together parameter and standard error biases should not exceed 10%, meaning 5 percent each?

Thank you!
 Bengt O. Muthen posted on Wednesday, February 13, 2019 - 5:55 pm
Back to top
Add Your Message Here
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Options: Enable HTML code in message
Automatically activate URLs in message