Cox Proportional Hazards Model (part 2)

advertisement
Checking the Proportional Hazards Assumption
The basic Cox Model assumes that the hazard functions for two different levels of a
covariate are proportional for all values of t.
To see this, consider the following ratio:
h(t, x i )
=
h(t, x j )
SAS PROC PHREG can be used to formally test and graphically check the proportional
hazards assumption:
ods html;
ods graphics on;
proc phreg data=leukemia2;
model duration*censor(0)= group logwbc / ties=efron rl;
assess ph / resample;
run;
ods graphics off;
ods html close;
10
11
Checking Proportional Hazards in R
You will need to install and the package proptest from the CRAN website.
> leuk.cph= coxph(Surv(Time,Censor)~cbind(Group,logWBC),data=leukemia)
Notice that the covariates are combined into a matrix with columns equal to the terms in
the model in order to use this test.
> test1 = scoreproptest(leuk.cph,covariate=1)  Group
> print(test1)
Score process test of proportional hazards
Tested covariate: 1
Basis of smooth functions for other covariates: legendre
Dimensions for other covariates:
Covariate
2
Dimension
4
Kolmogorov--Smirnov statistic: 0.7059797,
p-value: 0.544
Cramer--von Mises statistic: 0.06814982,
p-value: 0.776
Anderson--Darling statistic: 0.4547127,
p-value: 0.678
p-values based on 1000 simulations
> plot(test1)
> test2 = scoreproptest(leuk.cph,covariate=2)  logWBC
> print(test2)
Score process test of proportional hazards
Tested covariate: 2
Basis of smooth functions for other covariates: legendre
Dimensions for other covariates:
Covariate
1
12
Dimension
4
Kolmogorov--Smirnov statistic: 0.5954771,
p-value: 0.525
Cramer--von Mises statistic: 0.0565693,
p-value: 0.8
Anderson--Darling statistic: 0.5354785,
p-value: 0.604
p-values based on 1000 simulations
> plot(test2)
> title(main="Proportional Hazards for logWBC")
An easier alternative approach
This approach uses the cox.zph function which is in survival library where the function
coxph is located. The graphics are not as good as the approach above.
> leuk.cph = coxph(Surv(Time,Censor)~Group+logWBC,data=leukemia)
> temp = cox.zph(leuk.cph)
> print(temp)
rho
chisq
p
Group2 0.00451 0.000542 0.981
logWBC 0.02764 0.034455 0.853
GLOBAL
NA 0.034529 0.983
> par(mfrow=c(2,2))
> plot(temp)
13
Plotting the Survivor Functions for Different Cohorts
A cohort is a group of patients that have the same values for a given set of covariates. For
example, in this study we could consider the cohort of patients in treatment group 1 who
had a log base 2 white blood cell count equal to 2. We might want to compare the
survivor function of this cohort to the survivor function for the cohort of patients with
the same white blood cell count in treatment group 2.
To do this in SAS, you must first create a data set containing the covariate values of
interest:
data InputVals;
input group logwbc;
datalines;
1 2
2 2
Next, add a ‘baseline’ statement to the PROC PHREG code. This will estimate the
survivor function for each cohort specified in the previous data set:
proc phreg data=leukemia2;
model duration*censor(0)= group logwbc / ties=efron rl;
baseline covariates=Inputvals out=Pred1 survival=S /
nomean;
proc print data=pred1;
run;
Finally, you can plot the survivor function for each group:
symbol1 v=dot i=steplj;
proc gplot data=pred1;
plot S*duration=group;
run;
Su r v i v o r
Func t i on
E s t i ma t e
1. 0
0. 9
0. 8
0. 7
0. 6
0. 5
0. 4
0. 3
0. 2
0. 1
0
10
20
30
dur at i on
gr oup
1
2
14
Next, consider an example which compares four cohorts: group = 1 and logwbc = 2;
group = 1 and logwbc = 4; group = 2 and logwbc = 2; group = 2 and logwbc = 4.
data InputVals;
input group logwbc;
datalines;
1 2
2 2
1 4
2 4
;
proc phreg data=leukemia2;
model duration*censor(0)= group logwbc / ties=efron rl;
baseline covariates=Inputvals out=Pred1 survival=S /
nomean;
data pred1; set pred1;
if group=1 and logwbc=2
if group=1 and logwbc=4
if group=2 and logwbc=2
if group=2 and logwbc=4
then
then
then
then
pattern=1;
pattern=2;
pattern=3;
pattern=4;
legend1 label=none
value=('group 1 wbc 2' 'group 1 wbc 4' 'group 2 wbc 2'
'group 2 wbc 4');
axis1 label=(h=1 f=swiss 'Survival Time in Months');
symbol1 i=stepljs v=square c=blue;
symbol2 i=stepljs v=diamond c=yellow;
symbol3 i=stepljs v=circle c=red;
symbol4 i=stepljs v=dot c=green;
proc gplot data=Pred1;
plot S*duration=Pattern / legend=legend1 haxis=axis1;
run;
Su r v i v o r
Func t i on
E s t i ma t e
1. 0
0. 9
0. 8
0. 7
0. 6
0. 5
0. 4
0. 3
0. 2
0. 1
0. 0
0
gr oup
10
1
wb c
2
gr oup
1
wb c
4
20
gr oup
2
wb c
2
gr oup
30
2
wb c
4
15
Plotting Survivor Curves for Different Cohorts in R
A cohort is a group of patients that have the same values for a given set of covariates.
For example, in this study we could talk about the cohort of patients who received
treatment for leukemia and had log base 2 white blood cell count equal to 2.00. We
might want to compare the survival experience of this cohort to the cohort of patients
with the same blood cell count but in the placebo group or perhaps to the cohort of
patients who received treatment but had a log cell count of 4.00.
We can visualize and examine summary statistics for the survival experience of different
cohorts as follows:
> fit3 = coxph(Surv(Time,Censor)~Group + logWBC,data=leukemia)
> summary(fit3)
Call:
coxph(formula = Surv(Time, Censor) ~ Group + logWBC)
Group2
logWBC
coef exp(coef) se(coef)
z
p
1.39
4.00
0.425 3.26 1.1e-03
1.17
3.23
0.233 5.03 4.8e-07
Group2
logWBC
exp(coef) exp(-coef) lower .95 upper .95
4.00
0.25
1.74
9.2
3.23
0.31
2.05
5.1
Estimate Survivor Function S(t) for Desired Cohorts
> sf1 <survfit(fit3,newdata=list(Group=as.factor(c(1,2)),logWBC=c(2,2)))
Obtain Summary Statistics
> sf1
Call: survfit(formula = fit3, newdata = list(Group = as.factor(c(1,
2)), logWBC = c(2, 2)))
[1,]
[2,]
records n.max n.start events median 0.95LCL 0.95UCL
42
42
42
30
NA
23
NA
42
42
42
30
22
13
NA
Plot the Survivor Functions with a Legend
> plot(sf1,lty=1:2,col=c("Red","Blue"))
> legend(locator(),c("Treatment, log2WBC = 2","Placebo, log2WBC =
2"),lty=1:2,col=c("Red","Blue"))
16
Adding CI’s for S(t)
> plot(sf1,lty=1:2,col=c("Red","Blue"),conf.int=T)
> title(main="Plot of Survivor Functions for 2 Cohorts (with
CIs)",xlab="Time",ylab="S(t)")
> legend(locator(),c("Treatment, log2WBC = 2","Placebo, log2WBC =
2"),lty=1:2,col=c("Red","Blue"))
17
Examine two different cohorts
> sf2 <survfit(fit3,newdata=list(Group=as.factor(c(1,1)),logWBC=c(2,4)))
> sf2
Call: survfit(formula = fit3, newdata = list(Group = as.factor(c(1,
1)), logWBC = c(2, 4)))
[1,]
[2,]
records n.max n.start events median 0.95LCL 0.95UCL
42
42
42
30
NA
23
NA
42
42
42
30
8
6
NA
18
Examining four different cohorts
> sf3 =
survfit(fit3,newdata=list(Group=as.factor(c(1,2,1,2)),logWBC=c(2,2,4,4)))
> sf3
Call: survfit(formula = fit3, newdata = list(Group = as.factor(c(1,
2, 1, 2)), logWBC = c(2, 2, 4, 4)))
[1,]
[2,]
[3,]
[4,]
records n.max n.start events median 0.95LCL 0.95UCL
42
42
42
30
NA
23
NA
42
42
42
30
22
13
NA
42
42
42
30
8
6
NA
42
42
42
30
4
3
8
> plot(sf3,lty=1:4,col=2:5)
> legend(locator(),c("Trt,logWBC=2","Cont,logWBC=2","Trt,logWBC=4",
+ "Cont,logWBC=4"),lty=1:4,col=2:5)
> title(main="Plot of Survivor Functions for 4 Cohorts",xlab="Time",ylab="S(t)")
19
Residuals and Influence Statistics
First, we will examine two types of residuals:
1. Deviance residuals – these are used to identify potential outliers.
2. Martingale residuals – these are used to assess the functional form of continuous
predictors.
Both of these residuals can be written to a data set from PROC PHREG:
proc phreg data=leukemia2;
model duration*censor(0)= group logwbc / ties=efron rl;
assess ph var=(group logwbc) / resample;
output out=residuals resmart=mart resdev=dev;
run;
Examine a plot of the deviance residuals versus case number
data residuals; set residuals;
obs= _N_;
run;
proc gplot data=residuals;
plot dev*obs;
symbol1 value=circle c=blue;
run;
De v i a n c e
Re s i d u a l
3
2
1
0
- 1
- 2
0
10
20
30
40
50
obs
20
Assess the Functional Form of Continuous Predictors
proc loess data=residuals;
model mart=logwbc / smooth=.6;
ods output OutputStatistics=Results;
run;
goptions reset=all;
symbol1 color=black value=circle;
symbol2 color=red value=dot;
proc gplot data=Results;
plot (depvar pred)*logwbc / overlay;
run; quit;
Ma r t i n g a l e
Re s i d u a l
1
0
- 1
- 2
1
2
3
4
5
l o g wb c
Strong curvature in this plot may indicate the need to consider a different functional
form for the predictor variable.
Assessing Influence of Observations
proc phreg data=leukemia2;
model duration*censor(0)= group logwbc / ties=efron rl;
assess ph var=(group logwbc) / resample;
output out=residuals resmart=mart resdev=dev dfbeta=dgroup
dlogbwc;
run;
21
data residuals; set residuals;
obs= _N_;
run;
For any case, if |DFBETA| > 1
for small data sets or 2 n for
large data sets, then that case
can be regarded as influential.
proc gplot data=residuals;
plot (dgroup dlogbwc)*obs;
symbol1 value=circle c=blue;
run;
Di f f e r e n c e
i n
t he
p a r a me t e r
f or
l o g wb c
0. 07
0. 06
0. 05
0. 04
0. 03
0. 02
0. 01
0. 00
- 0. 01
- 0. 02
- 0. 03
- 0. 04
- 0. 05
- 0. 06
- 0. 07
- 0. 08
- 0. 09
- 0. 10
- 0. 11
- 0. 12
- 0. 13
- 0. 14
- 0. 15
- 0. 16
- 0. 17
- 0. 18
- 0. 19
0
10
20
30
40
50
obs
22
Diagnostics in R
1. Plot Deviance Residuals vs. Case Number
2. Assessing Functional Form of Continuous Predictors (Martingale Residuals vs. Xj)
3. Assessing Influence (DFBETASj vs. Case Number)
1. Plot Deviance Residuals vs. Case Number
> fit3 = coxph(Surv(Time,Censor)~Group+logWBC,data=leukemia)
> plot(resid(fit3,type="deviance"),ylab="Deviance Residuals")
> abline(h=0,lty=2,col="red")
> title(main="Deviance Residuals vs. Case Number")
> identify(resid(fit3,type="deviance"))
[1] 1 22 28
No cases truly standout here.
2. Assessing Functional Form of Continuous Terms (Martingale Residuals vs. Xj)
>
>
>
>
plot(logWBC,resid(fit3),ylab="Martingale Residuals")
title(main="Plot of Martingale Residuals vs. logWBC")
abline(h=0,col="gray")
lines(lowess(logWBC,resid(fit3)),lty=2,col="red")
Strong curvature in this plot can
indicate the need to consider a
different functional form for the
predictor.
23
3. Assessing Influence (DFBETASj vs. Case Number)
> bresid <- resid(fit3,type="dfbetas")
> plot(bresid[,1],type="h",ylab="Scaled Change in Est.
Coef",main="Group")
> plot(bresid[,2],type="h",ylab="Scaled Change in Est.
Coef",main="logWBC")
Suggested cutoffs for the DFBETAS criterion are |DFBETAj| > 1 for small data sets or
2
for large data sets. Any cases with values exceeding these cutoffs can indicate
n
problems with high or undue influence.
For both terms we have no evidence of excessive influence for our model.
24
Adding Gender to the Model
We now consider adding the following predictor:
Sex = Gender of patient {1 = male, 0 = female}
to the current model.
> fit1 <- coxph(Surv(Time,Censor)~Group+logWBC+sex,data=leukemia)
> summary(fit1)
Call:
coxph(formula = Surv(Time, Censor) ~ Group + logWBC + sex)
n= 42
Group2
logWBC
sex1
coef exp(coef) se(coef)
z
p
1.504
4.50
0.462 3.258 1.1e-03
1.166
3.21
0.233 4.997 5.8e-07
0.315
1.37
0.455 0.692 4.9e-01
Group2
logWBC
sex1
exp(coef) exp(-coef) lower .95 upper .95
4.50
0.222
1.820
11.11
3.21
0.312
2.031
5.07
1.37
0.730
0.562
3.34
Rsquare= 0.675
(max possible=
Likelihood ratio test= 47.2 on
Wald test
= 33.5 on
Score (logrank) test = 48 on 3
0.988 )
3 df,
p=3.17e-10
3 df,
p=2.48e-07
df,
p=2.11e-10
The estimated hazard ratio for males is e .315  1.37 . Thus male coronary heart disease
patients have 1.37 times the risk of death when compared to females. However, because
p=.49 we have no evidence to suggest that the sex effect is significant we really cannot
put too much stock in this result.
25
Checking the proportional hazards assumption
> cox.zph(fit1)
rho
Group2 -0.1017
logWBC
0.0595
Sex1
-0.3684
GLOBAL
NA
chisq
0.344
0.161
4.076
4.232
p
0.5578
0.6884
0.0435
0.2374
*
The p-value associated with gender is significant suggesting the proportional hazards
assumption may not be satisfied. We might consider fitting a Cox model “stratified” by
sex.
 (t | x, Sex  i)  i (t ) exp 1 X 1  ...   p X p 
~
The decreasing trend in the plot
for Sex indicates a possible
violation of the proportional
hazards assumption.
We could use the scoreproptest method from the proptest library instead.
> par(mfrow=c(2,2))
> fit1 <- coxph(Surv(Time,Censor)~cbind(Group,logWBC,sex),data=leukemia)
> test1 = scoreproptest(fit1,covariate=1)
> test1
Score process test of proportional hazards
Tested covariate: 1
Basis of smooth functions for other covariates: legendre
Dimensions for other covariates:
Covariate
2 3
Dimension
4 4
Kolmogorov--Smirnov statistic: 0.7433935,
p-value: 0.457
Cramer--von Mises statistic: 0.08234563,
p-value: 0.7
Anderson--Darling statistic: 0.5734439,
p-value: 0.534
p-values based on 1000 simulations
> plot(test1)
26
> test2 = scoreproptest(fit1,covariate=2)
> test2
Score process test of proportional hazards
Tested covariate: 2
Basis of smooth functions for other covariates: legendre
Dimensions for other covariates:
Covariate
1 3
Dimension
4 4
Kolmogorov--Smirnov statistic: 0.4062264,
p-value: 0.835
Cramer--von Mises statistic: 0.06838016,
p-value: 0.728
Anderson--Darling statistic: 0.5278619,
p-value: 0.675
p-values based on 1000 simulations
> plot(test2)
> test3 = scoreproptest(fit1,covariate=3)
> test3
Score process test of proportional hazards
Tested covariate: 3
Basis of smooth functions for other covariates: legendre
Dimensions for other covariates:
Covariate
1 2
Dimension
4 4
Kolmogorov--Smirnov statistic: 0.9274068,
p-value: 0.028
Cramer--von Mises statistic: 0.3822472,
p-value: 0.011
Anderson--Darling statistic: 1.81662,
p-value: 0.014
p-values based on 1000 simulations
> plot(test3)
> par(mfrow=c(1,1))
27
Based on the above analyses we may decide to stratify on sex. To fit a stratified Cox
model use the argument strata(variable name) in the model specification to indicate
a variable to stratify on.
> fit2 = coxph(Surv(Time,Censor)~Group+logWBC+strata(sex),data=leukemia)
> summary(fit2)
Call:
coxph(formula = Surv(Time, Censor) ~ Group + logWBC + strata(sex),
data = leukemia)
n= 42, number of events= 30
coef exp(coef) se(coef)
z Pr(>|z|)
Group2 0.9332
2.5426
0.4697 1.987
0.0469 *
logWBC 1.4085
4.0897
0.3504 4.019 5.84e-05 ***
--Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Group2
logWBC
exp(coef) exp(-coef) lower .95 upper .95
2.543
0.3933
1.013
6.384
4.090
0.2445
2.058
8.128
Concordance= 0.801 (se = 0.093 )
Rsquare= 0.513
(max possible= 0.967 )
Likelihood ratio test= 30.22 on 2 df,
Wald test
= 21.14 on 2 df,
Score (logrank) test = 28.77 on 2 df,
p=2.743e-07
p=2.572e-05
p=5.651e-07
> sf = survfit(fit2)
> sf
Call: survfit(formula = fit2)
sex=0
sex=1
records n.max n.start events median 0.95LCL 0.95UCL
22
22
22
16
12
10
NA
20
20
20
14
16
8
NA
> plot(sf,lty=1:2,col=c("red","blue"))
> legend(15,.9,c("Females","Males"),lty=1:2,col=c("red","blue"))
> title(main="Survivor Functions, Stratified by Sex",xlab="Time",ylab="S(t)")
28
> sf2 <-survfit(fit2,newdata=list(Group=c(1,2),logWBC=c(mean(logWBC),mean(logWBC))))
> summary(sf2)
Call: survfit(formula = fit2, newdata = list(Group = c(1, 2), logWBC =
c(mean(logWBC), mean(logWBC))))
sex=0
time n.risk n.event survival1 survival2
5
22
1
0.9458 8.68e-01
6
21
2
0.8317 6.26e-01
7
18
1
0.7759 5.25e-01
8
17
3
0.5745 2.44e-01
10
13
1
0.5037 1.75e-01
11
11
2
0.3651 7.72e-02
12
8
2
0.2151 2.01e-02
13
6
1
0.1506 8.12e-03
15
5
1
0.1000 2.87e-03
17
4
1
0.0611 8.18e-04
22
1
1
0.0162 2.81e-05
sex=1
time n.risk n.event survival1 survival2
1
20
2
0.969 9.22e-01
2
18
2
0.923 8.15e-01
3
16
1
0.884 7.31e-01
4
15
2
0.784 5.39e-01
5
13
1
0.715 4.26e-01
6
12
1
0.614 2.89e-01
8
11
1
0.494 1.67e-01
16
10
1
0.321 5.57e-02
22
8
1
0.140 6.74e-03
23
7
2
0.015 2.31e-05
In what order are the survival curves
computed?
> plot(sf2,lty=1:4,col=c("red","blue","brown","black"))
> legend(13,.9,c("Females,Group=1","Females,Group=2","Males,Group=1",
"Males,Group=2"),lty=1:4,col=c("red","blue","brown","black"))
> title(main="Survival by Treatment Group, Stratified by Sex")
29
Example: Time in Rehabilitation Clinic for Heroin Addicts
(Stratified Cox Model)
The variables in the file Heroin.sas include:






ID = identification number
Clinic = 1 or 2 (there were two clinics in the study)
Status = 0 if censored, 1 if departed from clinic
Prison = 1 if prison record exists, 0 otherwise
Dose = maximum methadone dose
Time = time to censorship or departure from clinic
First, let’s consider fitting a model which includes clinic, prison, and dose:
ods html;
ods graphics on;
proc phreg data=heroin;
model time*status(0)= clinic prison dose / ties=efron rl;
assess ph var=(clinic prison dose) / resample;
run;
ods graphics off;
ods html close;
30
31
Clearly, the proportional hazards assumption is not reasonable for clinic. This is often
the case with multi-center studies in which the baseline hazards may be location specific.
When this is an issue, we can use a stratified Cox model which will allow for different
baseline hazards for the various levels of the stratification variable.
proc phreg data=heroin;
model time*status(0)= prison dose / ties=efron rl;
strata clinic;
run;
32
Analysis of Heroin Addict Data in R
Variables in this data file:
 Id – identification number (NEVER USE THIS AS A COVARIATE!)
 Clinic – two clinic study (1 or 2)
 Status – 0 = censored, 1 = departed from clinic
 Prison – indicator of prison record (1 = yes, 0 = no)
 Time – days spent in clinic
There is often times a site difference in multi-center studies that potentially make the
proportional hazards assumption untenable, i.e. the baseline hazards may be location
specific. When this is an issue we can use a stratified Cox model which will allow for
different baseline hazards for the levels of the stratification variable.
> attach(Heroin)
> names(Heroin)
[1] "id"
"Clinic" "Status" "Time"
"Prison" "Dose"
> fit1 <- coxph(Surv(Time,Status)~Clinic+Prison+Dose)
> summary(fit1)
Call:
coxph(formula = Surv(Time, Status) ~ Clinic + Prison + Dose)
n= 238
coef exp(coef) se(coef)
z
p
Clinic -1.0098
0.364 0.21488 -4.70 2.6e-06
Prison 0.3265
1.386 0.16722 1.95 5.1e-02
Dose
-0.0354
0.965 0.00638 -5.54 2.9e-08
Clinic
Prison
Dose
exp(coef) exp(-coef) lower .95 upper .95
0.364
2.745
0.239
0.555
1.386
0.721
0.999
1.924
0.965
1.036
0.953
0.977
Rsquare= 0.238
(max possible=
Likelihood ratio test= 64.6 on
Wald test
= 54.1 on
Score (logrank) test = 56.3 on
> cox.zph(fit1)
rho chisq
Clinic -0.2578 11.185
Prison -0.0382 0.220
Dose
0.0724 0.700
GLOBAL
NA 12.616
0.997 )
3 df,
p=6.23e-14
3 df,
p=1.06e-11
3 df,
p=3.6e-12
p
0.000824 ***
0.639324
0.402755
0.005546
33
There is a definite trend in
the plot for Clinic which
indicates the need to stratify
on clinic.
> fit2 <- coxph(Surv(Time,Status)~Prison+Dose+strata(Clinic))
> summary(fit2)
Call:
coxph(formula = Surv(Time, Status) ~ Prison + Dose + strata(Clinic))
n= 238
coef exp(coef) se(coef)
z
p
Prison 0.3896
1.476 0.16893 2.31 2.1e-02
Dose
-0.0351
0.965 0.00646 -5.43 5.6e-08
Prison
Dose
exp(coef) exp(-coef) lower .95 upper .95
1.476
0.677
1.060
2.056
0.965
1.036
0.953
0.978
Rsquare= 0.133
(max possible= 0.994 )
Likelihood ratio test= 33.9 on 2 df,
p=4.32e-08
Wald test
= 32.7 on 2 df,
p=8.1e-08
Score (logrank) test = 33.3 on 2 df,
p=5.77e-08
> fit2
Call:
coxph(formula = Surv(Time, Status) ~ Prison + Dose + strata(Clinic))
coef exp(coef) se(coef)
z
p
Prison 0.3896
1.476 0.16893 2.31 2.1e-02
Dose
-0.0351
0.965 0.00646 -5.43 5.6e-08
Likelihood ratio test=33.9
on 2 df, p=4.32e-08
n= 238
34
> plot(survfit(fit2),lty=1:2,col=c("red","blue"))
> survfit(fit2)
Call: survfit.coxph(object = fit2)
n events rmean se(rmean) median 0.95LCL 0.95UCL
Clinic=1 162
122
434
22.0
434
358
517
Clinic=2 74
28
624
38.1
878
661
Inf
> legend(500,.9,c("Clinic 1","Clinic 2"),lty=1:2,col=c("red","blue"))
> title(main="Survival Time, Stratified by Clinic")
It is possible that the effects of dose and prison record are also dependent on the clinic,
i.e. there is an interaction between clinic and these covariates. To check this assumption
we can fit a stratified model which allows the estimated coefficients for prison and dose
to be strata dependent. This can be done in two ways:
> fit3 <- coxph(Surv(Time,Status)~(Prison+Dose)*strata(Clinic))
> summary(fit3)
Call:
coxph(formula = Surv(Time, Status) ~ (Prison + Dose) * strata(Clinic))
n= 238
coef exp(coef) se(coef)
z
p
Prison
0.50283
1.653 0.18871 2.6646 7.7e-03
Dose
-0.03580
0.965 0.00774 -4.6260 3.7e-06
Prison:strata(Clinic)Clinic=2 -0.58288
0.558 0.42813 -1.3615 1.7e-01
Dose:strata(Clinic)Clinic=2
-0.00115
0.999 0.01457 -0.0789 9.4e-01
Prison
Dose
Prison:strata(Clinic)Clinic=2
Dose:strata(Clinic)Clinic=2
exp(coef) exp(-coef) lower .95 upper .95
1.653
0.605
1.142
2.39
0.965
1.036
0.950
0.98
0.558
1.791
0.241
1.29
0.999
1.001
0.971
1.03
Rsquare= 0.14
(max possible= 0.994 )
Likelihood ratio test= 35.8 on 4 df,
Wald test
= 34.1 on 4 df,
Score (logrank) test = 35 on 4 df,
p=3.22e-07
p=7.18e-07
p=4.71e-07
35
> anova(fit2,fit3,test="Chi")  Conducts the General Chi-square Test to compare these models
Analysis of Deviance Table
Model 1: Surv(Time, Status) ~ Prison + Dose + strata(Clinic)
Model 2: Surv(Time, Status) ~ Prison + Dose + strata(Clinic) + Prison:strata(Clinic) +
Dose:strata(Clinic)
Resid. Df Resid. Dev Df Deviance P(>|Chi|)
1
236
1195.03
2
234
1193.17
2
1.86
0.39
> fit4 <- coxph(Surv(Time,Status)~Prison+Dose+Prison:Clinic+
Dose:Clinic + strata(Clinic))
> summary(fit4)
Call:
coxph(formula = Surv(Time, Status) ~ Prison + Dose + Prison:Clinic +
Dose:Clinic + strata(Clinic))
n= 238
coef exp(coef) se(coef)
z
p
Prison
1.08571
2.962
0.5386 2.0157 0.044
Dose
-0.03465
0.966
0.0198 -1.7502 0.080
Prison:Clinic -0.58288
0.558
0.4281 -1.3615 0.170
Dose:Clinic
-0.00115
0.999
0.0146 -0.0789 0.940
Prison
Dose
Prison:Clinic
Dose:Clinic
exp(coef) exp(-coef) lower .95 upper .95
2.962
0.338
1.030
8.51
0.966
1.035
0.929
1.00
0.558
1.791
0.241
1.29
0.999
1.001
0.971
1.03
Rsquare= 0.14
(max possible= 0.994 )
Likelihood ratio test= 35.8 on 4 df,
p=3.22e-07
Wald test
= 34.1 on 4 df,
p=7.18e-07
Score (logrank) test = 35 on 4 df,
p=4.71e-07
> anova(fit2,fit4,test="Chi")
Analysis of Deviance Table
Model 1: Surv(Time, Status) ~ Prison + Dose + strata(Clinic)
Model 2: Surv(Time, Status) ~ Prison + Dose + strata(Clinic) + Prison:Clinic +
Dose:Clinic
Resid. Df Resid. Dev Df Deviance P(>|Chi|)
1
236
1195.03
2
234
1193.17
2
1.86
0.39
The need for the interaction model is not supported by the General Chi-square Test for
comparing nested models (p = .39).
36
Plotting Survivor Functions for Prison and Clinic
> sf2 = survfit(fit2,newdata=list(Prison=as.factor(c(0,1)),
Dose=c(mean(Dose),mean(Dose))))
> plot(sf2,lty=1:4,col=2:5)
> legend(locator(),legend=c("No Prison, Clinic1","Prison, Clinic 1",
"No Prison, Clinic 2","Prison, Clinic 2"),lty=1:4,col=2:5)
Note: The survfit command cycles through the covariates in order then the strata!
> title(main="Plot of Prison Effect with Clinic Strata",xlab="Days",ylab="S(t)")
37
Download