57
SAS vs. R Competing Risk Analysis Lovedeep Gondara BC Cancer Agency

2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Embed Size (px)

Citation preview

Page 1: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

SAS vs. R

Competing Risk Analysis

Lovedeep Gondara

BC Cancer Agency

Page 2: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Introduction

To understand competing risk, lets just have

a quick look at survival analysis.

Survival Analysis is primarily used to estimate the probability of an event happening after a certain time frame in a time to event analysis and incorporates censoring.

Page 3: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

3

Censoring

Time Study end

Patient 1: Event

Patient 4: Event after

Study’s end

Patient 3: Lost to follow-up

Patient 2: Event

Patient 5: No event even

after study’s end

Page 4: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

4

Censoring

Patient Time

(days)

Event Censored

1 240 Y N

2 285 Y N

3 250 N Y

4 180 N Y

5 200 N Y

Time

Study end: 365 days

1

3

2

5

4

Page 5: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

IntroductionWe generally display the information using following two methods.

Page 6: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Introduction

KM curve

Page 7: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

IntroductionCompeting risks concern the situation where more than one cause

of failure is possible.

Page 8: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Introduction

What is Competing risk?Competing risks arise in the analysis of time-to-event data, i.e. when event of

Interest Is impossible to observe due to a different type of event occurring

before.

Eg:

If interest focuses on a specific cause of death, death from a non-disease

related cause would constitute the competing risk.

Page 9: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example: Competing Risk

Starting condition

Event

(Competing Risk)

Event of Interest

Page 10: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Introduction

Why is it important?Main Assumption of KM –

Patients who are censored have the same survival probabilities as those who

continue to be followed, But it is violated in case of competing risk.

It is well known and pointed out that in presence of competing risks, the

standard product-limit method of describing the distribution of time-to

event yields biased results.

Page 11: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

Competing events censored vs. competing events included

Page 12: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Modeling Competing Risk

We will be focusing on model proposed by

Fine and Gray, which is most common and

widely used.

Page 13: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Fitting the model

R is widely used to fit competing risk model

because of available packages that makes the

job much easier such as ‘cmprsk’ which

provides options of plotting cumulative

incidence curves and fitting a multivariate

model.

Page 14: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Fitting the model

SAS does not provide any direct method of

implementing competing risk.

%CIF can be used to estimate cumulative

incidence.

Page 15: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

Introducing %PSHREG written by

Maria Kohl

Georg Heinze Medical University of Vienna

With added options and functionality by me

Page 16: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

Fits a multivariate Fine and Gray’s competing risk model.

Macro call –

%pshreg(data=mydata, time=time_variable, cens=status_variable, varlist=X1 X2 X3);

Page 17: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

%pshreg(data=mydata, time=time_variable, cens=status_variable, varlist=X1 X2 X3);

Where

Data= Name of your SAS dataset.

Page 18: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

%pshreg(data=mydata, time=time_variable, cens=status_variable, varlist=X1 X2 X3);

Where

Time = Time variable

Page 19: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

%pshreg(data=mydata, time=time_variable, cens=status_variable, varlist=X1 X2 X3);

Where

Cens = Censoring variable with 0 for censored , 1 for event of interest and 2 for competing events.

Page 20: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

%pshreg(data=mydata, time=time_variable, cens=status_variable, varlist=X1 X2 X3);

Where

Varlist= List of variables to be used

Page 21: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

%pshreg(data=mydata, time=time_variable, cens=status_variable, failcode=1, cencode=2, varlist=X1 X2 X3);

If censoring variable not defined as

mentioned then specify –

Failcode= event of interest

Cencode= for censored observations

Page 22: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

Additional options%pshreg(data=mydata, time=time_variable,

cens=status_variable, varlist=X1 X2 X3, options=%str());

Options = Any options for PROC PHREG

Eg: options = %str(rl )

Page 23: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

Additional options

%pshreg(data=mydata, time=time_variable, cens=status_variable, varlist=X1 X2 X3, options=%str(), out=sas_data_set);

Out=User defined output dataset

Page 24: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

Additional options

%pshreg(data=mydata, time=time_variable, cens=status_variable, varlist=X1 X2 X3, options=%str(), out=sas_data_set, by=);

By = To define subsets(Same as in PHREG)

Page 25: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

Additional options

%pshreg(data=mydata, time=time_variable, cens=status_variable, varlist=X1 X2 X3, options=%str(), out=sas_data_set, by=, cuminc=1);

Cuminc=1 (Will display cumulative incidence curves for 1st variable in model) – default is 0 and code is output in log .

Page 26: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

For cumulative incidence curve -

Page 27: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

PSHREG

Similar to crr in ‘cmprsk’ package as it uses

an estimate of the survivor function to

reweight contributions to the risk sets for

failures from competing causes.

Page 28: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

Fitting a simple model using basic

parameters.

%pshreg_new(data=valung, time=time,

cens=status,varlist= Age kps duration, options=%str(rl) );

Page 29: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

%pshreg_new(data=valung, time=time, cens=status,varlist= Age kps duration, options=%str(rl) );

Page 30: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

Lets try doing same in R using ‘cmprsk’

We can not put all variables straight into the model, so lets bind them together first.

Page 31: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

Now call model statement using default parameters.

Page 32: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

Lets have a look at our results -

Page 33: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

?

Page 34: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Added Options

Class –

You can specify any class variables to be used in the model.

Ref –

Reference level can be specified for the class variable.

Page 35: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

%pshreg_new(data=valung, time=time, cens=status,varlist= Age kps duration prior, options=%str(rl), class=prior );

Page 36: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

Doing same in R

First recode the factor variable so we can use it in the model.

Or

Page 37: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

Then we can fit the model after binding the

new recoded variable in

Page 38: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

Wasn’t that hard, right?

But, what if my variable has more than two

levels –

Or

Page 39: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

Then we can try figuring out from output the

name of variables and reference level or keep

a sticky note on side to remember it all.

Page 40: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

Using backward elimination from options –

%pshreg_new(data=valung, time=time, cens=status,varlist= Age kps duration prior, options=%str(rl selection=backward), class=prior );

Page 41: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example%pshreg_new(data=valung, time=time, cens=status,varlist= Age kps duration

prior, options=%str(rl selection=backward), class=prior );

Page 42: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

Can we do it in R ? Lets try

First look at the output –

Page 43: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Example

Remove the least significant variable

Bind the remaining variables again

Run your model using new variables

Keep on repeating until you get the desired results …

Page 44: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Added Options

HR –

Specify a variable to calculate hazard ratio for that specific variable, same as Hazard ratio statement in PHREG.

Unit –

You can specify a custom unit for hazard ratio such as by 0.1, 10 etc.

Page 45: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Added options

%pshreg_new(data=valung, time=time, cens=status,varlist= Age kps duration prior, options=%str(rl selection=backward), class=prior, hr=kps, unit=10 );

Page 46: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Added Options

Sc –

For plotting scaled Schoenfeld type residuals with 95% confidence limits(to check for time dependent effects)

Page 47: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Added Options%pshreg_new(data=valung, time=time, cens=status,varlist= Age kps

duration prior, options=%str(rl selection=backward), class=prior,sc=1 );

Page 48: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Added Options

Cumvar –

A variable can be specified for which you want cumulative incidence curve for.

Med(Experimental) –

Specify med=1 to get median survival time.

Page 49: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Added Options

%pshreg_new(data=valung, time=time, cens=status,varlist= Age kps duration prior, options=%str(rl selection=backward), class=prior, cuminc=1,cumvar=prior );

Page 50: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Added optionsInternal sort option was added in case of a by

variable as previously you needed to have the

data sorted on by variable if you are using ‘by’

option.

Page 51: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Why use PSHREG

Why should you use PSHREG in SAS ?

Page 52: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Summary

Ease of use

No need to use matrix functions to bind your

variables before using in model and then trying

to figure out from output what was their order.

Page 53: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Summary

Easily specify any Class variable and reference level to be used.

Compute and plot scaled Schoenfeld type residuals to check for time dependency.

Firth correction can be applied for monotone likelihood phenomenon.

Page 54: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Summary

The phenomenon of monotone likelihood is observed in the fitting

process of a Cox model if the likelihood converges to a finite value

while at least one parameter estimate diverges to ±∞.

Page 55: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Advantages

Use all options available in PHREG (Forward Selection, Backward Elimination etc.).

In case of time dependent effects, weighted estimation can be used.

Page 56: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Download

Original macro –

http://cemsiis.meduniwien.ac.at/kb/wf/software/statistische-software/pshreg/

References –

Jason P. Fine and Robert J. Gray (A Proportional Hazards Model for the Subdistribution

of a Competing Risk)Journal of the American Statistical AssociationVol. 94, No. 446 (Jun., 1999), pp. 496-509.

Maria Kohl and Georg Heinze (A SAS Macro for Proportional and NonproportionalSubdistribution Hazards Regression for Survival Analyses with Competing Risks)

Georg Heinze, Michael Schemper (A Solution to the Problem of Monotone Likelihood in Cox Regression)

Georg Heinze, Deniela Dunker (Monotone likelihood and time dependent covariates in Cox’s model)

Page 57: 2013 Competing Risk Analysis - SAS Group Presentatio… · Main Assumption of KM ... competing risk model. Macro call ... Compute and plot scaled Schoenfeld type residuals to check

Thanks

[email protected]

Questions?