glmnet_sampler: Sample from a 'Glmnet' Package Model

View source: R/estimators.R

glmnet_samplerR Documentation

Sample from a 'Glmnet' Package Model

Description

This assumes a continuous response, so that the out-of-sample MSE can be used to estimate the outcome variability sigma.

Usage

glmnet_sampler(fits, newdata = NULL, indices = NULL, lambda_ix = 1, ...)

Arguments

fits

The fitted 'glmnet' package model model from which to draw samples.

newdata

A data.frame containing new inputs from which to sample responses. If NULL, defaults to the data used to estimate fit.

indices

The coordinates of the response from which to draw samples.

lambda_ix

A regularization strength parameter used to maintain consistency with estimation. Not used during sampling.

...

Additional parameters to pass to predict.glmnet

Value

y_star A data.frame of samples y associated with the new inputs.

Examples

m <- glmnet_model()
fit <- estimator(m)(mpg ~ hp + wt, data = mtcars)
glmnet_sampler(fit, mtcars)

plm <- parallelize(glmnetUtils::glmnet)
fit <- plm(mpg + disp ~ hp + wt, data = mtcars)
glmnet_sampler(fit, mtcars)

multimedia documentation built on Sept. 30, 2024, 9:28 a.m.