Open ggkuhnle opened 5 years ago
The 'fun' argument in Predict does not always work with cph - especially when giving a variable. Example from the cph vignette:
n <- 1000 set.seed(731) age <- 50 + 12rnorm(n) label(age) <- "Age" sex <- factor(sample(c('Male','Female'), n, rep=TRUE, prob=c(.6, .4))) cens <- 15runif(n) h <- .02exp(.04(age-50)+.8*(sex=='Female')) dt <- -log(runif(n))/h label(dt) <- 'Follow-up Time' e <- ifelse(dt <= cens,1,0) dt <- pmin(dt, cens) units(dt) <- "Year" dd <- datadist(age, sex) options(datadist='dd') S <- Surv(dt,e)
f <- cph(S ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
Predict(f, fun=exp) - calculates HR Predict(f, age, fun=exp) - does not calculate HR
The 'fun' argument in Predict does not always work with cph - especially when giving a variable. Example from the cph vignette:
n <- 1000 set.seed(731) age <- 50 + 12rnorm(n) label(age) <- "Age" sex <- factor(sample(c('Male','Female'), n, rep=TRUE, prob=c(.6, .4))) cens <- 15runif(n) h <- .02exp(.04(age-50)+.8*(sex=='Female')) dt <- -log(runif(n))/h label(dt) <- 'Follow-up Time' e <- ifelse(dt <= cens,1,0) dt <- pmin(dt, cens) units(dt) <- "Year" dd <- datadist(age, sex) options(datadist='dd') S <- Surv(dt,e)
f <- cph(S ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
Predict(f, fun=exp) - calculates HR Predict(f, age, fun=exp) - does not calculate HR