targets::use_targets()
library(tidyverse)
write_csv(penguins, "data/penguins.csv")
library(targets)
tar_glimpse()
tar_make()
tar_make()
# Run the R scripts in the R/ folder with your custom functions:
tar_source()
tar_glimpse()
suppressPackageStartupMessages(library(brms))
options(
mc.cores = 4
)
tar_glimpse()
tar_make(starts_with("model"))
x <- brm(
bf(body_mass ~ bill_len),
data = penguins,
chains = 4, iter = 2000, seed = 1234
)
install.packages("rstan", type = "source")
install.packages("rstan")
x <- brm(
bf(body_mass ~ bill_len),
data = penguins,
chains = 4, iter = 2000, seed = 1234
)
library(brms)
x <- brm(
bf(body_mass ~ bill_len),
data = penguins,
chains = 4, iter = 2000, seed = 1234
)
# we recommend running this in a fresh R session or restarting your current session
install.packages("rstan", repos = c('https://stan-dev.r-universe.dev', getOption("repos")))
library(brms)
x <- brm(
bf(body_mass ~ bill_len),
data = penguins,
chains = 4, iter = 2000, seed = 1234
)
remotes::install_github("stan-dev/rstan", ref = "develop", subdir = "rstan/rstan")
library(brms)
x <- brm(
bf(body_mass ~ bill_len),
data = penguins,
chains = 4, iter = 2000, seed = 1234
)
library(targets)
tar_make()
tar_invalidate(starts_with("model"))
tar_make()
install.packages('StanHeaders', repos = c('https://stan-dev.r-universe.dev'), type = "source")
library(targets)
tar_invalidate(starts_with("model"))
tar_make()
library(tidyverse)
library(tidyverse)
library(tidybayes)
library(tidyverse)
library(tidybayes)
library(targets)
tar_load(penguins)
tar_load(starts_with("models"))
library(marginaleffects)
ggplot(penguins, aes(x = bill_len, y = body_mass, color = species)) +
geom_point()
tar_load(starts_with("model"))
library(parameters)
model_parameters(model1_bayes)
tar_load(ends_with("_bayes"))
#| warning: false
#| message: false
library(tidyverse)
library(tidybayes)
library(targets)
library(marginaleffects)
library(parameters)
tar_load(penguins)
tar_load(ends_with("bayes"))
tar_load(c(model1_bayes, model2_bayes))
model1_bayes |>
gather_draws()
model1_bayes
model1_bayes |>
gather_draws(b_bill_len)
model1_bayes |>
gather_draws(b_bill_len) |>
ggplot(aes(x = .value)) +
stat_halfeye()
model1_bayes |>
gather_draws(b_bill_len) |>
ggplot(aes(x = .value)) +
stat_halfeye() +
labs(x = "bill_len")
model1_bayes |>
gather_draws(b_bill_len)
bill_len_model_1 <- model1_bayes |>
gather_draws(b_bill_len) |>
mutate(model = "Model 1")
bill_len_model_2 <- model2_bayes |>
gather_draws(b_bill_len) |>
mutate(model = "Model 2")
bind_rows(bill_len_model_1, bill_len_model_2) |>
ggplot(aes(x = .value)) +
stat_halfeye() +
labs(x = "bill_len") +
facet_wrap(vars(model))
bind_rows(bill_len_model_1, bill_len_model_2) |>
ggplot(aes(x = .value, y = model)) +
stat_halfeye() +
labs(x = "bill_len")
bind_rows(bill_len_model_1, bill_len_model_2) |>
ggplot(aes(x = .value, y = model, fill = model)) +
stat_halfeye() +
guides(fill = "none") +
labs(x = "bill_len")
model1_bayes
model1_bayes |>
plot_predictions(condition = c("bill_len"))
library(patchwork)
p1 <- model1_bayes |>
plot_predictions(condition = c("bill_len"))
p1 <- model1_bayes |>
plot_predictions(condition = c("bill_len"))
p2 <- model1_bayes |>
plot_predictions(condition = c("bill_len", "species"))
p1 <- model1_bayes |>
plot_predictions(condition = c("bill_len"))
p2 <- model2_bayes |>
plot_predictions(condition = c("bill_len", "species"))
p1 | p2
p1 <- model1_bayes |>
plot_predictions(condition = c("bill_len")) +
coord_cartesian(xlim = c(2000, 6500))
p2 <- model2_bayes |>
plot_predictions(condition = c("bill_len", "species")) +
coord_cartesian(xlim = c(2000, 6500))
p1 | p2
model1_bayes |>
plot_predictions(condition = c("bill_len")) +
coord_cartesian(xlim = c(2000, 6500))
model1_bayes |>
plot_predictions(condition = c("bill_len"))
p1 <- model1_bayes |>
plot_predictions(condition = c("bill_len")) +
coord_cartesian(ylim = c(2000, 6500))
p2 <- model2_bayes |>
plot_predictions(condition = c("bill_len", "species")) +
coord_cartesian(ylim = c(2000, 6500))
p1 | p2
#| warning: false
#| message: false
p1 <- model1_bayes |>
plot_predictions(condition = c("bill_len")) +
coord_cartesian(ylim = c(2000, 6500))
p2 <- model2_bayes |>
plot_predictions(condition = c("bill_len", "species")) +
coord_cartesian(ylim = c(2000, 6500))
p1 | p2
modelsummary(list(model1_bayes, model2_bayes))
library(modelsummary)
modelsummary(list(model1_bayes, model2_bayes))
modelsummary(list(model1_bayes, model2_bayes), statistic = "[{conf.low}, {conf.high}]",
ci_method = "hdi",
metrics = c("R2"))
modelsummary(list(model1_bayes, model2_bayes), statistic = "[{conf.low}, {conf.high}]",
ci_method = "hdi",
metrics = c("R2"), digits = 1)
modelsummary(list(model1_bayes, model2_bayes), statistic = "[{conf.low}, {conf.high}]",
ci_method = "hdi",
metrics = c("R2"), fmt = 1)
tar_outdated()
tar_make()
tar_make()
tar_glimpse()
