Survival Part 5

download Survival Part 5

of 36

Transcript of Survival Part 5

  • 7/30/2019 Survival Part 5

    1/36

    1

    Survival Models in SAS

    Part 5: PROC LIFEREG

    Part 3February 13, 2008

    Charlie Hallahan

  • 7/30/2019 Survival Part 5

    2/36

    2

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG

    These talks are based on the book Survival Analysis Using the SAS System: A Practical

    Guide

    (1995) by Paul Allison.

    The book is part of the SAS Books-by-Users series and can be found at

    http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=55233

    http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=55233http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=55233
  • 7/30/2019 Survival Part 5

    3/36

    3

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG

    This series of talks will cover

    Chapter 1: Introduction

    Chapter 2: Basic Concepts of Survival Analysis

    Chapter 3: Estimating and Comparing Survival Curves with PROC LIFETEST

    Chapter 4: Estimating Parametric Regression Models with PROC LIFEREG

    Chapter 5: Estimating Cox Regression Models with PROC PHREG

    Chapter 6: Competing Risks

  • 7/30/2019 Survival Part 5

    4/36

    4

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG

    Topics in Chapter 4:

    Introduction

    The Accelerated Failure Time Model

    Alternative Distributions

    Categorical Variables and the CLASS StatementMaximum Likelihood Estimation

    Hypothesis tests

    Goodness-of-Fit Tests with the Likelihood-Ratio Statistic

    Graphical Methods of Evaluating Model Fit

    Left Censoring and Interval Censoring

    Generating Predictions and Hazard Functions

    The Piecewise Exponential Model

  • 7/30/2019 Survival Part 5

    5/36

    5

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG: Left Censoring and Interval Censoring

    A feature ofLIFEREG,

    not shared by PHREG, is its ability to handle both left

    censoring and interval censoring.

    Left censoring

    means the event of interest occurred sometime earlier than the

    observed time t.

    Interval censoring

    means that the event of interest occurred sometime in an

    interval [a, b], but it is not known exactly when in that interval.

    Left censoring is a special case of interval censoring where a =

    0.

    Right censoring is a special case of interval censoring where b = .

    Interval censoring is incorporated into the likelihood function as ( ) ( ), where

    (.) is the survivor function for observation .

    i i

    i

    S a S b

    S i

  • 7/30/2019 Survival Part 5

    6/36

    6

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG: Left Censoring and Interval Censoring

    A different syntax for the MODEL

    statement is required when either left or interval

    censoring is present.

    MODEL(LOWER,UPPER) = list of covariates

    The form of censoring for an observation depend on the values for UPPER and

    LOWER.

    Uncensored:

    LOWER and UPPER are both present and equal

    Interval Censored:

    LOWER and UPPER are both present and different

    Right Censored: LOWER is present and UPPER is missingLeft Censored: LOWER is missing and UPPER is present

    Any observation where LOWER is 0 or negative or both UPPER and LOWER are

    missing are excluded.

  • 7/30/2019 Survival Part 5

    7/36

    7

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG: Left Censoring and Interval Censoring

    For example:

    Observation Lower

    Upper

    Status

    .

    1 3.9

    3.9

    Uncensored

    2 7.2

    .

    Right Censored

    3 4.1

    5.6

    Interval Censored

    4

    .

    2.0

    Left Censored

    5 0

    5.8

    Excluded

    6

    3.2

    1.9

    Excluded

    Using the recidivism dataset, well artificially create censored data of various kinds.

    Recall that the current dataset only contains right-censored observations where no

    arrest has occurred by week = 52, the end of the study.

    The first 30 arrests are recoded to have WEEKequal to missing.

  • 7/30/2019 Survival Part 5

    8/36

    8

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG: Left Censoring and Interval Censoring

    data r eci d_t emp;r et ai n count 0;set sur vi val . r eci d;

    * set week = . f or 1st 30 ar r est s;i f count < 30 and ar r est = 1 t hen

    do;week = .;count = count + 1;

    end;

    * ar t i f i ci al l y cr eat e some censor ed dat a;i f _n_

  • 7/30/2019 Survival Part 5

    9/36

    9

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG: Left Censoring and Interval Censoring

    Model Information

    Dat a Set WORK. RECI D_TEMP

    Dependent Var i abl e Log( l ower )Dependent Var i abl e Log( upper )

    Number of Observations 432

    Noncensored Values 84

    Right Censored Values 318

    Left Censored Values 30

    Interval Censored Values 0Name of Di st r i but i on Wei bul lLog Li kel i hood - 294. 0611169

    Number of Obser vat i ons Read 432Number of Obser vat i ons Used 432

    t i t l e "Exampl e wi t h r i ght - and l ef t - censor i ng" ;proc lifereg dat a = r eci d_t emp;

    model (lower,upper)=f i n age race wexp mar par o pr i o

    / di st =wei bul l ;run;

  • 7/30/2019 Survival Part 5

    10/36

    10

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG: Left Censoring and Interval Censoring

    Analysis of Parameter Estimates

    St andar d 95% Conf i dence Chi -Par amet er DF Est i mat e Er r or Li mi t s Squar e Pr > Chi Sq

    I nt er cept 1 3. 9567 0. 4078 3. 1574 4. 7560 94. 14

  • 7/30/2019 Survival Part 5

    11/36

    11

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG: Left Censoring and Interval Censoring

    For comparison, here is the original model

    (without left-censoring):

    Anal ysi s of Par amet er Est i mat es

    St andar d 95% Conf i dence Chi -Par amet er DF Est i mat e Er r or Li mi t s Squar e Pr > Chi Sq

    I nt ercept 1 3. 9901 0. 4191 3. 1687 4. 8115 90. 65

  • 7/30/2019 Survival Part 5

    12/36

    12

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG: Left Censoring and Interval Censoring

    The data for the recidivism example is recorded weekly. This could be considered as

    daily data which has been interval-censored.

    The following code creates a new dataset where the arrest data is treated as daily

    data which has been interval-censored as weekly data.

    data r eci d_t emp;set sur vi val . r eci d;

    / * i nt er val censor ed cases: */i f ar r est =1 t hen do;

    upper =week;

    l ower =week- .9999;end;

    / * r i ght - censor ed cases: */i f ar r est =0 t hen do;

    upper=.;

    l ower =52;end;

  • 7/30/2019 Survival Part 5

    13/36

    13

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG: Left Censoring and Interval Censoring

    t i t l e "Exampl e wi t h i nt er val - censor i ng" ;proc lifereg dat a = r eci d_t emp;

    model ( l ower , upper ) =f i n age r ace wexp mar par o pr i o/ di st =wei bul l ;

    run;

    Model Information

    Dat a Set WORK. RECI D_TEMPDependent Var i abl e Log( l ower )Dependent Var i abl e Log( upper )

    Number of Observations 432

    Noncensored Values 0

    Right Censored Values 318

    Left Censored Values 0

    Interval Censored Values 114

    Name of Di st r i but i on Wei bul l

    Log Li kel i hood - 680. 995873

  • 7/30/2019 Survival Part 5

    14/36

    14

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG: Left Censoring and Interval Censoring

    Analysis of Parameter Estimates

    St andard 95% Conf i dence Chi -

    Par amet er DF Est i mate Er r or Li mi t s Squar e Pr > Chi Sq

    I nt ercept 1 3. 9906 0. 4374 3. 1333 4. 8479 83. 23

  • 7/30/2019 Survival Part 5

    15/36

    15

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    When predicting a single survival time for a particular observation, the median

    survival time

    is usually considered the most useful.

    The OUTPUT statement produces such a prediction.

    t i t l e "Out put t i ng t he medi an sur vi val t i me f or each obser vat i on" ;

    proc lifereg dat a=sur vi val . r eci d;model week*ar r est ( 0) =f i n age r ace wexp mar paro pr i o

    / di st =wei bul l ;output out=a p=median std=s;

    run;

    proc print dat a=a( obs=20) ;var week ar r est _pr ob_ medi an s;

    run;

    the P=

    keyword produces the median

    by default. Other percentiles can be

    requested with the QUANTILE keyword.STD=

    requests the standard errors of the

    median predictions.

  • 7/30/2019 Survival Part 5

    16/36

    16

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    Obs week ar r est _PROB_ medi an s

    1 20 1 0. 5 86. 910 14. 53222 17 1 0. 5 43. 353 6. 64563 25 1 0. 5 45. 257 14. 65374 52 0 0. 5 167. 947 50. 29315 52 0 0. 5 87. 403 21. 73066 52 0 0. 5 86. 166 13. 9891

    7 23 1 0. 5 148. 225 42. 41568 52 0 0. 5 93. 083 15. 53209 52 0 0. 5 54. 873 7. 6941

    10 52 0 0. 5 83. 518 15. 483011 52 0 0. 5 109. 544 18. 985912 52 0 0. 5 165. 290 50. 3119

    13 37 1 0. 5 56. 411 10. 131914 52 0 0. 5 146. 285 38. 767715 25 1 0. 5 65. 358 8. 360016 46 1 0. 5 110. 592 18. 114717 28 1 0. 5 45. 471 6. 8145

    18 52 0 0. 5 65. 816 10. 306419 52 0 0. 5 44. 305 9. 428820 52 0 0. 5 122. 208 30. 5519

  • 7/30/2019 Survival Part 5

    17/36

    17

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    To get predicted values for observations not in the original dataset, simply add these

    observations to the original dataset with a missing values for the event time.

    To restrict predictions to just a subset of observations, create

    a dummy variable,

    say USE, that equals 1 for a prediction observation and 0 otherwise.

    Then use the option CONTROL=USE in the OUTPUT statement.

  • 7/30/2019 Survival Part 5

    18/36

    18

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    To request specific predicted survival times, the author provides a macro called

    PREDICT.

    The calculations are straightforward once the linear predictor for an observation

    and parameter estimates are known.

    These are available in PROC LIFEREG with the OUTEST option on the

    PROC

    statement and the XBETA= option on the

    OUTPUT statement.

  • 7/30/2019 Survival Part 5

    19/36

    19

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    * - - - - - - - - - - - - - - ;* PREDICT Macro;* - - - - - - - - - - - - - - ;

    %macro predict(outest=, out=_last_,xbeta=,time=);

    / ********************************************************************MACRO PREDI CT pr oduces pr edi ct ed sur vi val pr obabi l i t i es f or speci f i edsurvi val t i mes, based on model s f i t t ed by PROC LI FEREG. When f i t t i ng t hemodel wi t h PROC LI FEREG, you must r equest t he OUTEST dat a set i n t he

    PROC st at ement . You must al so r equest an OUTPUT dat a set wi t h t heXBETA= keywor d.

    PREDI CT has f our paramet ers:

    OUTEST i s t he name of t he dat a set pr oduced wi t h t he OUTEST opt i on.

    OUT i s t he name of t he dat a set produced by t he OUTPUT st at ement .The def aul t i s t he l ast cr eat ed data set .

    XBETA i s t he name of t he var i abl e speci f i ed wi t h t he XBETA= keywor d.

    TI ME i s t he speci f i ed sur vi val t i me t hat i s t o be eval uat ed.

  • 7/30/2019 Survival Part 5

    20/36

    20

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    Exampl e of usage:

    To get 5- year survi val probabi l i t i es f or ever y i ndi vi dual i n t he sampl e( assumi ng t hat act ual sur vi val t i mes are measur ed i n year s) ;

    %pr edi ct ( out est =a, out =b, xbet a=l p, t i me=5) .

    Aut hor : Paul D. Al l i son, Uni v. of Pennsyl vani aal l i son@ssc. upenn. edu

    ( edited 10/25/2007)*********************************************************************/

    (I had to make a few edits to be compatible with the current version of SAS)

  • 7/30/2019 Survival Part 5

    21/36

    21

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    dat a _pr ed_;_p_=1;* use i f _di st _ = Gamma;*set &out est ( keep=_di st _ _ scal e__shape1_) poi nt =_p_;

    set &out est ( keep=_di st _ _scal e_ ) poi nt =_p_;f i l e pr i nt ;set &out ;l p=&xbet a;t =&t i me;gamma=1/ _scal e_;

    al pha=exp( - l p*gamma) ;pr ob=0;i f _di st _=' Exponent i al ' or _di st _=' Wei bul l ' t hen pr ob=exp( - al pha*t **gamma) ;i f _di st _=' Lognor mal ' t hen pr ob=1- pr obnor m( ( l og( t ) - l p) / _scal e_) ;i f _di st _=' LLogi st i c' t hen pr ob=1/ ( 1+al pha*t **gamma) ;i f _di st _=' Gamma' t hen

    do;

    d=_shape1_;k=1/ ( d*d) ;u=( t *exp( - l p) ) **gamma;pr ob=1- pr obgam( k*u**d, k) ;i f d l t 0 t hen pr ob=1- pr ob;

    end;dr op l p gamma al pha _di st _ _scal e_ d k u;

    r un;

    %mendpr edi ct ; (The variable_shape1_only exists for the gamma distribution)

  • 7/30/2019 Survival Part 5

    22/36

    22

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    %i ncl ude "d: \ Char l i e\ SI GSTAT\ Sur vi val Model s\ pr edi ct . sas" ;

    t i t l e "Pr edi cti ng 30- week sur vi val pr obabi l i t i es";proc lifereg dat a=sur vi val . r eci d out est =a;model week*ar r est ( 0) =f i n age r ace wexp mar paro pr i o

    / di st =wei bul l ;out put out =b p=medi an xbet a=l p;

    run;

    %predict( out est =a, out =b, xbet a=l p, t i me=30)

    t i t l e2 "Summar y st at i st i cs f or 30- week pr edi ct ed sur vi val pr obabi l i t i es";proc means dat a=_pr ed_;

    var pr ob;run;

    t i t l e2 "1st 20 obser vat i ons wi t h 30- week pr edi ct ed sur vi val pr obabi l i t i es";proc print dat a=_pr ed_( obs=20) ;

    var week ar r est f i n age r ace wexp mar paro pr i o t pr ob;run;

  • 7/30/2019 Survival Part 5

    23/36

    23

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    Summary statistics for 30-week predicted survival probabilities

    The MEANS Pr ocedure

    Anal ysi s Var i abl e : prob

    N Mean St d Dev Mi ni mum Maxi mum- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -432 0. 8639191 0. 0749853 0. 3436233 0. 9831820- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  • 7/30/2019 Survival Part 5

    24/36

    24

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    1st 20 observations with 30-week predicted survival probabilities

    Obs week ar r est f i n age r ace wexp mar paro pr i o t prob

    1 20 1 0 27 1 0 0 1 3 30 0. 855792 17 1 0 18 1 0 0 1 8 30 0. 661393 25 1 0 19 0 1 0 1 13 30 0. 677604 52 0 1 23 1 1 1 1 1 30 0. 940105 52 0 0 19 0 1 0 1 3 30 0. 856846 52 0 0 24 1 1 0 0 2 30 0. 854177 23 1 0 25 1 1 1 1 0 30 0. 929038 52 0 1 21 1 1 0 1 4 30 0. 868119 52 0 0 22 1 0 0 0 6 30 0. 74306

    10 52 0 0 20 1 1 0 0 0 30 0. 8481611 52 0 1 26 1 0 0 1 3 30 0. 8935612 52 0 0 40 1 1 0 0 2 30 0. 9387813 37 1 0 17 1 1 0 1 5 30 0. 7515114 52 0 0 37 1 1 0 0 2 30 0. 9277615 25 1 0 20 1 0 0 1 3 30 0. 7926716 46 1 1 22 1 1 0 1 2 30 0. 8949017 28 1 0 19 1 0 0 0 7 30 0. 6793418 52 0 0 20 1 0 0 0 2 30 0. 7944819 52 0 0 25 1 0 0 1 12 30 0. 6696520 52 0 0 24 0 1 0 1 1 30 0. 90800

  • 7/30/2019 Survival Part 5

    25/36

    25

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    The author provides another macro, LIFEHAZ, to plot the estimated hazard function

    appropriate for the selected model distribution.

    * - - - - - - - - - - - - - - - ;* LIFEHAZ Macro ;* - - - - - - - - - - - - - - - ;

    %macro lifehaz(outest=,out=,obsno=0,xbeta=lp);

    / ********************************************************************Macr o LI FEHAZ pl ot s t he hazar d f unct i on f or a model f i t t ed byPROC LI FEREG. I n t he LI FEREG procedur e, you must speci f y OUTEST=name1i n t he PROC st at ement . You must al so use t he OUTPUT st at ement wi t hOUT=name2 and XBETA=name3. By def aul t , t he hazar d i s pl ot t ed f or t hemean val ue of XBETA ( t he l i near pr edi ct or ) . I f you want a pl ot f or a

    speci f i c observat i on, you must speci f y t he observat i on number( OBSNO) when you i nvoke t he macr o. The macr o i s i nvoked as f ol l ows:

    %l i f ehaz( out est =name1, out =name2, xbet a=name3, obsno=1) ;

    Aut hor : Paul D. Al l i son, U. of Pennsyl vani a, al l i son@ssc. upenn. edu.

    ( edi t ed: 10/ 25/ 2007)

    ********************************************************************/

  • 7/30/2019 Survival Part 5

    26/36

    26

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    dat a;set &out est ;cal l symput ( ' t i me' , _NAME_) ;

    r un;proc means dat a=&out nopr i nt ;

    var &t i me &xbet a;out put out =_c_ mi n( &t i me) =mi n max( &t i me) =max mean( &xbet a) =mean;

    r un;dat a;

    set &out est ;

    cal l symput ( ' model ' , _di st _) ;s=_scal e_;*d=_shape1_;

    _y_=&obsno;set _c_ ( keep=mi n max mean) ;i f _ y_=0 t hen m=mean;

    el se do;set &out ( keep=&xbet a) poi nt =_y_;m=&xbet a;

    end;i nc=( max- mi n) / 300;g=1/ s;al ph=exp( - m*g) ;

  • 7/30/2019 Survival Part 5

    27/36

    27

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    i f _di st _=' LNORMAL' t hen do;do t =mi n t o max by i nc;z=( l og( t ) - m) / s;f =exp( - z*z/ 2) / ( t * s*sq r t ( 2*3.14159) ) ;

    Sur v=1- pr obnor m( z) ;h=f / Sur v;out put ;end;

    end;el se i f _di st _=' Gamma' t hen do;

    *d=_shape1_;k=1/ ( d*d) ;do t =mi n t o max by i nc;u=( t *exp( - m) ) ** ( 1/ s ) ;f =abs( d) *( k*u**d) **k*exp( - k*u**d) / ( s*gamma( k) *t ) ;Sur v=1- pr obgam( k*u**d, k) ;i f d l t 0 t hen Sur v=1- Sur v;

    h=f / Sur v;out put ;end;

    end;el se i f _di st _=' Wei bul l ' or _di st _=' Exponent i al ' t hen do;

    do t =mi n t o max by i nc;h=g*al ph*t ** ( g- 1) ;out put ;end;

    end;

  • 7/30/2019 Survival Part 5

    28/36

    28

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

    el se i f _di st _=' LLogi st i c' t hen do;do t =mi n t o max by i nc;h=g*al ph*t ** ( g- 1) / ( 1+al ph*t **g) ;out put ;

    end;end;el se put ' ERROR: DI STRI BUTI ON NOT FI TTED BY LI FEREG' ;r un;pr oc gpl ot ;

    pl ot h*t / haxi s=axi s2 vaxi s=axi s1 vzer o;

    symbol 1 i =j oi n v=none c=bl ack;axi s1 l abel =( f =t i t al i c angl e=90 ' Hazar d' ) ;axi s2 l abel =( f =t i t al i c j ust i f y=c ' t i me' f =t i t al i c j ust i f y=c "&model ") ;

    r un; qui t ;%mendl i f ehaz;

    %include "d:\Charlie\SIGSTAT\Survival Models\lifehaz.sas";title "Graph of Estimated Hazard Function for the Recidivism Data";

    title2 "Estimated Parametric Model is Weibull";

    %lifehaz(outest=a, out=b, xbeta=lp)

  • 7/30/2019 Survival Part 5

    29/36

    29

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: Generating Predictions and Hazard Functions

  • 7/30/2019 Survival Part 5

    30/36

    30

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: The Piecewise Exponential Model

    All the parametric models considered so far assume a smooth, relatively simple

    function of time.

    The Cox

    model (estimated with PROC PHREG) makes no such assumptions.

    The cost for this flexibility is not being able to test the shape of the hazard function.

    A compromise to introduce some flexibility into a parametric survival model is

    the piecewise exponential model.

    To some extent this model incorporates some time-varying covariates, namely

    the intercept is allowed to vary over time.

    Some preliminary data manipulation

    is necessary with the existing data.

  • 7/30/2019 Survival Part 5

    31/36

    31

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG: The Piecewise Exponential Model

    Basic idea:

    Divide the time scale into intervals

    Assume the hazard is constant within each interval, but can vary across intervals.

    ( ) ( )

    0 1 0

    -1

    Let , ,..., be the endpoints for the intervals with 0 and .

    The in the interval [ , ) is assumed to be: ( )

    or log ( ) where log .

    The choice of intervals i

    J J

    j j j j

    j j j j

    a a a J a a

    a a h t e

    h t

    = =

    =

    = + =

    xhazard

    x

    s arbitrary (implying some ad hoc ness for the model).

  • 7/30/2019 Survival Part 5

    32/36

    32

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: The Piecewise Exponential Model

    As an example, consider the recidivism

    data where a different intercept is allowed

    for the log hazard for each quarter of the year.

    The 52-week year is divided into 4 13-week quarters and a separate observation is

    created for each subject for any quarter they are still at risk,

    i.e., havent been

    arrested yet by the beginning of that quarter.

    So four records are created for any subject not arrested by the beginning of the

    fourth quarter, three records for those not arrested by the beginning of the third

    quarter, etc..

    The recidivism data is easier than most survival datasets since all censoring takes

    place at the end of the dataset in the fourth quarter. Otherwise

    the code below

    would be more complicated in that it would have to check within each quarter

    whether or not an observation is censored or not in order to correctly define

    the censoring variable.

  • 7/30/2019 Survival Part 5

    33/36

    33

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: The Piecewise Exponential Model

    data quar t er ;set sur vi val . r eci d;

    quar t er =cei l ( week/ 13) ;do j =1 t o quar t er ;

    t i me=13;event =0;

    i f j =quar t er and ar r est =1 t hen do;event =1;t i me=week- 13*(quarter- 1) ;

    end;out put ;

    end;run;

    Note that the variable t i me now represents the number of weeks within each quarter

    that the subject is either at risk or has been arrested (i.e., the event has occurred).

  • 7/30/2019 Survival Part 5

    34/36

    34

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: The Piecewise Exponential Model

    t i t l e "Est i mat i on of a pi ecewi se exponent i al model " ;proc lifereg dat a=quar t er ;

    cl ass j ;model t i me*event ( 0) =f i n age r ace wexp mar par o pr i o j

    / di st =exponent i al covb;run;

    Type I I I Anal ysi s of Ef f ect s

    Wal dEf f ect DF Chi - Squar e Pr > Chi Sq

    f i n 1 3. 8895 0. 0486

    age 1 6. 7348 0. 0095r ace 1 1. 0302 0. 3101wexp 1 0. 4924 0. 4828mar 1 1. 2869 0. 2566paro 1 0. 1826 0. 6692pr i o 1 10. 0699 0. 0015j 3 8.6954 0.0336

  • 7/30/2019 Survival Part 5

    35/36

    35

    Chapter 4: Estimating Parametric Regression Models with

    PROC LIFEREG: The Piecewise Exponential Model

    Analysis of Parameter Estimates

    St andard 95% Conf i dence Chi -Par amet er DF Est i mate Er r or Li mi t s Squar e Pr > Chi Sq

    I nt ercept 1 3. 7226 0. 6082 2. 5307 4. 9146 37. 47

  • 7/30/2019 Survival Part 5

    36/36

    36

    Chapter 4: Estimating Parametric Regression Models

    with PROC LIFEREG: The Piecewise Exponential Model

    Recall the estimates the model log( ) so that a positive

    parameter estimate implies a longer survival time for subject .

    A longer survival time corresponds to a lower hazard and the

    i i iT x

    i

    = +LIFEREG

    sign of the coefficient

    must be reversed to interpret the impact of that variable on the hazard function at .

    Thus, an significant estimate of 0.8202 for the first quarter effect implies that, relati

    iT

    ve

    to the fourth quarter, there is less hazard for arrest in the first quarter.

    The second and third quarter effects are also positive, but insignificant.