# Re: st: eqivalent to stkerhaz for discrete time survival analysis?

 From Steven Samuels To statalist@hsphsun2.harvard.edu Subject Re: st: eqivalent to stkerhaz for discrete time survival analysis? Date Mon, 16 Feb 2009 18:27:30 -0500

```--

Hilde-

```
Sorry, but I'm not familiar with -stkerhaz- (please show the source for non-official commands). Model your analysis after the example starting on the bottom of page 8 of http://www.iser.essex.ac.uk/files/ teaching/stephenj/ec968/pdfs/STB-39-pgmhaz.pdf. (The -pgmhaz- command has the same general set up as -pgmhaz8- and -hshaz-.) You must - expand- your data as Jenkins does. Start with a small unit (months? quarters? years?) Create an indicator variable for each interval. If the number of events per interval is small, group the original intervals as Jenkins does In your set-up, you had only two intervals; you should be able to get estimates for many more, unless the number of events in your data is very small. In Jenkins's example on page 11, he created six final intervals with only 31 events.
```
```
To estimate a probability for each interval, you must include all the interval indicators in the model and omit the constant (nocons option). Omit observations and indicators for intervals in which there are no events. To minimize fitting problems, use the options "difficult tech(dfp)" as in the last example in the -hshaz- help. You might also try -pgmhaz8-; it is another frailty model and will probably have fewer convergence problems.
```
```
Calculate the probabilities by yourself; Let interval j have dummy variable dj. You can estimate the baseline probability for interval j after running -hshaz- by:
```
gen p_j = exp(-exp(_b[dj]))

A -forval- statement will automate the process, e.g.:

forvalues j =1/12 {
gen p_`j' = exp(-exp(_b[d`j']))
}

```
If you add interactions with log(time) (recommended, rather than with time itself), the p's will be legitimate baseline probabilities for the situation when non-time covariates have value zero. In your example, you had a completely different probability at each interval for men and women. If you conclude you need separate probabilities, just fit the models separately for each gender. You might well find that different covariates matter for men and women, for example marital status, age, or number of children.
```
-Steve
On Feb 16, 2009, at 6:00 AM, Hilde Karlsen wrote:

```
```Dear statalisters,

```
I am performing a survival analysis of attrition from the nursing occupation (dependent variable is binary: 1 eq 'death/moved out'; 0 eq not moved out, and the time variable is discrete and ranges from 1-13 'years sice graduation').
```
```
I have read that I should estimate a baseline hazard to describe the form of the hazardfunction. However, I am not sure how to do this. I've found an ado which is called stkerhaz, but it seems this command should only be used after stcox, and I will probably be using the hshaz (model 2) or logit or cloglog. Is there a command which can help me estimate the baseline hazard and plot the hazardfunction, or do I have to calculate this myself? In the latter case, how do I do this?
```
```
Furthermore, I've been playing around a bit with hshaz, and the computations/convergence take a lot of time, particularly for model 2. I get messages from stata iteration log that the likelihood is very close to non-concave (or something in that direction). What is the best method to 'avoid' this long series of iterations?
```
Here is the syntax I wrote (please tell me if it is wrong) where :
male = man eq 1;
year1_4 = 1 to 4 years after graduation;
year5_8 = 5 to 8 years after graduation
(the omitted category is 9-13 years after graduation)
LPNR is the id-variable
movedout is the dependent variable (1= moved out, 0=not moved out)
```
Year is the time wariable, ranging from 1-13 years after graduation from the nursing study program
```

```
hshaz male year1_4 year5_8 male*year1_4 male*year5_8, id (LPNR) dead(movedout) seq(year)
```

```
Do you by the way know of a document which gives examples of estimation techniques and interpretation of estimates for the hshaz- command? (something similar to the chapter 7 from http:// www.iser.essex.ac.uk/iser/teaching/module-ec968 ?)
```

Best wishes,
Hilde

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```
```
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```