glm_cal: fits a calibration curve via glm or Cox proportional hazards...

View source: R/glm_cal.R

glm_calR Documentation

fits a calibration curve via glm or Cox proportional hazards model

Description

fits a calibration curve via glm or Cox proportional hazards model

Usage

glm_cal(
  y,
  p,
  x,
  xp,
  smooth,
  time = NULL,
  save_data = TRUE,
  save_mod = TRUE,
  pw = FALSE,
  ...
)

Arguments

y

binary or a time-to-event (Surv) outcome. Former is fit via glm and latter is fit via survival::coxph.

p

predicted probabilities

x

predictor (could be transformation of p)

xp

values for plotting (same scale as x)

smooth

'rcs', 'ns', 'bs', or 'none'

time

time to calculate survival probabilities at (only relevant if y is a Surv object)

save_data

whether to save the data elements in the returned object

save_mod

whether to save the model in the returned object

pw

save pointwise standard errors for plotting

Value

list of class glm_cal

Examples

library(pmcalibration)
# simulate some data
n <- 500
dat <- sim_dat(N = n, a1 = .5, a3 = .2)

# predictions
p <- with(dat, invlogit(.5 + x1 + x2 + x1*x2*.1))

glm_cal(y = dat$y, p = p, x = p, xp = NULL, smooth="ns", df=5)

pmcalibration documentation built on Sept. 8, 2023, 5:10 p.m.