sim_dat {pmcalibration} | R 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 |
value of the quadratic coefficient. If specified the linear predictor is simulated as follows: |
a3 |
value of the interaction coefficient. If specified the linear predictor is simulated as follows: |
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