
Test posterior hypotheses on a fitted mvgam model
Source:R/brms_wrappers.mvgam.R
hypothesis.mvgam.RdThe mvgam method of brms::hypothesis(), with the arguments and
parameter names of brms::hypothesis.brmsfit(). By default a
hypothesis names population-level coefficients without their b_
prefix, as "x > 0" tests b_x. class = NULL names any
parameter by the full name variables.mvgam() lists, such as
ar1_trend[series_1] or sigma. That help page sets out how the
names are formed.
Usage
# S3 method for class 'mvgam'
hypothesis(
x,
hypothesis,
class = "b",
group = "",
alpha = 0.05,
robust = FALSE,
seed = NULL,
...
)Arguments
- x
A fitted
mvgamobject.- hypothesis
Character vector of hypothesis strings in the
brms::hypothesis()grammar, such as"x > 0"or"(x - z) = 0".- class
The class prefix the names in
hypothesisomit. Defaults to"b".NULLor""takes every parameter by its full name.- group
The grouping factor of a group-level class, as
class = "sd", group = "site"testssd_site__InterceptasIntercept.- alpha
One minus the credible-interval mass. Defaults to
0.05(90%-CI for one-sided, 95%-CI for two-sided).- robust
Logical. If
FALSE(the default), uses mean and standard deviation for summaries. IfTRUE, uses median and median absolute deviation (MAD).- seed
Optional integer seed for the random draws of an evidence ratio. The session's random state is restored when the call returns.
- ...
Forwarded to
brms::hypothesis.
Value
A brmshypothesis object. See brms::hypothesis().
See also
brms::hypothesis(), variables.mvgam().
Other posterior summaries:
VarCorr.mvgam(),
bibtex(),
how_to_cite.mvgam(),
index-mvgam,
mcmc_plot.mvgam(),
methods_md(),
mvgam_draws,
pairs.mvgam(),
posterior_interval.mvgam(),
ranef.mvgam(),
smooths.mvgam(),
summary.mvgam()
Examples
# \dontrun{
set.seed(13)
simdat <- sim_mvgam(family = poisson(), n_series = 1L,
n_timepoints = 120L, trend_model = AR())
mod <- mvgam(y ~ x,
trend_formula = ~ AR(p = 1),
data = simdat$data_train,
family = poisson(),
chains = 2, silent = 2)
#> Warning: 1 of 2000 (0.0%) transitions ended with a divergence.
#> See https://mc-stan.org/misc/warnings for details.
# A population-level coefficient, named as fixef() names it.
hypothesis(mod, "x > 0")
#> Hypothesis Tests for class :
#> Hypothesis Estimate Est.Error CI.Lower CI.Upper Evid.Ratio Post.Prob Star
#> 1 (x) > 0 -0.36 0.08 -0.48 -0.24 0 0
#> ---
#> 'CI': 90%-CI for one-sided and 95%-CI for two-sided hypotheses.
#> '*': For one-sided hypotheses, the posterior probability exceeds 95%;
#> for two-sided hypotheses, the value tested against lies outside the 95%-CI.
#> Posterior probabilities of point hypotheses assume equal prior probabilities.
# Any parameter by its full name.
hypothesis(mod, c("ar1_trend[series_1] > 0",
"sigma_trend[series_1] < 1"),
class = NULL)
#> Hypothesis Tests for class :
#> Hypothesis Estimate Est.Error CI.Lower CI.Upper Evid.Ratio
#> 1 (ar1_trend[series... > 0 0.44 0.15 0.18 0.67 665.67
#> 2 (sigma_trend[seri... < 0 -0.37 0.08 -0.49 -0.23 Inf
#> Post.Prob Star
#> 1 1 *
#> 2 1 *
#> ---
#> 'CI': 90%-CI for one-sided and 95%-CI for two-sided hypotheses.
#> '*': For one-sided hypotheses, the posterior probability exceeds 95%;
#> for two-sided hypotheses, the value tested against lies outside the 95%-CI.
#> Posterior probabilities of point hypotheses assume equal prior probabilities.
# }