View source: R/tidier_methods.R
| tidy.mvgam | R Documentation |
mvgam object's parameter posteriorsGet parameters' posterior statistics, implementing the generic tidy from
the package broom.
## S3 method for class 'mvgam'
tidy(x, probs = c(0.025, 0.5, 0.975), ...)
x |
An object of class |
probs |
The desired probability levels of the parameters' posteriors.
Defaults to |
... |
Unused, included for generic consistency only. |
The parameters are categorized by the column "type". For instance, the
intercept of the observation model (i.e. the "formula" arg to mvgam()) has
the "type" "observation_beta". The possible "type"s are:
observation_family_extra_param: any extra parameters for your observation model, e.g. sigma for a gaussian observation model. These parameters are not directly derived from the latent trend components (contrast to mu).
observation_beta: betas from your observation model, excluding any
smooths. If your formula was y ~ x1 + s(x2, bs='cr'), then your
intercept and x1's beta would be categorized as this.
random_effect_group_level: Group-level random effects parameters, i.e. the mean and sd of the distribution from which the specific random intercepts/slopes are considered to be drawn from.
random_effect_beta: betas for the individual random intercepts/slopes.
trend_model_param: parameters from your trend_model.
trend_beta: analog of "observation_beta", but for any trend_formula.
trend_random_effect_group_level: analog of
"random_effect_group_level", but for any trend_formula.
trend_random_effect_beta: analog of "random_effect_beta", but for any
trend_formula.
Additionally, GP terms can be incorporated in several ways, leading to different "type"s (or absence!):
s(bs = "gp"): No parameters returned.
gp() in formula: "type" of "observation_param".
gp() in trend_formula: "type" of "trend_formula_param".
GP() in trend_model: "type" of "trend_model_param".
A tibble containing:
"parameter": The parameter in question.
"type": The component of the model that the parameter belongs to (see details).
"mean": The posterior mean.
"sd": The posterior standard deviation.
percentile(s): Any percentiles of interest from these posteriors.
Other tidiers:
augment.mvgam()
## Not run:
set.seed(0)
simdat <- sim_mvgam(
T = 100,
n_series = 3,
trend_model = AR(),
prop_trend = 0.75,
family = gaussian()
)
simdat$data_train$x <- rnorm(nrow(simdat$data_train))
simdat$data_train$year_fac <- factor(simdat$data_train$year)
mod <- mvgam(
y ~ -1 + s(time, by = series, bs = 'cr', k = 20) + x,
trend_formula = ~ s(year_fac, bs = 're') - 1,
trend_model = AR(cor = TRUE),
family = gaussian(),
data = simdat$data_train,
silent = 2
)
tidy(mod, probs = c(0.2, 0.5, 0.8))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.