Dear Statalist.

I have estimated a discrete-time hazard model with a normal unobserved heterogeneity distribution using xtcloglog.
It is a single spell model in which individuals experience the event of interest only once, or are right censored.
The model incorporates both time varying and time invariant covariates.

I have followed the advice and procedures suggested in the excellent lessons provided by Professor Stephen P. Jenkins at https://www.iser.essex.ac.uk/resourc...sis-with-stata
I have organized my data appropriately and estimated the following model:

by id: ge newt = _n ;
ge logt = ln(newt) ;

xtcloglog y x1 x2 x3 x4 x5 x6 logt, i(id) nolog

Now, I want to calculate and graph the predicted hazard for the values of x6 given that the value of x5 == 1 (both are binary variables) over the spell months.
Here, I need to derive predictions assuming that the frailty term is set equal to its mean value.

Professor Jenkins’ advice in Lesson 7 (https://www.iser.essex.ac.uk/files/t...s/ec968st7.pdf) provides code for doing so for the pgmhaz8 estimator (pgmhaz8 is downloadable from SSC).

However, it is unclear for me whether the exact same code must be used when estimating models with the xtcloglog command.
On p. 21 in lesson 7, Jenkins writes “Observe that the same code could be used to generate predictions after estimating the proportional hazards or logistic models with Normal heterogeneity….. Note that, for these models, one could predict hazard rates in this model for each person within the sample using their built-in predict commands:

. predict p, pu0

Observe the “pu0” option. This ensures that the prediction is generated while conditioning on frailty being set equal to its mean value.”

Does this mean that I can calculate and graph the predicted hazard with the following code?

xtcloglog y x1 x2 x3 x4 x5 x6 logt, i(id) nolog

predict p , pu0
bysort id (newt): ge s = exp(sum(ln(1-p)))

ge h0 = p if x5 == 1 & x6 == 0
ge h1 = p if x5 == 1 & x6 == 1

twoway (connect h0 newt, sort msymbol(t) ) (connect h1 j, sort msymbol(o) ), title("Predicted hazard") saving(dclog1, replace)

This code produces plots, but I am not sure whether it is correct.

In other words, since the predict option is available for xtcloglog, can I skip the matrix operations and summarize to derive the mean as detailed in Jenkins’ Lesson 7 on pp. 18-19?

Any and all input on this question would be highly appreciated.

Sincerely,
Erik