Monte Carlo Simulation for CFA PreviousNext
Mplus Discussion > Confirmatory Factor Analysis >
Message/Author
 Yue Yin posted on Tuesday, October 24, 2017 - 2:31 pm
Hi, all,

I have a problem in running Monte Carlo simulation for CFA. I check the code in Mplus Manual, the code is as follows:
MONTECARLO:
NAMES ARE y1-y4;
NOBSERVATIONS = 500;
NREPS = 500;
SEED = 4533;
MODEL POPULATION:
f BY y1@1 y2-y4*1;
f*.5;
y1-y4*.5;
MODEL: f BY y1@1 y2-y4*1;
f*.5;
y1-y4*.5;
OUTPUT: TECH9;
The question is, I can only set the sample size for the simulation like 500, but I want to fix the correlation among y1-y4 to certain value, how do I do this? And one more question about the null model. I know in the null model, y1-y4 should not correlated with f. But should the correlation among y1-y4 is also 0? Thank you.
 Bengt O. Muthen posted on Tuesday, October 24, 2017 - 2:37 pm
y1-y4 will be correlated because they are all influenced by f. This is the idea behind factor analysis.
 Yue Yin posted on Tuesday, October 24, 2017 - 2:47 pm
Yeah, I know y1-y4 will be correlated, but I want to set the correlation among y1-y4 to a certain value, how should I do it?
 Bengt O. Muthen posted on Tuesday, October 24, 2017 - 2:55 pm
Your factor loading values will imply a certain correlation. And you can add a residual correlation between y's using WITH. The sum of the correlation from the factor model and the residual corr will be the total corr.
 Yue Yin posted on Tuesday, October 24, 2017 - 3:25 pm
Thank you for your quick reply. I still have a question regarding the syntax "model". So the model: in here is for the analyze the data generate from population right? like the regular model analysis? Do I have to set the parameter in the model part exact the same with population model?
 Bengt O. Muthen posted on Tuesday, October 24, 2017 - 5:45 pm
See our article on our website under Papers:

Muthén, L.K. & Muthén, B.O. (2002). How to use a Monte Carlo study to decide on sample size and determine power. Structural Equation Modeling, 4, 599-620. Mplus inputs and outputs used in this paper can be viewed and/or downloaded from the Examples page.
download paper contact first author show abstract
 Yue Yin posted on Wednesday, October 25, 2017 - 1:56 pm
Thank you! And the code I put in is as follows:
montecarlo:
names are y1-y5;
nobservations= 100;
nreps=100;
seed=4553;
model population:
f by y1@1 y2-y5*.3;
f*.5;
y1-y5* .3;

model: f by y1@1 y2-y5*.3;
f*.5;
y1-y5* .3;

output:tech9;
The tech9 displays some error:
REPLICATION 18:
WARNING: THE RESIDUAL COVARIANCE MATRIX (THETA) IS NOT POSITIVE DEFINITE.
THIS COULD INDICATE A NEGATIVE VARIANCE/RESIDUAL VARIANCE FOR AN OBSERVED
VARIABLE, A CORRELATION GREATER OR EQUAL TO ONE BETWEEN TWO OBSERVED
VARIABLES, OR A LINEAR DEPENDENCY AMONG MORE THAN TWO OBSERVED VARIABLES.
CHECK THE RESULTS SECTION FOR MORE INFORMATION.
PROBLEM INVOLVING VARIABLE Y1.
So could you tell me what might cause this? Thank you!
 Bengt O. Muthen posted on Wednesday, October 25, 2017 - 2:58 pm
We need to see your full output - send to Support along with your license number.
 Yue Yin posted on Thursday, October 26, 2017 - 4:15 pm
I don't know where is the license number, because I use the mplus in school's computer. Do I have to send the license number?
 Yue Yin posted on Thursday, October 26, 2017 - 5:01 pm
And I have one more question, I used the result=result.txt; to save the result because I want to check the CFI index. But I go through the manual, it did not tell me which number is the CFI. It says the parameter and residual are the same order in tech1 output, however, this output did not include CFI, RMSEA indices.
Thank you!
 Linda K. Muthen posted on Thursday, October 26, 2017 - 6:08 pm
The information saved is shown at the end of the output.

Support is available to one registered user per license with a current support contract. You will need to ask the IT person about the license.
 Yue Yin posted on Friday, October 27, 2017 - 12:00 pm
Hi, I check the end of the output of result which I saved, there is no information there. So I do not know which number is CFI I am looking for. I did not find CFI index in the regular output when I run the data. So one of my classmates told me if I want to check CFI, I can use result=result.txt; But there are bunch of lists numbers in the result, and I can't find which one is the CFI index. Could you help me with it? I post one result of the replications here:
1
0.12850963E+000 0.16637625E+000 0.10542683E+000 0.24245871E+000 -.53844490E-001 0.27359201E+001 0.27566123E+001 0.14999967E+001 0.14273713E+001 0.95628253E+000
0.59382407E+000 0.74838989E+000 0.86456038E+000 0.89356540E+000 0.33227006E-001
0.99474094E-001 0.91789804E-001 0.10004394E+000 0.96918565E-001 0.98043956E-001 0.24849708E+001 0.24859032E+001 0.13605512E+001 0.13166292E+001 0.14100323E+000
0.16245855E+000 0.17558644E+000 0.13699189E+000 0.13881395E+000 0.53722203E-001
0.22813263E+001 0.50000000E+001 0.80900559E+000 -.68725369E+003 -.68611303E+003 0.15000000E+002 0.14045074E+004 0.14435849E+004 0.13962112E+004 0.00000000E+000
0.30230132E-001
 Yue Yin posted on Friday, October 27, 2017 - 12:29 pm
Sorry about all the trouble, I found the information. But CFI is not listed in it. Is there any specific syntax I can use to obtain CFI? I am using Mplus 8.

Thank you!
 Linda K. Muthen posted on Friday, October 27, 2017 - 1:31 pm
I need to see the output at support. You need a support contract for this.
 Yue Yin posted on Thursday, November 02, 2017 - 3:25 pm
Hi,

I want to generate data based on only the correlation matrix, I put the code like this:
montecarlo:
names are y1-y5;
nobservations= 100;
nreps=200;
seed=4553;
repsave=all;
save=lown100rep*.dat;
model population:
y1 with y2 * .2;
y1 with y3 * .2;
y1 with y4 * .2;
y1 with y5 * .2;
y2 with y3 * .2;
y2 with y4 * .2;
y2 with y5 * .2;
y3 with y4 * .2;
y3 with y5 * .2;
y4 with y5 * .2;


output:tech9;
But the output gave me some errors:
*** WARNING in MODEL command
All variables are uncorrelated with all other variables in the model.
Check that this is what is intended.
1 WARNING(S) FOUND IN THE INPUT INSTRUCTIONS

*** FATAL ERROR
THE POPULATION COVARIANCE MATRIX THAT YOU GAVE
AS INPUT IS NOT POSITIVE DEFINITE AS IT SHOULD BE.

I am wondering that is there something wrong with it? And is it possible that to generate data only based on the correlation matrix I created?

Thank you.
 Bengt O. Muthen posted on Friday, November 03, 2017 - 10:32 am
Send your output to Support along with your license number.
Back to top
Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: