Defining a new variable PreviousNext
Mplus Discussion > Structural Equation Modeling >
Message/Author
 Susan Scott posted on Wednesday, November 22, 2006 - 10:39 am
I have the feeling I may be missing something very obvious, but when I add the following statement to my model

DEFINE:
sf36 = (pcs_ob + mcs_ob)/2;

with sf36 used in the following model statement:

MODEL:
HRQL BY eqsum eq5dw10 hu3m eqtherm sf36;


I get the error message:

** FATAL ERROR

THE SAMPLE COVARIANCE MATRIX COULD NOT BE INVERTED. THIS CAN OCCUR IF A
VARIABLE HAS NO VARIATION, OR IF TWO VARIABLES ARE PERFECTLY CORRELATED, OR
IF THE NUMBER OF OBSERVATIONS IS NOT GREATER THAN THE NUMBER OF VARIABLES.
CHECK YOUR DATA. THIS PROBLEM IS DUE TO:


VARIABLE : SF36

I am able to run the model with each of these variables individually, ie. pcs_ob and mcs_ob instead of sf_36. Also, I tried defining sf36 as sf36=pcs_ob, and I still get this message. So I am guessing the problem is with my definition statement.

Thank you,
Susan
 Linda K. Muthen posted on Wednesday, November 22, 2006 - 10:52 am
Please send your input, data, output, and license number to support@statmodel.com. It is not obvious what the problem is without further information.
 David Bard posted on Wednesday, November 22, 2006 - 9:44 pm
It's not obvious to me why, but adding a define command to my syntax resulted in loss of observations for a model that did not even contain the variables used in the define command. The define syntax was used for a previous model and was simply left in this new model after a cut and paste. It's not a big deal, I will simply exclude define commands not needed for a given model, but can you explain why this happens? tx, db.

If it helps, here's the define syntax:
DEFINE:
citpreg = citynum*pregnant;
twkhighc = twkhigh;
if twkhigh > 5 then twkhighc = 5;
twkamhdc = twkamhd2;
if twkamhd2 > 5 then twkamhdc = 5;
formrbc = formrb;
 Linda K. Muthen posted on Thursday, November 23, 2006 - 6:35 am
I would need more information to answer this question. Please send your input, data, output, and license number to support@statmodel.com.
 Roxana Dragan posted on Monday, June 08, 2009 - 9:13 am
I want to add a random variable to an existing variable. I do not plan to do this repeatedly like in a Monte Carlo study. I just need to use a command like DEFINE y=x+e, where:
y - new variable
x - old variable
e - random variable from the normal distribution with zero mean and a standard error I can choose. Can/(how do) I do this in Mplus? Thank you.
 Bengt O. Muthen posted on Monday, June 08, 2009 - 11:33 am
If e is latent, you don't need Define but can do it in the Model command as:

e BY;

If e is observed, Mplus does not currently offer this capability.
 PETER TOYINBO posted on Saturday, July 17, 2010 - 11:24 am
I wish to create MD_A from G12A and G15A where G12A tests presence of a condition (yes=1, no=5) while G15A scores severity scale' at 3 levels if checked 'yes' on G12A but assigns 'missing' if checked 'no'.

I wish to combine G12A and G15A in a new 4-level scale MD_A where 0 indicates absence of condition. Below is the partial syntax and error I am getting.

USEVARIABLES ARE

G18A G18B G18C G18D G18E G18F G18G G18H G18I G18J
MD_A MD_B MD_C MD_D MD_E MD_F MD_G MD_H MD_I ;

CATEGORICAL ARE

G18A G18B G18C G18D G18E G18F G18G G18H G18I G18J
MD_A MD_B MD_C MD_D MD_E MD_F MD_G MD_H MD_I ;

MISSING=. ;

DEFINE:

IF (G12A == 1) THEN MD_A == 0 ;
IF (G12A == 5 AND G15A == 1) THEN MD_A == 1 ;
IF (G12A == 5 AND G15A == 2) THEN MD_A == 2 ;
IF (G12A == 5 AND G15A >= 3) THEN MD_A == 3 ;

IF (G12B == 1) THEN MD_B == 0 ;
IF (G12B == 5 AND G15B == 1) THEN MD_B == 1 ;
IF (G12B == 5 AND G15B == 2) THEN MD_B == 2 ;
IF (G12B == 5 AND G15B >= 3) THEN MD_B == 3 ;

....

ANALYSIS: TYPE = EFA 1 4;

PLOT: TYPE IS PLOT3 ;

*** ERROR
Variable names must begin with an alphabet character:
EQ
 Linda K. Muthen posted on Saturday, July 17, 2010 - 11:31 am
See the DEFINE option of the user's guide. You can't use == on both the right and left-hand sides of THEN. On the right-hand side use =.
 PETER TOYINBO posted on Saturday, July 17, 2010 - 12:19 pm
I spotted an error in my syntax above and corrected it to now read:

IF (G12A == 5) THEN MD_A == 0 ;
IF (G12A == 1 AND G15A == 1) THEN MD_A == 1 ;
IF (G12A == 1 AND G15A == 2) THEN MD_A == 2 ;
IF (G12A == 1 AND G15A >= 3) THEN MD_A == 3 ;

But I am still getting the same error (below) about variable names which I could not figure out :

*** ERROR
Variable names must begin with an alphabet character:
EQ

Thanks for your help.
 Linda K. Muthen posted on Saturday, July 17, 2010 - 12:34 pm
On the right-hand side use = not ==.
 Spencer James posted on Tuesday, November 16, 2010 - 11:03 am
Why does Mplus use a degree of freedom to compute a new variable? How do I ensure that the added degree(s) of freedom does not influence my measures of model fit? Thanks for your help.
 Linda K. Muthen posted on Tuesday, November 16, 2010 - 2:11 pm
I don't understand your question. Please send outputs that illustrate what you are saying along with your license number to support@statmodel.com.
 Kerry Lee posted on Monday, December 06, 2010 - 3:15 am
Dear Dr. Muthen,

Is it necessary to list both the original variables and new variables created using DEFINE in USEVARIABLES? I thought this was the case after reading the User's Guide. However, when I did this, both original and new were included in a CFA model even though only the new variables were specified in MODEL.

On a related matter, I ran the same analysis using either the original and new variables (original/x to bring the scale back to 1 - 10). The raw bivariate correlations naturally remain the same, but the standardized CFA factor loadings and correlations are different.
Are such differences to be expected?

The difference in time needed to run the two analyses was astonishing: 37 min versus 56 sec (scaled).

Sincerely,
Kerry.
 Linda K. Muthen posted on Monday, December 06, 2010 - 6:34 am
Every variable specified on the USEVARIABLES list is included in the model to be estimated. New variables created using DEFINE must be placed on the USEVARIABLES list if they are used in the MODEL command. If any original variables are used in the MODEL command, the new variables created in DEFINE must follow them on the USEVARIABLES list.

Large variances make model convergence more difficult so this could increase the time. I would have to see the two outputs and your license number at support@statmodel.com to comment on the standardized coefficients.
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: