Duration Analysis In Stata Kevin Sweeney Assistant Director, Political Research Lab Based On: An Introduction to Survival Analysis Using Stata We Will Cover: 1. Overview – Stata and “Shape” of Survival Data 2. ST-Setting and Describing Your Data 3. Nonparametric Analysis: Kaplan-Meier 4. Parametric Models (Exponential, Weibull…), and post-estimation 5. The Cox Proportional Hazards Model, and post-estimation
22
Embed
Duration Analysis In Stata - Department of Political Science Analysis In Stata Kevin Sweeney ... Contains data from ... Duration Analysis In Stata.ppt
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Duration Analysis In StataKevin Sweeney
Assistant Director, Political Research Lab
Based On: An Introduction to Survival Analysis Using Stata
We Will Cover:
1. Overview – Stata and “Shape” of Survival Data2. ST-Setting and Describing Your Data3. Nonparametric Analysis: Kaplan-Meier4. Parametric Models (Exponential, Weibull…), and post-estimation5. The Cox Proportional Hazards Model, and post-estimation
When You Open Stata…
Review W
indow:
Review W
indow:
Past Commands A
ppear H
ere
Variable Window:
Variable Window:
All Variables in Dataset Appear Here
Command Window:Command Window:Issued commands Appear Here
ResultsWindowResultsWindow::Recent Results Appear Here
Open Log Files Files Here View DataData Here
ST Setting Your Data
failtime x1 35 29 420 922 10
The basic syntax is stset time_of_failure_or_censoring_variable, failure(one_if_failure_variable)
So, if we had data that looked like this:
We’d type stset failtime
lasttime x failed1 3 15 2 19 4 120 9 122 10 0
If we had data that looked likethis, we’d type…
stset lasttime, failure(failed)
_t0 & _t – record time span_d – records outcome_st – records whether the ____observation is relevant.
ST Setting Your Data, Important Options
If you have more than one record per subject you must tell Statawhat the id variable is… name lasttime x failed
Bob 1 3 1Bob 5 2 1Jim 9 4 1Jim 20 9 1Jim 22 10 0
stset lasttime, failure(failed) id(name)
name lasttime x eventBob 1 3 7Bob 5 2 9Jim 9 4 6Jim 20 9 7Jim 22 10 9
You can also tell Stata a certainkind of event is a failure, whereasothers are not…
stset lasttime, failure(event==9) id(name)
ST Setting Your Data, One More Option
name begin lasttime x eventBob 0 1 3 7Bob 3 5 2 9Jim 0 9 4 6Jim 17 20 9 7Jim 21 22 10 9
Finally (well, not really), youcan tell Stata when your observations begin, if you don’tStata will do it for you…