inst/tests/cph3.r

## Explore width of confidence intervals, checking that it is zero
## at the median of the single predictor

require(rms)
require(survival)
set.seed(1)
a <- 1 : 100
dd <- datadist(a); options(datadist='dd')
S <- Surv(a + 100 * runif(100))
f <- cph(S ~ a)
ab <- list(v = median(a))
plot(Predict(f), abline=ab)
f <- cph(S ~ pol(a, 2))
plot(Predict(f), abline=ab)
plot(Predict(f, ref.zero=TRUE), abline=ab)

b <- sample(1:100) + 100
dd <- datadist(a, b)
f <- cph(S ~ pol(a, 2) + b)
plot(Predict(f), abline=ab)
plot(Predict(f, ref.zero=TRUE), abline=list(v=c(median(a),median(b))))

     

Try the rms package in your browser

Any scripts or data that you put into this service are public.

rms documentation built on Sept. 12, 2023, 9:07 a.m.