Skip to contents

Posterior draws of each level's deviation for every group-level term of the observation formula, summarised or raw. Each element is named r_<group>[<level>,<coef>], as variables.mvgam() lists it.

Usage

# S3 method for class 'mvgam'
ranef(
  object,
  summary = TRUE,
  robust = FALSE,
  probs = c(0.025, 0.975),
  pars = NULL,
  groups = NULL,
  ...
)

Arguments

object

A fitted mvgam object.

summary

Logical. TRUE (the default) summarises each coefficient's draws. FALSE returns the draws.

robust

Logical. If FALSE (the default), uses mean and standard deviation for summaries. If TRUE, uses median and median absolute deviation (MAD).

probs

Two probabilities for the lower and upper bounds of the credible interval. Default c(0.025, 0.975), a 95% interval.

pars

Optional character vector of coefficient names, such as "Intercept". NULL (the default) keeps every coefficient.

groups

Optional character vector of grouping factors. NULL (the default) keeps every factor.

...

Unused. Anything passed here is refused.

Value

A named list with one 3D array per grouping factor. With summary = TRUE the dimensions are levels, statistics and coefficients. The statistics are Estimate, Est.Error and one quantile per element of probs. With summary = FALSE the dimensions are draws, levels and coefficients, and the array carries an nchains attribute. A grouping factor of a distributional parameter or of one response of several is keyed <group>__<parameter>.

Details

A group-level term in trend_formula is named with the _trend suffix, as r_g_trend[a,Intercept]. as_draws.mvgam() returns its draws.

See also

VarCorr.mvgam() summarises the standard deviations and correlations. fixef.mvgam() summarises the population-level effects.

Other posterior summaries: VarCorr.mvgam(), bibtex(), how_to_cite.mvgam(), hypothesis.mvgam(), index-mvgam, mcmc_plot.mvgam(), methods_md(), mvgam_draws, pairs.mvgam(), posterior_interval.mvgam(), smooths.mvgam(), summary.mvgam()

Author

Nicholas J Clark

Examples

# \dontrun{
set.seed(14)
simdat <- sim_mvgam(family = poisson(), n_series = 4L,
                    n_timepoints = 120L, trend_model = AR())
mod <- mvgam(y ~ s(x, k = 5) + (1 | series),
             trend_formula = ~ AR(p = 1),
             data = simdat$data_train, family = poisson(),
             chains = 2, silent = 2)
#> Warning: 24 of 2000 (1.0%) transitions ended with a divergence.
#> See https://mc-stan.org/misc/warnings for details.

# Each series' intercept deviation, one row per series
ranef(mod)$series[, , "Intercept"]
#>              Estimate Est.Error       Q2.5     Q97.5
#> series_1  0.009904798 0.1520011 -0.3298922 0.3499711
#> series_2 -0.016345766 0.1623397 -0.4188833 0.3202881
#> series_3 -0.074777940 0.1607167 -0.4728470 0.2011157
#> series_4  0.078783349 0.1657638 -0.2215688 0.4790375

# Next: VarCorr() gives the standard deviation of these deviations
# }