View source: R/ResamplingSchemes.R
resample_param_cens | R Documentation |
Generate a new, resampled dataset of the same shape as data
following the given model. The covariates X are kept the same. Survival
times Y are drawn according to model$sample_yx()
and censoring times C
according to the KM estimator.
resample_param_cens(data, model)
data |
|
model |
ParamRegrModel to use for the resampling |
data.frame()
with columns x, z and delta containing the resampled
data
# Create an example dataset
n <- 10
x <- cbind(runif(n), rbinom(n, 1, 0.5))
model <- NormalGLM$new()
params <- list(beta = c(2, 3), sd = 1)
y <- model$sample_yx(x, params = params)
c <- rnorm(n, mean(y) * 1.2, sd(y) * 0.5)
z <- pmin(y, c)
delta <- as.numeric(y <= c)
data <- dplyr::tibble(x = x, z = z, delta = delta)
# Fit the model to the data
model$fit(data, params_init = params, inplace = TRUE, loglik = loglik_xzd)
# Resample from the model given data
resample_param_cens(data, model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.