Discrete time survival analysis: medi... PreviousNext
Mplus Discussion > Categorical Data Modeling >
 Stan Hong posted on Wednesday, December 14, 2005 - 12:49 am
Dear Linda/Bengt

Using Mplus, is it possible to test mediation effect in discrete time survival analysis?

I'd like to test


where X=independent variables and M=mediators.

Are the point estimates and standard errors of the indirect effect generated by Mplu3 valid in this case?

Thanks so much in advance.
 Linda K. Muthen posted on Wednesday, December 14, 2005 - 7:45 am
Yes and yes.
 Stan posted on Saturday, December 24, 2005 - 8:13 pm
Merry Christmas!

Can you please let me know the formula of its standard error (for mediation effect in categorical data analysis)?

Which formula is used for computing a standard error of mediation effect in Mplus in general?
 Linda K. Muthen posted on Monday, December 26, 2005 - 9:25 am
For indirect effects in Mplus, standard errors are estimated using either the Delta method of bootstrap.
 Lois Gelfand posted on Friday, June 16, 2006 - 1:53 pm
Can you refer me to examples of testing mediation effect in discrete time survival analysis? Thanks! Lois
 Linda K. Muthen posted on Monday, June 19, 2006 - 8:07 am
I don't know the answer to this question. I will try to find the answer and post it if I do.
 Antonio A. Morgan-Lopez posted on Tuesday, June 20, 2006 - 5:42 am
Jenn Tein @ ASU has a chapter that should be relevant:

Tein, J.-Y., & MacKinnon, D. P. (2003). Estimating Mediated Effects with Survival Data. H. Yanai, A. O. Rikkyo, K. Shigemasu, Y. Kano, J. J. Meulman (Eds.) New Developments on Psychometrics (pp. 405-412). Tokyo, Japan: Springer-Verlag Tokyo Inc.

I'd contact her or Dave MacKinnon directly if you have trouble tracking down the book.......
 Steffi posted on Thursday, June 22, 2006 - 2:29 pm
I am afraid my problem is very basic but I cannot come up with a good explanation.

Running a DTSA with four binary indicators (x1-x4), and two continuous predictors (y1 and y2) the model quickly converges (Mixture Missing) and yields reasonable results. The relevant Model statement is:

eta BY x1@1 x2@1 x3@1 x4@1;
eta ON y1 y2;

The predictors y1 and y2 are correlated, but adding (y1 WIH y2) requires numerical integration, which never converges. The same is true for a mediator effect
(i.e., eta ON y1; y1 ON y2;).

The data are nice, and y1 and y2 are clearly correlated (and a mediator effect seems likely), so I think it is something more fundamental I am missing here...

Thank you very much for any insights!
 Bengt O. Muthen posted on Thursday, June 22, 2006 - 5:55 pm
The predictors y1 and y2 are correlated by default in the Mplus analysis. Just like in regression analysis, these correlations are not part of the model's parameter set. You should not mention y1 with y2.

If you really want the mediation model that you have problems with, contact support.
 Steffi posted on Thursday, June 22, 2006 - 11:26 pm
thank you for your fast reply! Indeed, the mediation is what I am actually after.

But out of curiosity: other than in "standard" CFA I assume it is not possible to constrain corr(y1, y2) to zero?

 Bengt O. Muthen posted on Friday, June 23, 2006 - 5:18 am
I think you are asking if in a mixture analysis you can constrain the correlation of two variables to zero if they are predictors of a continuous latent variable that in turn influences categorical observed variables. That is possible in Mplus. If you have problems doing so, please send your input, output, data, and license number to support@statmodel.com.
 Steffi posted on Monday, July 24, 2006 - 7:51 am
I have a follow up question on Stan Hong, Lois Gelfand and my earlier post:

I want to test a mediation effect in discrete time survival analysis (X->M->Y) with X = continuous predictor, M = continuous mediator and Y = vector of binary event indicators (proportional hazard odds assumption). I have censored observations, and from my reading of the literature, the best approach would be the product of coefficients method (a*b, where a is a standard regression coefficient and b is a logit coefficient) using bootstrapped SEs. With a logit link function and ML, am I correct that such a test is not (yet) possible in Mplus?

The next best approach is probably to compute SE using the Delta Method as recommended by Linda somewhere, but this also needs to be done by hand, correct?

Before tackling this task, I want to make sure that there is no "better" alternative (such as a probit-link function with WLSMV as indicated in another post, etc. but I am very hesitant to adopt such an approach since I have never seen it before in a DTSA context). What would you recommend me and can you provide me with any good references for mediation effects with dichotomous outcomes (I am aware of MacKinnons message from Dec. 04 and many of his excellent papers, but I wonder to which extent these findings can be generalized to DTSA with censored observations)?

Thank you so much in advance!
 Bengt O. Muthen posted on Wednesday, July 26, 2006 - 4:25 pm
You are right that we don't do model indirect for categorical ML. But you can use

model constraint:

- this gives the Delta method.

WLSMV is not appropriate with survival indicators given that missing data needs to be done via MAR.

I can't think of any mediation references with survival, but you may want to contact Katherine Masyn about that.
 kanako ishida posted on Tuesday, December 12, 2006 - 10:38 pm
I want to do discrete-time hazard model. My data set is in long format---observations at different ages are nested within individuals, which are nested in cluster (census tracts). Can I specify id of individuals as "idvariable" and census tracts as "cluster" to do three level model? Or do I have to restructure the data so that each age interval becomes one variable and to take a multivariate approach at the lower level?

Also, can I introduce frailty to account for unobserved heterogeneity for individuals without restructuring the data?

Any comments will be greatly appreciated!
 Linda K. Muthen posted on Wednesday, December 13, 2006 - 7:54 am
This can only be done in a wide format. Frailties can be introduced in the wide format.
 tarani chandola posted on Thursday, November 08, 2007 - 5:52 am
I am trying to use the "Model Constraint: New" command described by Bengt above on July 26, 2006 4:25 pm to obtain the Delta method for estimating the standard error of a mediation effect in a cox regression model.

However, I get a fatal error message: "*** FATAL ERROR
Internal Error Code: PR1004 - Parameter restriction split problem.
An internal error has occurred. Please contact us about the error,
providing both the input and data files if possible."

Am I doing something very wrong here? My syntax is below:

RGRLEV I_123Y P_123Y
survival=P_123Y (all);
timecensored=I_123Y (0= right 1=not);


P_123Y on FAMPROB6 (b);
P_123Y on RGRLEV ;

Model Constraint:
New (c);
 Linda K. Muthen posted on Thursday, November 08, 2007 - 7:59 am
The problem is that one variable is continuous and the other time censored. This is not allowed in MODEL CONSTRAINT. If you are creating an indirect effect, I am not sure that the product can be used here. You can ask for TECH3 and compute the standard error of the product yourself.
 tarani chandola posted on Friday, November 30, 2007 - 1:44 am
HI Linda,
Thanks for your reply on Nov 8. Could I please confirm with you about not being sure if the product can be used in the example syntax I posted on Nov 8? I would ideally like to estimate the indirect effect of RGRLEV on P_123Y (survival time). However, this would mean multiplying the estimates of the regression of FAMPROB6 on RGRLEV, and the cox regression of P_123Y on RGRLEV. As these are different kinds of regression analyses, perhaps I cannot multiply the paths together to obtain an indirect effect- is this correct?

Is there any way around this? I suppose I could forego the cox regression model and estimate the logistic model regressing I_123Y (survival or not) on FAMPROB6 - and then multiply the path from RGRLEV to FAMPROB6 and then FAMPROB6 to I_123Y to obtain the indirect effect of RGRLEV on I_123Y.
 Linda K. Muthen posted on Friday, November 30, 2007 - 7:58 am
See the following paper:

MacKinnon, D.P., Lockwood, C.M., Brown, C.H., Wang, W., & Hoffman, J.M. (2007). The intermediate endpoint effect in logistic and probit regression. Clinical Trials, 4, 499-513.
 Oliver Arranz-Becker posted on Monday, August 18, 2008 - 10:29 am
I have two questions concerning discrete-time mediated survival analysis. Our data set is in long format (observations nested within individuals). The predictor is dichotomous, mediators are continuous, dependent variable is an event indicator (no missing data).

1. Our model is a survival analysis with a preceding panel regression model. Is it correct to use TYPE=COMPLEX in conjunction with the CLUSTER option to account for the nonindependence of observations (due to the long format)? Or are there any alternatives you would suggest in our case (any literature suggestions are appreciated)?

2. Is it true that indirect effects can only be estimated with a probit regression in our case? Is there any alternative model specification based on the standard logistic link function?

Thank you in advance,
 Bengt O. Muthen posted on Monday, August 18, 2008 - 7:06 pm
1. It sounds like you have longitudinal data ("panel regression model" followed by a subsequent survival model. That seems to be best handled by letting the panel part be in wide, not long form (single-level analysis) since the survival modeling is in wide form (so first the columns with the panel outcomes for the panel time points, followed by columns for the even indicators).

2. You can consider the indirect effect with f as end point as in regular linear regression since f (using the Mplus UG notation) is continuous.
 Oliver Arranz-Becker posted on Wednesday, August 20, 2008 - 12:57 am
Thank you so much for your fast response.

We can see that your suggestion is a viable alternative. But: We are mainly interested in the effects of time-varying mediators on the outcome. If we use a wide data setup, we get several effects (as many as there are panel waves, in our case 8) on the respective event indicators. We feel this is quite cumbersome to depict/interpret.

Would it be correct to impose an equality contraint on the various effects per (time-varying) covariate? In this case there would be only one effect per time-varying covariate.
(Still, if the model fits worsens after the constraint, we continue to have the "cumbersome" multiple effects, don't we?)
 Linda K. Muthen posted on Wednesday, August 20, 2008 - 9:37 am
You can add equality constraints. Do you really believe that the relationship is the same at all time points?
 Oliver Arranz-Becker posted on Thursday, August 21, 2008 - 7:38 am
Thanks for your answer.

We are pretty sure the relationship is not invariant across time. But if this is the case, the results become quite technical/complicated for a non-methodological journal article, which we are trying to avoid...
Besides, isn't the equality constraint just what the "usual" time-discrete event history analysis with time-varying covariates does (unless you include interactions with times of measurement)?

One last question: Would you consider the "long format" approach (every row in the data refers to an episode of observation) incorrect, even if nonindependence of observations is controlled for by adjusting standard errors (by using the Mplus CLUSTER command)? In the "classic" (i.e., non-SEM) literature, time-discrete event history analysis is usually done in long format (this is why we figured we could run our analysis that way).
 Bengt O. Muthen posted on Thursday, August 21, 2008 - 4:08 pm
On the 1st paragraph - you can certainly do it with equality, hoping that fits well. But if it doesn't I am sure you can convince editors of the need for a better albeit slightly more complex model.

You can use the long format approach if (1) the nesting is the same for both the growth and the survival part, and (2) you take the older, long approach to survival.
 Mareike Doernte posted on Tuesday, February 09, 2010 - 3:20 am
Dear Linda/Bengt

I'd like to test a discrete time survival model with several independent variables (X) and a mediation effect(M).


My syntax is

f by t5-t18@1;
f on X1 X2 M;
M on X1 X2;

I know that it is possible to test mediation effects with MPlus but my model doesn't work this way.
Is there a mistake in my syntax? Do I have to set the variance of f free?

Thank you so much in advance!
 Linda K. Muthen posted on Tuesday, February 09, 2010 - 9:52 am
This look correct. Please send your output and license number to support@statmodel.com.
 Thierno Diallo posted on Wednesday, July 21, 2010 - 7:09 am
Dear Linda and Bengt,

I am doing a discrete time survival analysis by following models described in the Muthén and Maysen's article, and the Mplus user’s guide. However, I am experiencing some difficulties.

1) I have 10 time points but for the first two time points the binary U’s indicators have only 0 values. As the current version of Mplus doesn’t allow a categorical indicator with only one value, I thought of doing the analysis without the first two time points. That strategy can however result in bias in the estimation of the hazard because of the suppression of information related to time interval. Is that reasoning correct? If yes, is there any way to evaluate that bias? If the bias is negligible I can carry on with the discrete time survival analysis especially because the continuous one doesn’t really suit my problematical.

2) In the Muthén and Maysen's article they mentioned imposing specific structure to the logit baseline hazard. So, I was wandering how to test linear trend on the logit baseline hazard via MODEL CONSTRAINT.

I am looking forward to hearing your answer. Thank you for your invaluable help.
 Bengt O. Muthen posted on Wednesday, July 21, 2010 - 10:11 am
1) I may be wrong, but I don't see how deleting the first time points with u=0 biases the results. You simply have survival probability 1 during that time.

2) You can simply use the growth language

i s | u1@0 u2@1...

and make sure you don't get variances for the growth factors i and s. The use of "f BY u1-up@1 is the same as what the i growth factor does.
 Dustin Pardini posted on Wednesday, February 09, 2011 - 2:20 pm
I am planning to do a discrete time survival analysis and had a few questions I was hoping you could answer:

1) How should the data be coded for people who have missing assessments but then come back into the study? For example, say I have six assessments and someone drops out at time 3, but then comes back into the study at time 5 and reports the event. Should it be coded:

0 0 999 999 1 999 (999=missing)

if this hypothetical person did not report the event at time 5 or 6 would it be coded?

0 0 999 999 0 0

2) How does one handle unequal spacing between time points in these models?

Thanks in advance.
 Linda K. Muthen posted on Thursday, February 10, 2011 - 11:02 am
1. In the Muthen/Masyn implementation of discrete-time survival analysis in Mplus, only non-repeatable events such as onset of drug use are considered. Because of that, I think the coding for your two cases would be

0 0 0 0 1 999


0 0 0 0 0 0

Missing has a different meaning in this coding scheme.

2. The spacing does not matter unless you put a growth model on the thresholds.
 Dustin Pardini posted on Thursday, February 10, 2011 - 1:10 pm

Thanks for the reply. Since the people have missing information for some assessments it seems problematic to assume that the event has not occurred in for these phases (i.e., 0). I thought there was a way to take periodic missingness into account in these models. If I understand correctly dropout prior to an event occurring would be handled by coding 999 at the timepoint where dropout occurred, but handling periodic missingness as I outlined previously seems more tricky.
 Linda K. Muthen posted on Thursday, February 10, 2011 - 1:37 pm
The question would need to ask if it is the first time an event occurred. I don't think your coding scheme would work in the Mplus implementation.
 Chethan D Srikant posted on Saturday, November 19, 2011 - 9:25 pm
I have a dataset where the units under observation are subsidiaries of multi-national companies. In a period of 20 years new subsidiaries are setup that enter into the dataset. How should I code for the initial periods when they were absent because they were not born at all? They are not really missing values.

Thanks for your help
 Bengt O. Muthen posted on Sunday, November 20, 2011 - 8:15 pm
Since you posted under discrete-time survival, I assume you observe some event such as failure. Perhaps you should consider as your survival time variable, the number of years between being born and the event?
 Chethan D Srikant posted on Wednesday, November 23, 2011 - 1:43 pm
Yes, we do observe a failure and that is the event of interest, not the founding/entry. As of now I am not considering time-variant covariates (country level contextual factors) but the idea was to incorporate them at a later point of time. If I didn't have these I could have potentially coded each subject from its first year of entry. Even if I did this it would still bias any unobserved heterogeneity for the particular calendar year, for ex: there could have been a bad economic condition during a particular year in a particular country. So I just reasoned that I will code it as missing since it is not part of the risk set in any case.

If I correctly understood your suggestion - I can incorporate age as a time-variant covariate. I am just wondering if there would be too much of a correlation between this and the dependent variables (u) and wouldn't that overshadow the effects of my other variables?
 Linda K. Muthen posted on Tuesday, November 29, 2011 - 2:04 pm
We think age should not be the covariate - it should be the dependent survival variable. Instead we would recommend that the economic conditions that you are talking about should be a time-varying covariate - that can be done as in the

Discrete time survival may be a good approach here that can also accommodate time-varying covariates easily.
 Chethan D Srikant posted on Friday, December 02, 2011 - 4:59 pm
Yes, discrete time survival is the most appropriate approach for more than one reason for my analysis.

If I have age as the survival time dependent I cannot have macro-economic conditions as a simple time-varying covariate. Let me illustrate with an example. In a particular country consider subsidiary 1 as existing between 2006 and 2010. Subsidiary 2 exists from 2004 to 2008. I can have 7 dummy binary variables for age 1 to 7 but neither of them reached age 6. I now have 7 values for macro-economic condition. The macro-economic condition of year 2008 was fatal for one and not the other but with a simple time-varying covariate it appears that the fifth year (2008) was fatal for both.

If I correctly understood why you provided the particular link, what I can do is incorporate the existence of the subsidiary in a given year and year based time-varying variables in the latent part. This will incorporate the calendar year based effect on the survivability, through the class membership. Am I correct in interpreting what you said?
 Linda K. Muthen posted on Tuesday, December 06, 2011 - 2:17 pm
The time varying covariate would have to be coded for each observation separately

x1, x2, ..., x7
x1 would be bad economic condition in first year of existence
x2 would be bad economic condition in second year of existence ...

thus the data for the two companies would look like that

age, x1, x2, ..., x7

Now if you also add discrete time survival - the value 5 will also be split into binaries age1, age2,...,age7 age1, age2,...,age7, x1, x2, ..., x7
0,0,0,0,0,999,999 ,0,0,1,0,0,0,0
0,0,0,0,1,999,999 ,0,0,1,0,0,0,0
 Steffen Nestler posted on Wednesday, August 22, 2012 - 5:58 am
Dear all,
we are doing a discrete-time survival analysis in which we examine whether the effect of one time-invariant predictor (proportionality assumed and confirmed) on event occurences is mediated by a time-varying predictor (proportionality NOT confirmed). The basic model looks like this:

! c'-path
event_T1 on t_iv (1);
event_Tn on t_iv (1);

! b-paths
event_T1 on t_v1 (b1);
event_Tn on t_vn (bn);

! a-paths
t_v1 on t_iv (a1);
t_vn on t_iv (an);

To test mediation, we use the model constraint approach and everything works fine. However, given that the time-varying mediator is non-proportional we get n mediation effects (in our study n = 8); this makes sense but to facilitate the interpretation and reporting of the results, I was wondering whether there is a procedure or an approach to average the n effects? Or would you recommend to compute the model with proportionality assumed for the time-varying predictor?

Thanks in advance, Steffen
 Linda K. Muthen posted on Wednesday, August 22, 2012 - 12:18 pm
You can express the average in MODEL CONSTRAINT.
 Steffen Nestler posted on Wednesday, August 29, 2012 - 11:40 pm
Hi Linda,
thanks for your advice. Is the standard error for the average valid?
Thanks again, Steffen
 Bengt O. Muthen posted on Friday, August 31, 2012 - 2:56 pm
The SE that comes from Model Constraint is valid.
 Stefano posted on Friday, January 04, 2013 - 6:33 am
Dear Linda/Bengt,

I am running a discrete time survival analysis with a time-invariant predictor and considering a mediator (proportionality NOT confirmed).
Based on the last note on this thread, I would like to obtain the average of the n indirect effects, but I didn´t manage to write the correct code.

(simplified example with only 3 times)

f BY u1-u3@1;

!c' path
f on t_iv;

!b paths
u1 on m (b1);
u2 on m (b2);
u3 on m (b3);

! a path
m on t_iv (a);


model constraint:
new (ind1);
ind1 = b1*a
new (ind2);
ind2 = b2*a
new (ind3);
ind3 = b3*a

new (indirect);
indirect = mean(ind1 ind2 ind3);

How should i specify the model constraint to get the average correctly with their respective standard errors?

Thanks for your help!

 Linda K. Muthen posted on Friday, January 04, 2013 - 7:44 am
The MEAN option works in DEFINE not MODEL CONSTRAINT. Try

indirect = (ind1 + ind2 + ind3)/3;
 Stefano posted on Friday, January 04, 2013 - 8:07 am
Thanks a lot for your advice; it works this way.
How are the standard errors calculated for this indirect effect? Are they unbiased?

Thanks again for your help!
 Linda K. Muthen posted on Friday, January 04, 2013 - 10:27 am
They are Delta method standard errors. They are unbiased in large samples.
 Stefano posted on Saturday, January 05, 2013 - 8:58 am
Thanks for your reply. Another question: is there a way to get other model fit statistics besides AIC and BIC in a multilevel discrete time survival analysis with mediators?
 Bengt O. Muthen posted on Saturday, January 05, 2013 - 4:31 pm
No, you would have to compare competing models.
 Cheng posted on Wednesday, September 20, 2017 - 11:26 pm
May I know can I run Survival analysis for three outcome events (e.g., patient's survival, catheter free survival, and peritonitis free survival) in Mplus 7.4?

If yes, time for different events can it be done by using Cox within SEM-Survival analysis?

Thank you very much
 Tihomir Asparouhov posted on Thursday, September 21, 2017 - 4:45 pm
See section 3.1 in


and the Frailty directory of simulation examples in


To use Cox all you need to do is specify the variables like this

survival=t1 t2 t3;
Back to top
Add Your Message Here
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Options: Enable HTML code in message
Automatically activate URLs in message