rstanarm
: straightforward inference and interpretation.drake
R package.library(drake)
plan <- drake_plan(
life_exp = fit_model(covariate = "life_exp", dataset = dataset),
log_pop = fit_model(covariate = "log_pop", dataset = dataset),
dataset = prepare_gapminder(gapminder::gapminder),
plots = gather_plots(life_exp, log_pop),
report = render(
knitr_in("report.Rmd"),
output_file = file_out("report.html")
)
)
plan
## # A tibble: 5 x 2
## target command
## <chr> <chr>
## 1 life_exp "fit_model(covariate = \"life_exp\", dataset = dataset)"
## 2 log_pop "fit_model(covariate = \"log_pop\", dataset = dataset)"
## 3 dataset prepare_gapminder(gapminder::gapminder)
## 4 plots gather_plots(life_exp, log_pop)
## 5 report "render(knitr_in(\"report.Rmd\"), output_file = file_out(\"repo…
readd(dataset)
## # A tibble: 1,704 x 3
## life_exp log_gdp_percap log_pop
## <dbl> <dbl> <dbl>
## 1 -2.37 -1.21 0.113
## 2 -2.26 -1.17 0.170
## 3 -2.13 -1.14 0.236
## 4 -1.97 -1.15 0.309
## 5 -1.81 -1.25 0.387
## 6 -1.63 -1.20 0.467
## 7 -1.52 -1.03 0.377
## 8 -1.44 -1.14 0.423
## 9 -1.38 -1.36 0.525
## 10 -1.37 -1.37 0.717
## # … with 1,694 more rows
Produc
dataset.library(Ecdat)
# We want to predict "gsp" based on the other variables.
predictors <- setdiff(colnames(Produc), "gsp")
# We will try all combinations of three covariates.
combos <- combn(predictors, 3)
# We have a grid of covariates.
x1 <- rlang::syms(combos[1, ])
x2 <- rlang::syms(combos[2, ])
x3 <- rlang::syms(combos[3, ])
drake
>= 7.0.0.plan <- drake_plan(
model = target(
fit_gsp_model(gsp ~ x1 + x2 + x3, data = Ecdat::Produc),
transform = map(x1 = !!x1, x2 = !!x2, x3 = !!x3)
),
rmspe_i = target(
get_rmspe(model, Ecdat::Produc),
transform = map(model)
),
rmspe = target(
do.call(rbind, rmspe_i),
transform = combine()
),
plot = ggsave(file_out("rmspe.pdf"), plot_rmspe(rmspe))
)
## # A tibble: 170 x 2
## target command
## <chr> <chr>
## 1 model_state_year_p… fit_gsp_model(gsp ~ state + year + pcap, data = Ecd…
## 2 model_state_year_h… fit_gsp_model(gsp ~ state + year + hwy, data = Ecda…
## 3 model_state_year_w… fit_gsp_model(gsp ~ state + year + water, data = Ec…
## 4 model_state_year_u… fit_gsp_model(gsp ~ state + year + util, data = Ecd…
## 5 model_state_year_pc fit_gsp_model(gsp ~ state + year + pc, data = Ecdat…
## 6 model_state_year_e… fit_gsp_model(gsp ~ state + year + emp, data = Ecda…
## 7 model_state_year_u… fit_gsp_model(gsp ~ state + year + unemp, data = Ec…
## 8 model_state_pcap_h… fit_gsp_model(gsp ~ state + pcap + hwy, data = Ecda…
## 9 model_state_pcap_w… fit_gsp_model(gsp ~ state + pcap + water, data = Ec…
## 10 model_state_pcap_u… fit_gsp_model(gsp ~ state + pcap + util, data = Ecd…
## # … with 160 more rows
# If running locally:
options(clustermq.scheduler = "multicore")
# If on a SLURM cluster (other clusters also supported):
drake_hpc_template_file("slurm_clustermq.tmpl") # Modify by hand.
options(
clustermq.scheduler = "slurm",
clustermq.template = "slurm_clustermq.tmpl"
)
# Either way, make() is the same.
make(plan, jobs = 2, parallelism = "clustermq")
# If running locally:
future::plan(future::multisession)
# If on a SLURM cluster (other clusters also supported):
library(future.batchtools)
drake_hpc_template_file("slurm_batchtools.tmpl") # Modify by hand.
future::plan(batchtools_slurm, template = "slurm_batchtools.tmpl")
# Either way, make() is the same.
make(plan, jobs = 2, parallelism = "future")
drake
gapminder
packageProduc
dataset dataset from the Ecdat
packagedrake
make no copyright claim to any of the constituent graphicical elements that comprise the animations.