Skip to contents

Posterior draws of the standard deviation of each group-level term of the observation formula, with the correlations and covariances of terms that share a grouping factor.

Usage

# S3 method for class 'mvgam'
VarCorr(
  x,
  sigma = 1,
  summary = TRUE,
  robust = FALSE,
  probs = c(0.025, 0.975),
  ...
)

Arguments

x

A fitted mvgam object.

sigma

A single non-negative number. It has no effect. summary.mvgam() reports the observation family's scale.

summary

Logical. TRUE (the default) summarises the draws. FALSE returns them.

robust

Logical. TRUE summarises with the median and MAD. Defaults to FALSE.

probs

Numeric vector of the two quantiles to report.

...

Unused. Anything passed here is refused.

Value

A named list with one entry per grouping factor. Each entry is a list of these components:

  • sd: the standard deviation of each coefficient, a matrix of coefficients by statistics, or of draws by coefficients under summary = FALSE.

  • cor: correlation matrices, present when the factor carries two or more correlated coefficients. The array runs over coefficients, statistics and coefficients, or over draws and two coefficient axes under summary = FALSE.

  • cov: covariance matrices, shaped as cor.

Details

A trend-side component is named with the _trend suffix, as sd_g__Intercept_trend. as_draws.mvgam() returns its draws.

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.

# The standard deviation of the series intercepts
VarCorr(mod)$series$sd
#>            Estimate Est.Error       Q2.5     Q97.5
#> Intercept 0.2026411 0.2054635 0.00800586 0.7920425

# Next: ranef() gives each series' own deviation
# }