sim_dat: Simulate a binary outcome with either a quadratic...

sim_datR Documentation

Simulate a binary outcome with either a quadratic relationship or interaction

Description

Function for simulating data either with a single 'predictor' variable with a quadratic relationship with logit(p) or two predictors that interact (see references for examples).

Usage

sim_dat(N, a1, a2 = NULL, a3 = NULL)

Arguments

N

number of observations to simulate

a1

value of the intercept term (in logits). This must be provided along with either a2 or a3.

a2

value of the quadratic coefficient. If specified the linear predictor is simulated as follows: LP <- a1 + x1 + a2*x1^2 where x1 is sampled from a standard normal distribution.

a3

value of the interaction coefficient. If specified the linear predictor is simulated as follows: LP <- a1 + x1 + x2 + x1*x2*a3 where x1 and x2 are sampled from independent standard normal distributions.

Value

a simulated data set with N rows. Can be split into 'development' and 'validation' sets.

References

Austin, P. C., & Steyerberg, E. W. (2019). The Integrated Calibration Index (ICI) and related metrics for quantifying the calibration of logistic regression models. Statistics in medicine, 38(21), 4051-4065.

Rhodes, S. (2022, November 4). Using restricted cubic splines to assess the calibration of clinical prediction models: Logit transform predicted probabilities first. https://doi.org/10.31219/osf.io/4n86q

Examples

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

head(dat) # LP = linear predictor


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