Useobservations and define commands PreviousNext
Mplus Discussion > Structural Equation Modeling >
Message/Author
 Jon Elhai posted on Friday, June 20, 2008 - 2:13 pm
Linda,
Is it possible to define a new variable using the DEFINE command (such as, y = a*b), and also exclude some subjects based on that new variable using the USEOBSERVATIONS command (such as USEOBSERVATIONS are y ge 2)?
 Linda K. Muthen posted on Friday, June 20, 2008 - 3:00 pm
Yes. Just put it at the end of the USEVARIABLES list.
 Jon Elhai posted on Friday, June 20, 2008 - 8:54 pm
Dear Linda,
I did as you suggested, but I received an error message. That is, I defined my new variable (newvar), included it at the end of my USERVARIABLES list, and included a USEOBSERVATIONS command to only include those subjects with a response of "1" on the new variable. But I received the error:

*** ERROR
Undefined variable used in transformation:
newvar

Here's abbreviated syntax I used...
VARIABLE:
NAMES ARE id ptsdd4life ptsdd5life;

MISSING ARE ptsdd4life ptsdd5life (-999);

CATEGORICAL are ptsdd4life ptsdd5life newvar;

USEVARIABLES ARE ptsdd4life ptsdd5life newvar;
USEOBSERVATIONS are newvar== 1;

DEFINE: (I set up define commands below this to calculate newvar)


ANALYSIS:
TYPE = basic ;
estimator=wlsmv;
 Linda K. Muthen posted on Saturday, June 21, 2008 - 6:50 am
Please send your input, data, output, and license number to support@statmodel.com.
 Kristine Molina posted on Saturday, January 30, 2010 - 1:02 pm
Hi--

I am planning to run a multiple group analysis for males and females in a particular subethnic group. My ethnicity variable has 4 subgroups. I am only interested in one group. I am using complex survey data.

I was wondering if the way I should specify the commands would be as such:
GROUPING IS SEX (1= Male 2=Female);
USEOBSERVATIONS ARE (ETHNICITY EQ 1);

Or if I should be using:
GROUPING IS SEX (1= Male 2= Female);
SUBPOPULATION IS (ETHNICITY EQ 1);

Thanks!
 Linda K. Muthen posted on Sunday, January 31, 2010 - 10:20 am
Theoretically you should use SUBPOPULATION but it is not available with multiple group analysis.
 Kristine Molina posted on Sunday, January 31, 2010 - 5:50 pm
So is there any way that I can still just run a path analysis model for each separate subgroup even if I can't do the difference test for them, at least just to see how the estimates compare across the subgroups?

I tried the following command:
USEOBSERVATION ARE (ETHNICITY EQ 1 AND SEX EQ 1);

and it is telling me that "the input file does not contain valid commands"

I cannot find an example in the Users Guide that specifies observations from two different variables (e.g., Sex and Ethnicity).

Thanks!
 Linda K. Muthen posted on Monday, February 01, 2010 - 8:21 am
I would run two analyses for each group -- one using SUBPOPULATION and one using USEOBSERVATIONS and compare the results. If they are very similar, I would use USEOBSERVATIONS in the multiple group analysis.

Page 442 of the user's guide shows a USEOBSERVATIONS statement with two variables. I believe the error message you are getting means you have statements before the TITLE command that are not in the Mplus language. If you cannot see the problem, you need to send the output and your license number to support@statmodel.com.
 Marie-Helene Veronneau posted on Thursday, June 17, 2010 - 12:30 pm
Just like Jon Elhai, I also got the error message "Undefined variable used in transformation" when using the DEFINE command to create a new variable (newvar) that I wanted to use in the USEOBSERVATIONS statement (USEOBSERVATIONS = newvar GT 0).

Apparently, we can only use variables from the original dataset in the USEOBSERVATIONS statement. Any variable created with the DEFINE commant CANNOT be used in the USEOBSERVATIONS statement.

If this information is true, I think it can be useful to leave it here on the discussion forum for other users who have this problem.
 Linda K. Muthen posted on Thursday, June 17, 2010 - 12:50 pm
As stated in the user's guide, only variables from the NAMES statement can be used with the USEOBSERVATIONS option.
 yang posted on Wednesday, November 16, 2011 - 12:37 pm
Linda,

Would you please kindly teach me how to select observations based on a character instead of numeric variable that is already in the data set being used? I could not find this information anywhere else. Thanks.
 Linda K. Muthen posted on Wednesday, November 16, 2011 - 2:07 pm
Mplus does not read character data. All data must be numeric.
 Summer McKnight posted on Friday, October 26, 2012 - 1:28 pm
I keep getting an error when I try to select only my baseline data. Any advice?

INPUT INSTRUCTIONS

TITLE: SOPS
DATA: FILE IS sops_cfa.csv;
VARIABLE: NAMES ARE RECID TIMEPT BASELINE CELL SOPSA1 SOPSA2 SOPSA3 SOPSA4
SOPSD1 SOPSD2 SOPSD3 SOPSD4;
USEV ARE SOPSA1 SOPSA2 SOPSA3 SOPSA4
SOPSB1 SOPSB2 SOPSB3 SOPSB4
SOPSC1 SOPSC2 SOPSC3 SOPSC4
SOPSD1 SOPSD2 SOPSD3 SOPSD4;
MISSING IS *;
!TIMEMEASURES = TIMEPT;
USEOBSERVATIONS ARE (TIMEPT EQ BASELINE);
ANALYSIS: TYPE = H1 MISSING;

OUTPUT: SAMPSTAT STANDARDIZED MODINDICES
*** WARNING in ANALYSIS command
Starting with Version 5, TYPE=H1 is the default for all analyses with
missing data. To turn off the estimation of the H1 model and the
computation of chi-square, use NOCHISQUARE in the OUTPUT command.
*** WARNING in ANALYSIS command
Starting with Version 5, TYPE=MISSING is the default for all analyses.
To obtain listwise deletion, use LISTWISE=ON in the DATA command.
*** ERROR
The number of observations is 0. Check your data and format statement.
Data file: sops_cfa.csv
*** ERROR
Invalid symbol in data file:
"YR1" at record #: 1, field #: 2
 Linda K. Muthen posted on Friday, October 26, 2012 - 1:43 pm
It sounds like you have the variable names in the first record of the data set. Please remove this record.
 Rebecca Wolf posted on Thursday, October 31, 2013 - 8:58 am
I'm trying to use the USEOBSERVATION command to run a multiple regression analysis for each school ID (SCHOOL=1302, for example), because I don't want to split my data file into hundreds of files, one for each school. However, I am getting drastically different results than in SPSS, and I don't have much missing data. So, I'm wondering if the USEOBSERVATION command is using the entire sample in the estimation instead of using only the cases in a particular school. Can you please comment on this? Thanks!
 Linda K. Muthen posted on Thursday, October 31, 2013 - 10:19 am
You can see what is being used by looking at the sample size printed in the output. Perhaps you are specifying USEOBSERVATIONS incorrectly. If you can't figure this out, please send the output and your license number to support@statmodel.com.
 Rebecca Wolf posted on Thursday, October 31, 2013 - 10:35 am
The sample size is correct, so that's not it.
 Linda K. Muthen posted on Thursday, October 31, 2013 - 11:42 am
If you can't figure this out, please send the output and your license number to support@statmodel.com.
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: