Description Usage Arguments Examples
View source: R/stanova_samples.R
Posterior samples for ANOVA-type models
1 2 3 4 5 6 7 8 9 10 11 | stanova_samples(object, ...)
## S3 method for class 'stanova'
stanova_samples(
object,
diff_intercept = TRUE,
terms,
return = c("array", "matrix", "data.frame", "tibble", "tidybayes"),
dimension_chain = 3L,
...
)
|
object |
Fitted model. Currently only support for |
... |
currently ignored. |
diff_intercept |
logical. If |
terms |
optional character vector denoting a subset of model terms for which difference from intercept be returned. |
return |
|
dimension_chain |
Scalar integer. If |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | fit_warp <- stanova(breaks ~ wool * tension, data = warpbreaks,
prior = rstanarm::R2(0.5),
model_fun = "lm",
chains = 2, iter = 500)
arr_warp <- stanova_samples(fit_warp)
str(arr_warp)
mat_warp <- stanova_samples(fit_warp, return = "matrix")
str(mat_warp)
df_warp <- stanova_samples(fit_warp, return = "data.frame")
str(df_warp)
tail(df_warp$`wool:tension`)
if (requireNamespace("tibble")) {
tbl_warp <- stanova_samples(fit_warp, return = "tibble")
tbl_warp
}
if (require("tidybayes") && require("tidyverse")) {
tidy_warp <- stanova_samples(fit_warp, return = "tidybayes")
tidy_warp
tidy_warp$tension %>%
group_by(variable) %>%
median_qi(value) %>%
ggplot(aes(y = variable, x = value, xmin = .lower, xmax = .upper)) +
geom_pointinterval()
tidy_warp$tension %>%
ggplot(aes(y = variable, x = value)) +
stat_halfeye()
bind_rows(tidy_warp) %>%
ggplot(aes(y = variable, x = value)) +
stat_halfeye() +
facet_wrap(vars(term), scales = "free")
bind_rows(tidy_warp) %>%
ggplot(aes(y = variable, x = value)) +
stat_interval() +
facet_wrap(vars(term), scales = "free")
## marginal means instead of differences from mean:
stanova_samples(fit_warp, return = "tidybayes", diff_intercept = FALSE) %>%
bind_rows() %>%
ggplot(aes(y = variable, x = value)) +
stat_halfeye() +
facet_wrap(vars(term), scales = "free")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.