|

Confirmatory Factor Analysis with Mplus – That was easy!

Someone had a question about factor analysis with Mplus and even though it is not a piece of software I work with normally, we aim to please at The Julia Group, so I downloaded the demo version and away I went.

It truly was, as my granddaughter says, easy-peasy lemon squeezie.

You might not think so, because the first thing you are confronted with is pretty much a blank window like this

screen shot of editorFor people who are used to Excel, SPSS, SAS Enterprise Guide or other friendly GUI interfaces, this might be a bit off-putting. However, doing a confirmatory factor analysis was this easy.

1. Create a .dat file from the original file. The file was in a SAS format and I did not have SAS on the laptop I was working on (I’m in Cambridge, MA at the moment). What I did was

  • Open the file in SPSS by, from the FILE menu selecting READ TEXT DATA and then selecting SAS as the format
  • Ran this SPSS command from the syntax window to output a tab-delimited file with no header, which was the type of input Mplus would expect.

2. Type in this program to do a two-factor solution with the first three variables loading on the first factor and the next three loading on the second factor.

TITLE : Confirmatory Factor Analysis ;
DATA:  FILE IS ‘/Users/annmaria/Documents/mplustest/values.dat’ ;
VARIABLE: NAMES ARE q1f1 q2f1 q3f1 q1f2 q2f2 q3f2 ;
MODEL: f1 BY q1f1 q2f1 q3f1 ;
f2 BY q1f2 q2f2 q3f2 ;
OUTPUT: standardized ;

3. Click the RUN button.

That is really all there was to it.

Okay, well that is easy if you knew what to type so let me explain a few things. If you know SAS or SPSS this will be easy.

Each of those things that I put in all capitals is a command in Mplus, analogous to a DATA or PROC step in SAS and a command in SPSS. They don’t need to be in all caps, I just did that for ease for the reader. They DO need to be followed by a colon and then end the statement in a semi-colon.

Title – pretty obvious, gives your output a title.

DATA: FILE IS  — gives the path to locate your data.If your file is in the same directory as your program, you don’t need a fully qualified path and can just call it ‘values.dat’

VARIABLE: NAMES ARE

Give the names of your variables. You can specify a format but if you do not Mplus assumes they are in free format, which is the same as what SAS refers to as list format.  You might want to note that if you are using the demo version you can only have a maximum of 6 independent and 2 dependent variables.

MODEL:  This is my model (duh) and I am modeling two factors. The first factor I creatively named f1 and it is represented BY (notice the BY in the command) variables also creatively named q1f1 q2f1 and q3f1.

Similarly, I have a second factor named f2 ;

I added an OUTPUT statement with a standardized option because I wanted (surprise) standardized estimates. That statement is not required but as you’ll see in my next post on interpreting factor analysis data, you do want it.

I am intrigued by Mplus. It sort of assumes you have close to perfectly cleaned up data because I wouldn’t want to be doing a lot of data management with it, but for doing some relatively complex models  – factor analysis, path analysis, structural equation modeling – it looks pretty cool.

 

Similar Posts

2 Comments

  1. It’s easier than using a BIOS file so that your MAME runs Neo Geo rom files… not bad for something that starts off with a blank window!

Leave a Reply

Your email address will not be published. Required fields are marked *