[R] survexp with weights
Mike Harwood
harwood262 at gmail.com
Wed Apr 20 18:03:47 CEST 2011
Hello,
I probably have a syntax error in trying to generate an expected
survival curve from a weighted cox model, but I can't see it. I used
the help sample code to generate a weighted model, with the addition
of a "weights=albumin" argument (I only chose albumin because it had
no missing values, not because of any real relevance). Below are my
code with the resulting error messages. Thanks in advance!
> pfit <- coxph(Surv(time,status>0) ~ trt + log(bili) + log(protime) + age +
+ + platelet, data=pbc
+ )
>
> pfit
Call:
coxph(formula = Surv(time, status > 0) ~ trt + log(bili) +
log(protime) +
age + +platelet, data = pbc)
coef exp(coef) se(coef) z p
trt -0.000624 0.999 0.17304 -0.00360 1.0000
log(bili) 0.985497 2.679 0.08949 11.01262 0.0000
log(protime) 2.794001 16.346 0.95289 2.93215 0.0034
age 0.020590 1.021 0.00805 2.55666 0.0110
platelet -0.001699 0.998 0.00085 -2.00130 0.0450
Likelihood ratio test=164 on 5 df, p=0 n= 308, number of events=
143
(110 observations deleted due to missingness)
>
> plot(survfit(Surv(time, status>0) ~ trt, data=pbc))
> lines(survexp( ~ trt, ratetable=pfit, data=pbc), col='purple')
>
> pfit.wtd <- coxph(Surv(time,status>0) ~ trt + log(bili) + log(protime) + age +
+ + platelet, weights=albumin, data=pbc
+ )
>
> pfit.wtd
Call:
coxph(formula = Surv(time, status > 0) ~ trt + log(bili) +
log(protime) +
age + +platelet, data = pbc, weights = albumin)
coef exp(coef) se(coef) z p
trt -0.01354 0.987 0.094204 -0.144 8.9e-01
log(bili) 0.99282 2.699 0.048690 20.391 0.0e+00
log(protime) 2.54136 12.697 0.525797 4.833 1.3e-06
age 0.01913 1.019 0.004398 4.350 1.4e-05
platelet -0.00165 0.998 0.000462 -3.578 3.5e-04
Likelihood ratio test=535 on 5 df, p=0 n= 308, number of events=
143
(110 observations deleted due to missingness)
> plot(survfit(Surv(time, status>0) ~ trt, data=pbc))
> lines(survexp( ~ trt, ratetable=pfit.wtd, data=pbc), col='purple')
Error in eval(expr, envir, enclos) : object 'albumin' not found
> lines(survexp( ~ trt, ratetable=pfit.wtd, weights=albumin, data=pbc), col='purple')
Error in eval(expr, envir, enclos) : object 'albumin' not found
In addition: Warning message:
In survexp(~trt, ratetable = pfit.wtd, weights = albumin, data =
pbc) :
Weights ignored
> lines(survexp( ~ trt, ratetable=pfit.wtd, weights=pbc$albumin, data=pbc), col='purple')
Error in eval(expr, envir, enclos) : object 'albumin' not found
In addition: Warning message:
In survexp(~trt, ratetable = pfit.wtd, weights = pbc$albumin, data =
pbc) :
Weights ignored
>
More information about the R-help
mailing list