gam_cal: fits a calibration curve via gam

View source: R/gam_cal.R

gam_calR Documentation

fits a calibration curve via gam

Description

fits a calibration curve via gam

Usage

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

Arguments

y

binary or a time-to-event (Surv) outcome. For the former family = binomial(link="logit") and for the latter family = mgcv::cox.ph().

p

predicted probabilities

x

predictor (could be transformation of p)

xp

values for plotting (same scale as x)

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

...

additional arguments for mgcv::gam and mgcv::s

Value

list of class gam_cal

Examples

library(pmcalibration)
# simulate some data
n <- 500
dat <- sim_dat(N = n, a1 = .5, a3 = .2)
head(dat)
# predictions
p <- with(dat, invlogit(.5 + x1 + x2 + x1*x2*.1))

gam_cal(y = dat$y, p = p, x = p, xp = NULL, k = 20, method="REML")

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