Save fscores PreviousNext
Mplus Discussion > Categorical Data Modeling >
Message/Author
 Student 09 posted on Thursday, April 30, 2009 - 8:54 am
Hi

I wonder whether there is any possibility to save variables which are not part of the model with the savedata command.

I need to save both fscores and an Identifier-variable, which is not part of the model, and obviously cannot be saved together with the information on the fscores?

thanks
 Linda K. Muthen posted on Thursday, April 30, 2009 - 11:40 am
See the FSCORES option of the SAVEDATA command and the IDVARIABLE option of the VARIABLE command. You can save other variables using the AUXILIARY option of the VARIABLE command.
 Marissa Ericson posted on Thursday, June 23, 2011 - 9:27 am
would the SAVE FSCORES option save factor scores that are free from measurement error if you are specifying a latent variable with 5 predictors?
 Marissa Ericson posted on Thursday, June 23, 2011 - 10:41 am
Also, I am confused about how I am receiving a factor score for those participants who have no data. Thanks!
 Linda K. Muthen posted on Thursday, June 23, 2011 - 11:39 am
The default in Mplus is to estimate the model using all available information and missing data estimation. Therefore, all observations receive a factor score. For listwise deletion, add LISTWISE=ON; to the DATA command.

Factor scores are not the same as the factors in a model. How close they are to each other can be seen in the factor determinacy score. See the FSDETERMINACY option of the OUTPUT command.
 Marissa Ericson posted on Thursday, June 23, 2011 - 11:46 am
Thank you! One follow up question. If I have 5 measures and am creating a latent variable and then using that latent variable in subsequent analyses with other latent variables would the model use the same factor scores as I would receive in the fscores output? Is that what you meant by the factor scores are not the same as the factors in the model? For example, if I created a mean composite of the 5 measures would that differ the fscores output?
 Marissa Ericson posted on Thursday, June 23, 2011 - 11:49 am
To clarify further: I am doing a 4 latent variable cross lagged analysis in mplus but first doing CFA analyses on each of the 4 variables. Would the fscores data be the same as what is being used in this 4 latent variable cross lagged analysis? I would like to extract the same data without measurement error. Is that possible? Thank you again!
 Linda K. Muthen posted on Friday, June 24, 2011 - 9:25 am
I do not understand your question. However, I would only use factor scores if it was unavoidable.
 Marissa Ericson posted on Friday, June 24, 2011 - 9:58 am
Sorry if that was unclear. I am doing a basic 1-Factor CFA using 5 measures. When using the SAVE Fscores option, I am wondering whether the factor scores that are saved are free from measurement error. Thank you!
 Bengt O. Muthen posted on Friday, June 24, 2011 - 10:27 am
Factor scores can be seen as free of measurement error, but are not free of estimation error. Estimated factor scores do not behave as true factors (give different variances and relations to other variables) unless you have many good indicators. See for instance

Skrondal, A. and Laake, P. (2001). Regression among factor scores. Psychometrika 66, 563-575.
 Lisa M. Yarnell posted on Wednesday, February 15, 2012 - 8:43 am
When factor scores are saved, are they placed in the rightmost columns in the DAT file?

(This will affect the VARIABLE NAMES line in the program where I call in the saved data file.)
 Jon Heron posted on Wednesday, February 15, 2012 - 8:47 am
Hi Lisa,

it should tell you at the end of your .out file, e.g. here it's the last 8 vars

SAVEDATA INFORMATION

Order and format of variables

TOT_T1 F10.3
TOT_T2 F10.3
TOT_T3 F10.3
TOT_T4 F10.3
TOT_T5 F10.3
AGE_T1 F10.3
AGE_T2 F10.3
AGE_T3 F10.3
AGE_T4 F10.3
AGE_T5 F10.3
INTCPT1 F10.3
INTCPT1_SE F10.3
SLOPE1 F10.3
SLOPE1_SE F10.3
INTCPT2 F10.3
INTCPT2_SE F10.3
SLOPE2 F10.3
SLOPE2_SE F10.3
 Lisa M. Yarnell posted on Wednesday, February 15, 2012 - 9:06 am
Thanks, Jon--this is very helpful! I see in the Mplus manual how to merge files using an ID variable--but it is problematic that the saved factor score file does not have an ID in it.

How then do I merge these saved factor scores back into my main data set?

Thank you so much.
 Jon Heron posted on Wednesday, February 15, 2012 - 9:18 am
You can push the ID through to the final file within your variable section using

idvariable = ID;

the data I use had more than one ID and this isn't permitted with this command. If you're like me then you'll need to push other variables through using "auxiliary"

so I do

idvariable = ID1;
auxiliary = ID2;

Don't put them in your usevariable list though - the ID variable rarely fits the model well!!
 Lisa M. Yarnell posted on Wednesday, February 15, 2012 - 9:22 am
Exactly--I didn't want to put ID in the USEVARIABLE list because it would mess up the fit of my factor models!

Thanks so much, Jon, for your expertise on this.
 Joanne Bradbury posted on Thursday, February 16, 2012 - 3:35 pm
Hi,
I've just spent hours trying to save my factor scores through the MFILE command of the SAVEDATA function. I can save the factor scores no problem but I can't seem to get the factor scores to be merged back into the original dataset. Even trying to take them into SPSS was a problem with the factor scores being saved over three columns/variables. With MFILE, should I be nominating the original dataset that I want to merge the factor scores into?
Regards,
Joanne
 Linda K. Muthen posted on Friday, February 17, 2012 - 2:01 pm
You should be using the SAVE option if you want the factor scores in the original data set:

SAVE = FSCORES;
 Lisa M. Yarnell posted on Wednesday, February 22, 2012 - 11:36 pm
Hi Linda, can you tell me what is wrong in my Mplus script below, such that I get the error message at the bottom of this section of text? I was relying on p. 404 of the current Mplus manual as an example.

This script begins at the ANALYSIS line of my program, to save space.

ANALYSIS:
TYPE = BASIC;

SAVEDATA: MFILE = FACTORSCORES.DAT;
MNAMES ARE H4MH3R H4MH4R H4MH5R H4MH6R H4PE37R H4PE38R H4PE39R H4PE40R H4PE41R AID GENERAL CONCRETE;

MFORMAT IS 9F10.3 I9 2F10.3;

MSELECT ARE GENERAL CONCRETE;

MMISSING = H4MH3R H4MH4R H4MH5R H4MH6R H4PE37R H4PE38R H4PE39R
H4PE40R H4PE41R AID GENERAL CONCRETE (. *);

FILE IS MERGED.sav;
FORMAT IS FREE;
MISSFLAG = .;

*** ERROR in SAVEDATA command
Unknown option:
MFILE
 Linda K. Muthen posted on Thursday, February 23, 2012 - 6:52 am
Please send the output and your license number to support@statmodel.com.
 Lisa M. Yarnell posted on Thursday, February 23, 2012 - 10:10 am
Hi Linda, I took the advice of you and Jon Heron above, and saved the factor scores using the SAVE=FSCORES command, and selected other variables that I wanted in the saved data set using the AUXILIARY option.

But when I work with the newly created data set, factorscores_022312.dat, I get the message. Why would this be?

*** ERROR
The number of observations is 0. Check your data and format statement.
Data file: D:\AH\locker\factorscores_022312.dat
*** ERROR
Non-missing blank found in data file at record #1, field #: 18
 Linda K. Muthen posted on Thursday, February 23, 2012 - 11:16 am
Open the data file and look at record 1 filed 18.
 Lisa M. Yarnell posted on Tuesday, February 28, 2012 - 9:50 am
Hi Linda, can I change the default missing data flag when saving FSCORES from * to another value such as -999 or 999?

I got an error message when I tried to change the default missing data flag in this script.

SAVEDATA: FILE IS FACTORSCORES_022812.DAT; SAVE = FSCORES;
MISSFLAG = -999;
 Linda K. Muthen posted on Tuesday, February 28, 2012 - 10:28 am
Please send the output and your license number to support@statmodel.com.
 Lisa M. Yarnell posted on Monday, March 05, 2012 - 12:32 pm
Hi Linda, thanks for all of your help. What does it mean that Mplus saved two versions of my latent variables in the DAT file with the fscores:
GENERAL F10.3
GENERAL_SE F10.3
CONCRETE F10.3
CONCRETE_SE F10.3

Does the "_SE" refer to a standard error?
 Linda K. Muthen posted on Monday, March 05, 2012 - 12:40 pm
Yes.
 Lisa M. Yarnell posted on Tuesday, May 01, 2012 - 7:58 am
Hi Linda, I noticed that when I use SAVE FSCORES for a categorical factor analysis, SEs for the saved factor scores are missing from the list of variables in the DAT file that is created.

Is that true: There are no saved SEs for fscores from a categorical CFA?

Thanks.
 Bengt O. Muthen posted on Thursday, May 03, 2012 - 9:56 am
Mplus 6.12 does not have that, but if you use ML you can get that information via the information curve that you get in the PLOT command. One divided by the square root of the information value is the SE for the factor score at that factor value.
 Franziska posted on Tuesday, May 06, 2014 - 9:02 am
Dear Drs. Muthén,
I do have the same problem that has been posted by Joanne Bradbury on Thursday, February 16, 2012 - 3:35 pm
I have also spent hours trying to save my factor scores back into the original dataset through "just" the SAVE = FSCORES command. However, the output then tells me that this command is ignored as there is no datafile specified.
What am I doing wrong?
Thanks for answering!
Franziska
 Linda K. Muthen posted on Tuesday, May 06, 2014 - 10:28 am
You need to use the FILE option of the SAVEDATA command with SAVE=FSCORES. See the SAVEDATA command in the user's guide.
 Franziska posted on Thursday, May 08, 2014 - 9:16 am
Hi Linda,
this is what I have done:
Title:ESEM Germany 05 - Model 2: Invariance 8 factors, factorscores
Data: File is "C:\Users\wma117\Desktop\GERMANY_complete5.dat";
LISTWISE = ON;
Variable:Names are id br y co ca loc know es rel a1 a2 b1.....in1; [had do delete it due to message size]
CATEGORICAL ARE a1-in1;
USEVARIABLES = a1-in1;
Missing are all (-66);
GROUPING IS loc (0=loc 1=glob);
MODEL: f1-f8 BY a1-in1(*1);
ANALYSIS: PARAMETERIZATION = THETA;
ITERATIONS = 10000;
SAVEDATA: FILE IS GERMANY_complete5.dat;
SAVE = FSCORES;
OUTPUT: Standardized (STDYX)cinterval;

This was to try to save the factor scores into the original dataset to work with this afterwards. However, now the output says:
*** ERROR
The number of observations is 0. Check your data and format statement.

The dataset is fine. If I save the factorscores in a new dataset, everything runs smoothly.

I would really appreciate a helpful comment.

Thanks!
Franziska
 Linda K. Muthen posted on Thursday, May 08, 2014 - 2:17 pm
You can't use the same data set name in the FILE option in DATA and the FILE option in SAVEDATA.
 Franziska posted on Monday, May 12, 2014 - 12:08 am
Hi Linda,
thanks for the clarification!
So, as I see it, it is not possible to save factor scores "back" to the original dataset, right?
Thanks so much again for your support!
Franziska
 Linda K. Muthen posted on Monday, May 12, 2014 - 6:12 am
Correct.
 Stephus Daus posted on Monday, June 23, 2014 - 5:02 pm
Hi Linda
1. Could please be kind and post the solution to Yandell's MISSFLAG error above (post Feb 28 2012)?
2. How I can save all the records from the input dataset when I save the Fscores, even though these are considered missing on all values (listwise is off)?
3. Why doesn't the savedata FORMAT IS function work; neither with spaces or commas between?
Tried both Demo (mine) and full (campus) version of Mplus 7.2
[...]
Savedata:
File = Inquiry2.dat;
Save = Fscores;
Missflag = -9;
Format = 4F1.0 F5.3 2F8.0 F5.3 2F8.0;
! Format = 4F1.0, F5.3, 2F8.0, F5.3, 2F8.0;
*** ERROR in SAVEDATA command
Unknown option:
Missflag-9
Order and format of variables
I1 4F1.0
I2 4F1.0
I3 4F1.0
I4 4F1.0
SCIWGT 4F1.0
IDTEACH2 4F1.0
IDSTUD2 4F1.0
INQUIRY 4F1.0
STRATUM2 I8
TEACHID I8
Save file format
84F1.0 2I8
 Linda K. Muthen posted on Monday, June 23, 2014 - 5:52 pm
The FORMAT statement takes only one argument after the equal.

Regarding MISSFLAG, please send the output and your license number to support@statmodel.com.
 Johannes Bauer posted on Wednesday, January 27, 2016 - 8:59 am
Can negative numbers be used as missflag in the savedata command? In my analysis I received the following error message:

*** ERROR in SAVEDATA command
Unknown option:
missflag-99

Thanks
Johannes
 Linda K. Muthen posted on Wednesday, January 27, 2016 - 11:58 am
Try

MISSFLAG = -99;
 Johannes Bauer posted on Thursday, January 28, 2016 - 3:52 am
That was the input that I tried and that gave me the error message.

SAVEDATA: FILE IS output_pred.dat;
FORMAT IS FREE;
SAVE IS FSCORES;
missflag = -99;

*** ERROR in SAVEDATA command
Unknown option:
missflag-99
 Linda K. Muthen posted on Thursday, January 28, 2016 - 1:00 pm
Please send the output and your license number to support@statmodel.com.
 M.F. posted on Tuesday, June 07, 2016 - 11:41 pm
Hello,

I saved the factor scores for my seven items. Five of them are categorical.

When I compare the new file with the original data, I found that the categorical variables are changed and have new scores. The order is the same, I checked the Id.
I can't find why they are changed.

Can you pleas help me.
Thanks.
 Linda K. Muthen posted on Wednesday, June 08, 2016 - 7:02 am
See the CATEGORICAL option in the user's guide for an explanation of how the categorical items are recoded.
 Daniel Hatch posted on Saturday, October 22, 2016 - 5:23 pm
Linda,

Could you clarify what information is saved by the fscores subcommand? My input basically looks like this:

model: Factor1 by OV1 OV2 OV3 OV4 OV5;
Factor2 by OV6 OV7 OV8;

output: sampstat stdyx;

savedata: file is CFA_fs.dat;
save is fscores;

and I get 4 new variables. The first and third variables appear to be the factor scores (for Factor1 and Factor2 respectively I assume). Are the second and fourth variables SEs?

Thanks in advance for your help.

Dan
 Bengt O. Muthen posted on Sunday, October 23, 2016 - 1:26 pm
Yes, "Factor1_SE" refers to the Standard error of the factor score.
 Daniel Hatch posted on Monday, October 24, 2016 - 6:35 am
Thanks Bengt. Now, you mentioned "Factor1_SE"- is that a variable name? I noticed that when I ran the program above it didn't produce variable names. Is there a way to request that it do this?
 Linda K. Muthen posted on Monday, October 24, 2016 - 6:39 am
When you save data, a list of the variables in the order they are saved is shown at the end of the output with other information about the saved data set.
 Bengt O. Muthen posted on Monday, October 24, 2016 - 10:06 am
"Factor1" is the name you have given the factor. Mplus tacks on "_SE".
 J.D. Haltigan posted on Tuesday, October 10, 2017 - 6:42 pm
Quick one on this topic:

When I save factor scores using relevant steps, everything is fine, except I have two IDs that are blanks (they have response variable data). I am wondering why that might be?

Thank you!
 Linda K. Muthen posted on Wednesday, October 11, 2017 - 7:24 am
Please send the relevant files and your license number to support@statmodel.com.
 EH posted on Tuesday, September 18, 2018 - 10:54 pm
Dear Linda,

I keep getting this error:

SAVEDATA: FILE = FscoresPEWRL.sav; MISSFLAG = -99;
SAVE IS fscores;
FORMAT = F15.3;



*** ERROR in SAVEDATA command
Unknown option:
MISSFLAG-99

can you help?
 Linda K. Muthen posted on Wednesday, September 19, 2018 - 8:05 am
Use MISSFLAG=-99; No spaces around the equal sign.
 Tao Yang posted on Thursday, October 24, 2019 - 5:41 am
I was running Bayes estimation and try to save scores of latent variables. I see Mplus 8 manual has an illustration for SAVE = FSCORES (50 10), but I was using Mplus 7.11, and FSCORES allows only one value in the parentheses. If I enter FSCORES(500), what does it mean? Does it mean the latent variable score is based on 500 imputed datasets from Bayes?
 Tihomir Asparouhov posted on Friday, October 25, 2019 - 2:14 pm
Yes.
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: