fitted.bmgarch: Fitted (backcasting) method for bmgarch objects.

View source: R/forecasting_gq.R

fitted.bmgarchR Documentation

Fitted (backcasting) method for bmgarch objects.

Description

Extracts the model-predicted means, variances, and correlations for the fitted data.

Usage

## S3 method for class 'bmgarch'
fitted(
  object,
  CrI = c(0.025, 0.975),
  digits = 2,
  weights = NULL,
  inc_samples = FALSE,
  ...
)

Arguments

object

bmgarch object.

CrI

Numeric vector (Default: c(.025, .975)). Lower and upper bound of predictive credible interval.

digits

Integer (Default: 2, optional). Number of digits to round to when printing.

weights

Takes weights from model_weight function. Defaults to 1 – this parameter is not typically set by user.

inc_samples

Logical (Default: FALSE). Whether to return the MCMC samples for the fitted values.

...

Not used.

Details

Whereas forecast.bmgarch computes the forecasted values for future time periods, fitted.bmgarch computes the backcasted (model-predicted) values for the observed time periods.

Value

fitted.bmgarch object. List containing metadata and the backcast. Backcast is a list containing three elements:

mean

[N, 7, TS] array of mean backcasts, where N is the timeseries length, and TS is the number of time series. E.g., bc$backcast$mean[3,,"tsA"] is the mean backcast for the third observation in time series "tsA".

var

[N, 7, TS] array of variance backcasts, where N is the timeseries length, and TS is the number of time series. E.g., bc$backcast$var[3,,"tsA"] is the variance backcast for the third observation in time series "tsA".

cor

[N, 7, TS(TS - 1)/2] array of correlation backcasts, where N is the timeseries length, and TS(TS - 1)/2 is the number of correlations. E.g., bc$backcast$cor[3,, "tsB_tsA"] is the backcast for the correlation between "tsB" and "tsA" on the third observation. Lower triangular correlations are saved.

samples

List

. If inc_samples is TRUE, then a list of arrays of MCMC samples for means, vars, and cors. Each array is [Iteration, Period, ..., ...].

Examples

## Not run: 
data(panas)
# Fit CCC(1,1) and constant meanstructure.
fit <- bmgarch(panas, parameterization = "CCC", meanstructure = "constant")

# Obtain fitted values
fit.bc <- fitted(fit)

# Print fitted values
print(fit.bc)

# Plot fitted values (plot.bmgarch calls fitted internally)
plot(fit, type = "var")

# Save fitted values as data frame
fit.bc.df <- as.data.frame(fit.bc)

## End(Not run)

bmgarch documentation built on Sept. 12, 2023, 1:13 a.m.