Parametric resampling scheme for a parametric regression model
Source:R/ResamplingSchemes.R
resample_param.Rd
Generate a new, resampled dataset of the same shape as data
following the given model. The covariates are kept the same and the
response variables are drawn according to model$sample_yx()
.
Arguments
- data
data.frame()
with columns x and y containing the original data- model
ParamRegrModel to use for the resampling
Value
data.frame()
with columns x and y containing the resampled data
Examples
# 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)
data <- dplyr::tibble(x = x, y = y)
# Fit the model to the data
model$fit(data, params_init = params, inplace = TRUE)
# Resample from the model given data
resample_param(data, model)
#> # A tibble: 10 × 2
#> x[,1] [,2] y
#> <dbl> <dbl> <dbl>
#> 1 0.387 1 3.50
#> 2 0.0119 0 1.36
#> 3 0.233 0 -0.314
#> 4 0.0979 0 0.0419
#> 5 0.700 0 1.40
#> 6 0.214 1 2.41
#> 7 0.277 1 2.97
#> 8 0.747 1 4.72
#> 9 0.118 1 3.15
#> 10 0.296 0 -0.335