as.data.frame.dfm | R Documentation |
Extract Factor Estimates in a Data Frame
## S3 method for class 'dfm'
as.data.frame(
x,
...,
method = "all",
pivot = c("long", "wide.factor", "wide.method", "wide", "t.wide"),
time = seq_row(x$F_pca),
stringsAsFactors = TRUE
)
x |
an object class 'dfm'. |
... |
not used. |
method |
character. The factor estimates to use: any of |
pivot |
character. The orientation of the frame: |
time |
a vector identifying the time dimension, or |
stringsAsFactors |
make factors from method and factor identifiers. Same as option to |
A data frame of factor estimates.
library(xts)
# Fit DFM with 3 factors and 3 lags in the transition equation
mod = DFM(diff(BM14_M), r = 3, p = 3)
# Taking a single estimate:
print(head(as.data.frame(mod, method = "qml")))
print(head(as.data.frame(mod, method = "qml", pivot = "wide")))
# Adding a proper time variable
time = index(BM14_M)[-1L]
print(head(as.data.frame(mod, method = "qml", time = time)))
# All estimates: different pivoting methods
for (pv in c("long", "wide.factor", "wide.method", "wide", "t.wide")) {
cat("\npivot = ", pv, "\n")
print(head(as.data.frame(mod, pivot = pv, time = time), 3))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.