22
Stata Technical Bulletin
STB-22
The dotted curves are the means which differ for males and females as well as cases and controls. The fitted curves are
drawn only for those with sex==O. The raw Poisson data is not shown.
Bugs
Note that sp_adj will fail to produce an error message if the same variable is listed twice in adjust. The result however
will be incorrect.
Figures
x
Natural Cubic Spline
Figure 1: Recovered sine wave
Figure 2: Poisson model
ssa6 Utilities for survival analysis with time-varying regressors
Dr. Philippe Bocquier, CERPOD, EMAIL [email protected]
Only one observation (record, line) per individual is needed for most survival analyses. However, when using time-varying
covariates, one needs several observations per individual. The data set typically contains separate observations for each state the
individual experiences from birth (or from the start of the period at risk) until the time of the event or of censorship. The time
of interest for calculations is the time at the end of each state—that is, the time at the end of the period represented by each
observation in the data set.
This insert presents four utilities that assist in preparing data for survival analysis when there are time-varying regressors.
censor generates a censoring variable; firstocc identifies the first occurrence of an event; slice creates additional observations
to trace fixed-time transitions; and tmerge match merges two files of ordered information on individuals. Each of these utilities
is explained and demonstrated in the sections below.
Creating a censoring variable
One difficulty in file preparation is creating a censoring variable that corresponds to the particular event one wants to study.
censor is a utility to create two variables, the waiting time until the event (or censorship), and a dummy that tells whether the
event is a failure or a censorship. Its syntax is
censor ident-var time.var [ order_var ] = exp [ if exp [ in range
n generat e(new~vαr) [ before (exp) ]
censor creates two new variables, specified by the generate O option. The first new variable is the censoring variable, a 0/1
variable that is set to one in the period at the end of which the individual changed state. The change in state is defined by the ‘=
exp’. The censoring variable, eew~var, is set to missing in periods after the individual changed state. The second new variable,
enew~aar, is the time at censoring. This variable is also set to missing after the event occurred.