Learn R Programming

gofreg (version 1.0.0)

resample_param: Parametric resampling scheme for a parametric regression model

Description

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().

Usage

resample_param(data, model)

Value

data.frame() with columns x and y containing the resampled data

Arguments

data

data.frame() with columns x and y containing the original data

model

ParamRegrModel to use for the resampling

Examples

Run this code
# 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)

Run the code above in your browser using DataLab