residuals.dfm {dfms}R Documentation

DFM Residuals and Fitted Values

Description

The residuals \textbf{e}_t = \textbf{x}_t - \textbf{C} \textbf{F}_t or fitted values \textbf{C} \textbf{F}_t of the DFM observation equation.

Usage

## S3 method for class 'dfm'
residuals(
  object,
  method = switch(object$em.method, none = "2s", "qml"),
  orig.format = FALSE,
  standardized = FALSE,
  na.keep = TRUE,
  ...
)

## S3 method for class 'dfm'
fitted(
  object,
  method = switch(object$em.method, none = "2s", "qml"),
  orig.format = FALSE,
  standardized = FALSE,
  na.keep = TRUE,
  ...
)

Arguments

object

an object of class 'dfm'.

method

character. The factor estimates to use: one of "qml", "2s" or "pca".

orig.format

logical. TRUE returns residuals/fitted values in a data format similar to X.

standardized

logical. FALSE will put residuals/fitted values on the original data scale.

na.keep

logical. TRUE inserts missing values where X is missing (default TRUE as residuals/fitted values are only defined for observed data). FALSE returns the raw prediction, which can be used to interpolate data based on the DFM. For residuals, FALSE returns the difference between the prediction and the initial imputed version of X use for PCA to initialize the Kalman Filter.

...

not used.

Value

A matrix of DFM residuals or fitted values. If orig.format = TRUE the format may be different, e.g. a data frame.

Examples


library(xts)
# Fit DFM with 3 factors and 3 lags in the transition equation
mod = DFM(diff(BM14_M), r = 3, p = 3)

# Residuals
head(resid(mod))
plot(resid(mod, orig.format = TRUE)) # this is an xts object

# Fitted values
head(fitted(mod))
head(fitted(mod, orig.format = TRUE)) # this is an xts object



[Package dfms version 0.2.1 Index]