mvgam_draws function

Extract posterior draws from fitted mvgam objects

Extract posterior draws from fitted mvgam objects

Extract posterior draws in conventional formats as data.frames, matrices, or arrays.

## S3 method for class 'mvgam' as.data.frame( x, row.names = NULL, optional = TRUE, variable = "betas", use_alias = TRUE, regex = FALSE, ... ) ## S3 method for class 'mvgam' as.matrix(x, variable = "betas", regex = FALSE, use_alias = TRUE, ...) ## S3 method for class 'mvgam' as.array(x, variable = "betas", regex = FALSE, use_alias = TRUE, ...) ## S3 method for class 'mvgam' as_draws( x, variable = NULL, regex = FALSE, inc_warmup = FALSE, use_alias = TRUE, ... ) ## S3 method for class 'mvgam' as_draws_matrix( x, variable = NULL, regex = FALSE, inc_warmup = FALSE, use_alias = TRUE, ... ) ## S3 method for class 'mvgam' as_draws_df( x, variable = NULL, regex = FALSE, inc_warmup = FALSE, use_alias = TRUE, ... ) ## S3 method for class 'mvgam' as_draws_array( x, variable = NULL, regex = FALSE, inc_warmup = FALSE, use_alias = TRUE, ... ) ## S3 method for class 'mvgam' as_draws_list( x, variable = NULL, regex = FALSE, inc_warmup = FALSE, use_alias = TRUE, ... ) ## S3 method for class 'mvgam' as_draws_rvars(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)

Arguments

  • x: list object of class mvgam

  • row.names: Ignored

  • optional: Ignored

  • variable: A character specifying which parameters to extract. Can either be one of the following options:

    • obs_params (other parameters specific to the observation model, such as overdispsersions for negative binomial models or observation error SD for gaussian / student-t models)
    • betas (beta coefficients from the GAM observation model linear predictor; default)
    • smooth_params (smoothing parameters from the GAM observation model)
    • linpreds (estimated linear predictors on whatever link scale was used in the model)
    • trend_params (parameters governing the trend dynamics, such as AR parameters, trend SD parameters or Gaussian Process parameters)
    • trend_betas (beta coefficients from the GAM latent process model linear predictor; only available if a trend_formula was supplied in the original model)
    • trend_smooth_params (process model GAM smoothing parameters; only available if a trend_formula was supplied in the original model)
    • trend_linpreds (process model linear predictors on the identity scale; only available if a trend_formula was supplied in the original model)

    OR can be a character vector providing the variables to extract

  • use_alias: Logical. If more informative names for parameters are available (i.e. for beta coefficients b or for smoothing parameters rho), replace the uninformative names with the more informative alias. Defaults to TRUE

  • regex: Logical. If not using one of the prespecified options for extractions, should variable be treated as a (vector of) regular expressions? Any variable in x matching at least one of the regular expressions will be selected. Defaults to FALSE.

  • ...: Ignored

  • inc_warmup: Should warmup draws be included? Defaults to FALSE.

Returns

A data.frame, matrix, or array containing the posterior draws.

Examples

sim <- sim_mvgam(family = Gamma()) mod1 <- mvgam(y ~ s(season, bs = 'cc'), trend_model = 'AR1', data = sim$data_train, family = Gamma(), chains = 2, silent = 2) beta_draws_df <- as.data.frame(mod1, variable = 'betas') head(beta_draws_df) str(beta_draws_df) beta_draws_mat <- as.matrix(mod1, variable = 'betas') head(beta_draws_mat) str(beta_draws_mat) shape_pars <- as.matrix(mod1, variable = 'shape', regex = TRUE) head(shape_pars)