You are given a data set in the file \"ass4.csv\". It contains the following var
ID: 3154761 • Letter: Y
Question
You are given a data set in the file "ass4.csv". It contains the following variables:
file: https://onedrive.live.com/redir?resid=A38CBC2C2BA5DFB4!5240&authkey=!APmtzZdNJpEsEkg&ithint=file%2ccsv
Nursing home assignment (1: receive treatment, 0: control)
Gender (1: male, 0: female)
Use 123457 as the seed number to generate a sample of size 1000 and use this
sample to model the home nursing home duration times, measured by days, as
a function of patient characteristics.
Nursing home assignment (1: receive treatment, 0: control)
genderGender (1: male, 0: female)
marstat Marital Status (1: married, 0: not married) hlstat Health status (2: second best, 5: worst) cens Censoring indicator (1:censored, 0: discharged)Explanation / Answer
When the data is given in complete sense, the Cox proportional hazards model is fit on the ass4.csv file.
> tt <- read.csv("clipboard",header=TRUE,sep=" ")
> head(tt)
lstay age trt gender marstat histat cens
1 37 86 1 0 0 2 0
2 61 77 1 0 0 4 0
3 1084 75 1 0 0 3 1
4 1092 77 1 0 1 2 1
5 23 86 1 0 0 4 0
6 1091 71 1 1 0 3 1
> library(survival)
> tt$trt <- as.character(trt)
Error: object 'trt' not found
> tt$trt <- as.character(tt$trt)
> tt$gender <- as.character(tt$gender)
> tt$marstat <- as.character(tt$marstat)
> tt$histat <- as.character(tt$histat)
> tt_surv <- coxph(Surv(lstay,cens==1)~age+trt+gender+marstat+histat,data=tt)
> summary(tt_surv)
Call:
coxph(formula = Surv(lstay, cens == 1) ~ age + trt + gender +
marstat + histat, data = tt)
n= 1601, number of events= 322
coef exp(coef) se(coef) z Pr(>|z|)
age -0.001504 0.998497 0.008202 -0.183 0.855
trt1 -6.697327 0.001234 1.019454 -6.570 5.05e-11 ***
gender1 -0.038227 0.962495 0.160534 -0.238 0.812
marstat1 -0.042354 0.958531 0.198529 -0.213 0.831
histat3 0.183673 1.201623 0.145978 1.258 0.208
histat4 0.234321 1.264050 0.157696 1.486 0.137
histat5 0.241276 1.272872 0.280479 0.860 0.390
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
exp(coef) exp(-coef) lower .95 upper .95
age 0.998497 1.0015 0.9825743 1.014678
trt1 0.001234 810.2373 0.0001674 0.009102
gender1 0.962495 1.0390 0.7026695 1.318395
marstat1 0.958531 1.0433 0.6495577 1.414471
histat3 1.201623 0.8322 0.9026331 1.599650
histat4 1.264050 0.7911 0.9279686 1.721850
histat5 1.272872 0.7856 0.7345820 2.205611
Concordance= 0.77 (se = 0.019 )
Rsquare= 0.251 (max possible= 0.863 )
Likelihood ratio test= 462.9 on 7 df, p=0
Wald test = 45.58 on 7 df, p=1.054e-07
Score (logrank) test = 387.3 on 7 df, p=0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.