R/generics.R

Defines functions forecast nobs.dsge_fit logLik.dsge_fit coef.dsge_fit

Documented in forecast

# S3 generic registrations and standard method implementations

#' @export
coef.dsge_fit <- function(object, ...) {
  object$coefficients
}

#' @export
logLik.dsge_fit <- function(object, ...) {
  ll <- object$loglik
  n_free <- length(object$free_parameters)
  n_shocks <- object$model$n_exo_states
  attr(ll, "df") <- n_free + n_shocks
  attr(ll, "nobs") <- object$nobs
  class(ll) <- "logLik"
  ll
}

#' @export
nobs.dsge_fit <- function(object, ...) {
  object$nobs
}

#' Forecast from a DSGE Model
#'
#' Generic function for forecasting from estimated DSGE models.
#'
#' @param object A fitted model object.
#' @param ... Additional arguments passed to methods.
#'
#' @return A forecast object.
#'
#' @seealso [forecast.dsge_fit()]
#' @export
forecast <- function(object, ...) {
  UseMethod("forecast")
}

Try the dsge package in your browser

Any scripts or data that you put into this service are public.

dsge documentation built on Sept. 25, 2026, 5:08 p.m.