Skip to main content
. Author manuscript; available in PMC: 2011 Feb 10.
Published in final edited form as: Stat Med. 2010 Feb 10;29(3):371–381. doi: 10.1002/sim.3797
# read data into the table
×<- read.table("C:/analysis_dataset.txt",header=T,sep="\t")
# assign variable names
ftime <- x$years # follow-up time to censor, death, or NH
fstatus <- x$fstatus # status: 0=censor, 1=NH, 2=Death
pat_age <- x$pat_age # patient age
pat_inc <- x$log_pat_income # log patient income
pat_health <- x$pat_health # patient health
gender <- x$pat_gender # patient gender: female = 0 male = 1
freq <- x$freq_mb # freq of M & B problems
gds5 <- x$gds5 # moderate dementia = 1, 0 otherwise
gds6 <- x$gds6 # severe dementia = 1, 0 otherwise
age <- x$caregiver_age # caregiver age
c_hlth <- x$caregiver_health # caregiver health
sat <- x$satisfaction # satisfaction with support
react <- x$reaction # reaction to M & B problems
dep <- x$depression # depression scale
burden <- x$burden # caregiver burden
entry <- x$entry_year # year of study entry
tx <- x$group # group: 0=usual, 1=intensive
# assign labels 0='usual', 1='intensive'
tx_lab <- factor(tx,label=c('usual tmt','intensive'))
# assign labels 0='censor',1='NH',2='Death'
fstatf <- factor(fstatus,label=c('censor','NH','Death'))
# get the CIFs for each intervention group
x <- cuminc(ftime,fstatf,tx_lab,cencode='censor')
plot.cuminc(x,main="CIFs",xlab="Years",ylab="Probability",lty=1, lwd=2, color=1:6)
# multiple covariate analysis for proportional subdistribution hazards
y <- crr(ftime, fstatf, cov1=cbind(pat_age, pat_inc, pat_health, gender, freq, gds5, gds6,
+ age, c_hlth, sat, react, dep, burden, entry, tx_lab), failcode='NH', cencode='censor')
# produce the estimated cumulative incidence function for a male Alzheimer’s patient
# with moderate dementia (excellent health vs poor health) with caregiver receiving the
# intensive support. This patient is assumed to be average with respect to the other
# covariates and enters the study in year 4.
y.plot <- predict.crr(y,cov1=rbind(cbind(74, 3.6, 1, 1, 44, 1, 0, 71, 2, 4, 24, 10, 36, 4,
+ 1),cbind(74, 3.6, 4, 1, 44, 1, 0, 71, 2, 4, 24, 10, 36, 4, 1)))
plot(y.plot,ylim=c(0,1),xlab="Years",ylab="Probability")
# produce the estimated cumulative incidence function without covariate adjustment
z <- crr(ftime, fstatf, cov1=cbind(tx_lab), failcode='NH', cencode='censor')
z.plot <- predict.crr(z,cov1=c(0,1))
plot(z.plot,ylim=c(0,1),xlab="Years",ylab="Probability")
SAS code for Cox Proportional Hazards Models
* This code conducts cause-specific hazards analysis in SAS;
* treatment effect only;
proc phreg data=new;
    model years*fstatus(0,2) = group/ risklimits;
    title 'cause specific hazards for NH placement - treatment effect only';
run; quit;
proc phreg data=new;
    model years*fstatus(0,1) = group/ risklimits;
    title 'cause specific hazards for death - treatment effect only';
run; quit;
* treatment effect with covariates;
proc phreg data=new;
    model years*fstatus(0,2) = pat_age log_pat_income pat_health pat_gender freq_mb gds5 gds6 caregiver_age caregiver_health satisfaction reaction depression burden entry_year group / risklimits;
    title 'cause specific hazards for NH placement ';
run; quit;
proc phreg data=new;
    model years*fstatus(0,1) = pat_age log_pat_income pat_health pat_gender freq_mb gds5 gds6 caregiver_age caregiver_health satisfaction reaction depression burden entry_year group / risklimits;
    title 'cause specific hazards for death ';
run; quit;