regsim.lm simulate quantities of interest from a linear regression model

# S3 method for lm
regsim(object, x, num = 1000, ...)

Arguments

object

a regression model, usually, a result of a call to lm

x

a list of explanatory variables

num

number of iterations to run

...

additional arguments passed to class-specific functions

Examples

library(regsim) model <- lm(mpg ~ wt + cyl, data = mtcars) x <- list(wt = seq(1, 5, 0.1)) sim <- regsim(model, x) summary(sim)
#> Profile 1 #> wt 1.0000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p1 23.86455 27.17837 30.25616 #> ----------------------------- #> #> Profile 2 #> wt 1.1000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p2 23.68115 26.85333 29.80456 #> ----------------------------- #> #> Profile 3 #> wt 1.2000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p3 23.48834 26.53729 29.35295 #> ----------------------------- #> #> Profile 4 #> wt 1.3000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p4 23.29974 26.21261 28.90194 #> ----------------------------- #> #> Profile 5 #> wt 1.4000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p5 23.11456 25.90168 28.45417 #> ----------------------------- #> #> Profile 6 #> wt 1.5000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p6 22.92612 25.56927 28.01176 #> ----------------------------- #> #> Profile 7 #> wt 1.6000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p7 22.74366 25.25497 27.56166 #> ----------------------------- #> #> Profile 8 #> wt 1.7000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p8 22.55873 24.92965 27.10203 #> ----------------------------- #> #> Profile 9 #> wt 1.8000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p9 22.39177 24.61517 26.67318 #> ----------------------------- #> #> Profile 10 #> wt 1.9000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p10 22.20117 24.28892 26.22218 #> ------------------------------ #> #> Profile 11 #> wt 2.0000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p11 22.00724 23.96618 25.80215 #> ------------------------------ #> #> Profile 12 #> wt 2.1000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p12 21.84208 23.64712 25.36991 #> ------------------------------ #> #> Profile 13 #> wt 2.2000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p13 21.66185 23.32445 24.92841 #> ------------------------------ #> #> Profile 14 #> wt 2.3000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p14 21.47007 23.00994 24.51832 #> ------------------------------ #> #> Profile 15 #> wt 2.4000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p15 21.23228 22.69393 24.11723 #> ------------------------------ #> #> Profile 16 #> wt 2.5000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p16 21.04327 22.35883 23.71 #> --------------------------- #> #> Profile 17 #> wt 2.6000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p17 20.85009 22.04602 23.27034 #> ------------------------------ #> #> Profile 18 #> wt 2.7000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p18 20.61204 21.7318 22.86443 #> ----------------------------- #> #> Profile 19 #> wt 2.8000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p19 20.3719 21.42175 22.47792 #> ----------------------------- #> #> Profile 20 #> wt 2.9000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p20 20.10949 21.10823 22.09995 #> ------------------------------ #> #> Profile 21 #> wt 3.0000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p21 19.84112 20.78639 21.71629 #> ------------------------------ #> #> Profile 22 #> wt 3.1000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p22 19.59647 20.45868 21.35831 #> ------------------------------ #> #> Profile 23 #> wt 3.2000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p23 19.26464 20.1387 21.05255 #> ----------------------------- #> #> Profile 24 #> wt 3.3000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p24 18.92012 19.81077 20.75071 #> ------------------------------ #> #> Profile 25 #> wt 3.4000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p25 18.55756 19.49768 20.44599 #> ------------------------------ #> #> Profile 26 #> wt 3.5000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p26 18.15896 19.17473 20.17192 #> ------------------------------ #> #> Profile 27 #> wt 3.6000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p27 17.75207 18.8515 19.92077 #> ----------------------------- #> #> Profile 28 #> wt 3.7000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p28 17.34752 18.55054 19.66677 #> ------------------------------ #> #> Profile 29 #> wt 3.8000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p29 16.94396 18.22894 19.43372 #> ------------------------------ #> #> Profile 30 #> wt 3.9000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p30 16.50483 17.90768 19.20115 #> ------------------------------ #> #> Profile 31 #> wt 4.0000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p31 16.10836 17.59494 18.97332 #> ------------------------------ #> #> Profile 32 #> wt 4.1000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p32 15.66454 17.27138 18.76297 #> ------------------------------ #> #> Profile 33 #> wt 4.2000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p33 15.2216 16.95711 18.55377 #> ----------------------------- #> #> Profile 34 #> wt 4.3000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p34 14.75527 16.63908 18.36227 #> ------------------------------ #> #> Profile 35 #> wt 4.4000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p35 14.33193 16.33701 18.16166 #> ------------------------------ #> #> Profile 36 #> wt 4.5000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p36 13.88089 16.01876 17.96275 #> ------------------------------ #> #> Profile 37 #> wt 4.6000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p37 13.42985 15.70724 17.7509 #> ----------------------------- #> #> Profile 38 #> wt 4.7000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p38 12.97881 15.38705 17.54411 #> ------------------------------ #> #> Profile 39 #> wt 4.8000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p39 12.52913 15.06488 17.34033 #> ------------------------------ #> #> Profile 40 #> wt 4.9000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p40 12.08743 14.74763 17.16459 #> ------------------------------ #> #> Profile 41 #> wt 5.0000 #> cyl 6.1875 #> #> 2.5% 50% 97.5% #> p41 11.64132 14.43328 16.98951 #> ------------------------------ #>