Draw samples from a fitted linear model.
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
fit <- lm(mpg ~ hp + wt, data = mtcars)
lm_sampler(list(f = fit))
#> # A tibble: 32 × 1
#> f
#> <dbl>
#> 1 28.1
#> 2 24.3
#> 3 25.0
#> 4 28.4
#> 5 18.8
#> 6 15.2
#> 7 15.6
#> 8 22.0
#> 9 21.5
#> 10 24.1
#> # ℹ 22 more rows
plm <- parallelize(lm)
fit <- plm(mpg + disp ~ hp + wt, data = mtcars)
lm_sampler(fit)
#> # A tibble: 32 × 2
#> mpg disp
#> <dbl> <dbl>
#> 1 21.5 140.
#> 2 22.1 151.
#> 3 23.2 102.
#> 4 19.2 205.
#> 5 18.0 242.
#> 6 19.2 173.
#> 7 19.6 322.
#> 8 22.2 257.
#> 9 22.5 292.
#> 10 18.0 251.
#> # ℹ 22 more rows