Learn R Programming

BVAR (version 1.0.5)

rmse.bvar: Model fit in- and out-of-sample

Description

Functions to compute the root mean squared error and log predictive scores.

Usage

# S3 method for bvar
rmse(x, holdout, ...)

# S3 method for bvar lps(x, holdout, n_thin = 1L, ...)

rmse(x, ...)

# S3 method for default rmse(x, ...)

lps(x, ...)

# S3 method for default lps(x, ...)

Value

Returns a matrix with measures of model fit.

Arguments

x

A bvar object, obtained from bvar.

holdout

Optional numeric matrix or dataframe. Used for the out-of-sample fit.

...

Not used.

n_thin

Integer scalar. Every n_thin'th draw in x is used to calculate, others are dropped.

Examples

Run this code
# \donttest{
# Access a subset of the fred_qd dataset
data <- fred_qd[, c("CPIAUCSL", "UNRATE", "FEDFUNDS")]
# Transform it to be stationary
data <- fred_transform(data, codes = c(5, 5, 1), lag = 4)

# Estimate a BVAR using one lag, default settings and very few draws
x <- bvar(data[seq(1, nrow(data) - 5), ], lags = 1,
  n_draw = 600L, n_burn = 100L, verbose = FALSE)

# Compute RMSE
rmse(x)
lps(x, holdout = data[seq(nrow(data) - 4, nrow(data)), ])
# }

Run the code above in your browser using DataLab