eval_pred_dens: Evaluate the one-step ahead predictive density of a fitted...

View source: R/pred_funs.R

eval_pred_densR Documentation

Evaluate the one-step ahead predictive density of a fitted TVP model

Description

eval_pred_dens evaluates the one-step ahead predictive density of a fitted TVP model resulting from a call to shrinkTVP at the points supplied in x. For details on the approximation of the one-step ahead predictive density used, see the vignette.

Usage

eval_pred_dens(x, mod, data_test, log = FALSE)

Arguments

x

a real number or a vector of real numbers, taken to be the points at which the predictive density will be evaluated.

mod

an object of class shrinkTVP, containing the fitted model for which the predictive density should be evaluated.

data_test

a data frame with one row, containing the one-step ahead covariates. The names of the covariates have to match the names of the covariates used during model estimation in the call to shrinkTVP.

log

a single logical value determining whether the density should be evaluated on the log scale or not.

Value

The value returned is a vector of length length(x), containing the values of the predictive density evaluated at the points supplied in x.

Author(s)

Peter Knaus peter.knaus@wu.ac.at

See Also

Other prediction functions: LPDS(), fitted.shrinkTVP(), forecast_shrinkTVP(), predict.shrinkTVP(), residuals.shrinkTVP()

Examples


# Simulate data
set.seed(123)
sim <- simTVP(theta = c(0.2, 0, 0), beta_mean = c(1.5, -0.3, 0))
data <- sim$data

# Estimate model
res <- shrinkTVP(y ~ x1 + x2, data = data[1:199, ])

# Create sequence of x values where the density is to be evaluated
x_vals <- seq(0, 12, by = 0.1)

# Evaluate density and plot
dens <- eval_pred_dens(x_vals, res, data[200, ])
plot(x_vals, dens, type = "l")

# Add vertical line where true value of the one-step ahead y lies
abline(v = data$y[200])


shrinkTVP documentation built on May 29, 2024, 7:24 a.m.