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.
Please send your input, data, output, and license number to email@example.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;
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.
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.
I don't understand your question. Please send outputs that illustrate what you are saying along with your license number to firstname.lastname@example.org.
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).
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 email@example.com to comment on the standardized coefficients.
Luo Wenshu posted on Thursday, February 19, 2015 - 2:53 am
Dear Dr. Muthen,
I am using Mplus 7.3 doing twolevel analysis. I created cluster means for some observed variables and want to use these cluster means at level 2. I then listed these cluster means under original variables on the Usevariables list. Then running analysis led to the error that the number of record is 0. Currently I put Define comment down following the usevariables list. How should I position usevariables and define command?
Jane Doe posted on Thursday, March 12, 2015 - 11:35 am
Let me elaborate the question a bit. How about I have two latent variables f1 and f2. I generate a third latent variable which is the difference between these two latent variables: f3=f1-f2. (With your help I can now do this.) And I use f3 in my model further on as: x ON z f3;
But what I am interested in is the absolute difference between f1 and f2. Hence the previous question: can I use the absolute value of f3?
If the answer is still no. Then is it reasonable to save the factor scores for f3, take their absolute value and use that subsequently?
OR can I atleast generate a variable that takes value 1 if f3 is positive, 0 when f3 is 0 and -1 if f3 is negative?
Apologies for the long question. Thanks in advance.
Is it possible to use a "by" statement on the DEFINE line--or something that will achieve the same result as a "by" statement?
For instance, I want to calculate the Black-White achievement gap separately each of the numerous schools in my sample by calculating Black students' average achievement by school; and White studens' average achievement by school; and subtracting one from the other (also by school).
I will then use this variable in my model.
Is there a "by" statement available for the DEFINE line, in order to do this? I did not see one mentioned in the User's Guide.
Dear Linda, Below I described my data and what I am working on: My main hypothesis is: the effect of recovery during weekend (positive activation change over weekend) on health over time. I had three measurements over 1 year, for each I have one score of Health and three scores of positive affect before weekend (PAb), during weekend (PAd) and end of weekend (PAe) respectively. In a within person design I have to define the slope of positive affect change over weekend as the proxy of recovery that in turn will be used as the predictor of Health. I have to analysis my data in two levels of Between and Within person: Variables are: Health1 Health2 Health3 gender age and PAb1 PAd1 PAe1 (will define slope of recovery1) PAb2 PAd2 PAe2 (will define slope of recovery2) PAb3 PAd3 PAe3 (will define slope of recovery3)
For %between%: intercept and slope of health: I S |Health1@0Health2@1Health3@2 Then: I S ON gender age For %within%: Health1 ON slope of recovery1 Health2 ON slope of recovery2 Health3 ON slope of recovery3 So I need to DEFINE the slope of recovery (as a new variable) by taking 3 points of positive affect over each weekend. How can I have all of these analyses in one syntax of Mplus?
One approach is to do it in a wide, single-level format. Then you have 3*3 recovery outcomes and 3 health outcomes, so 12 columns in the data, not counting any covariates. You can formulate 3 growth models for the recoveries and let their growth factors predict the 3 health outcomes. I am not sure you need/want a growth model for the 3 health outcomes.
I've encountered some difficulties when I wanted to derive new variables from latent variables. I understand that I cannot use the define command for latent variables, but to show what I am aiming for I will put it as if I could.
m by m1 m2 m3; l by l1 l2 l3;
DEFINE: m2 = m**2; l2 = l**2;
In other words could you please let me know how I could derive the different transformations (e.g. squared, cubic) of latent variables in Mplus?
Dear Dr. Muthén, In a model I use for producing correlation tables I would like to define a new variable (bias) which is the difference between an affective latent variable (feels) and an observed variable (v9_6). To do this, I attempted a slightly modified version of Prof. Bengt's approach used above (post on March 02, 2015 - 11:01 am) for summing latent variables:
I'm running into a problem that's baffling me while trying to create a new variable. Here's what I have under define:
first = 0; if (time eq 1) then first = 1;
Mplus returns an error that nearly every case has data missing for the variable "first." I'm having trouble seeing how that can be, since the define command specifies that every case should have 0 unless the other variable (which has no missing data and varies between 1 and 12) is 1.
I'm running an ML-DSEM model, in case that matters. Any help much appreciated.
Any thoughts about why these lines in the define command:
first = 0; if (time eq 1) then first = 1;
would produce an error message that "first" is mostly missing data? The variable "time" has no missing data. I'm perplexed. I'm running an ML-DSEM model, in case that has anything to do with it. Any help much appreciated.