Learn R Programming

multimedia (version 0.2.0)

lm_sampler: Sample a Linear Model

Description

Draw samples from a fitted linear model.

Usage

lm_sampler(fits, newdata = NULL, indices = NULL, ...)

Value

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

Arguments

fits

The fitted linear 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.

...

Additional parameters passed to lm.predict

Examples

Run this code
fit <- lm(mpg ~ hp + wt, data = mtcars)
lm_sampler(list(f = fit))

plm <- parallelize(lm)
fit <- plm(mpg + disp ~ hp + wt, data = mtcars)
lm_sampler(fit)

Run the code above in your browser using DataLab