From 8434bcbf21cd17cec5bcfa5a41219e2fa3a04f70 Mon Sep 17 00:00:00 2001
From: Sebastian Krantz The data frame Another option is to use a Screeplot to gauge the number of factors
by looking for a kink in the plot. A mathematical procedure for finding
@@ -169,7 +169,7 @@ Introduction to dfms
Sebastian
Krantz
- 2023-03-30
+ 2023-04-01
Source: vignettes/introduction.Rmd
introduction.Rmd
2023-03-30
head(colnames(BM14_M))
#> [1] "ip_total" "ip_tot_cstr" "ip_tot_cstr_en" "ip_constr"
#> [5] "ip_im_goods" "ip_capital"
-plot(scale(BM14_M), lwd = 1)
+plot(scale(BM14_M), lwd = 1)
BM14_Models
provides information about
the series2, and the various models estimated by
@@ -138,7 +138,7 @@ 2023-03-30
# log-transforming and first-differencing the data
BM14_M[, BM14_Models_M$log_trans] %<>% log()
BM14_M_diff = diff(BM14_M)
-plot(scale(BM14_M_diff), lwd = 1)
+plot(scale(BM14_M_diff), lwd = 1)
Determining the Structure of the Model
@@ -155,7 +155,7 @@
Determining the Structure of the
#>
#> IC1 IC2 IC3
#> 7 7 13
-plot(ic)
Determining the Structure of the
do not add much to the explanatory power of the model. Next to the
number of factors, the lag order of the factor-VAR of the transition
equation should be estimated (the default is 1 lag). This can be done
-using the
VARselect()
function from the vars
+using the VARselect()
function from the vars
package, with PCA factor estimates reported by ICr()
.
# Using vars::VARselect() with 4 principal components to estimate the VAR lag order
@@ -220,9 +220,9 @@ Estimation and Exploration#> f2 0.1347 -0.0024 -0.0342
#> f3 -0.0087 0.1767 0.0249
#> f4 0.0307 0.0662 -0.0035
-plot(model1)
The model can be investigated using summary()
, which
+
The model can be investigated using summary()
, which
returns an object of class ‘dfm_summary’ containing the system matrices
and summary statistics of the factors and the residuals in the
measurement equation, as well as the R-Squared of the factor model for
@@ -230,10 +230,9 @@
-dfm_summary <- summary(model1)
+dfm_summary <- summary(model1)
print(dfm_summary) # Large model with > 40 series: defaults to compact = 2
#> Dynamic Factor Model: n = 92, T = 356, r = 4, p = 3, %NA = 25.8366
-#> with AR(1) errors: mean(abs(rho)) = 0.253
#>
#> Call: DFM(X = BM14_M_diff, r = 4, p = 3)
#>
@@ -282,15 +281,15 @@ Estimation and Exploration# print(dfm_summary, compact = 1)
# print(dfm_summary, compact = 0)
Apart from the model summary, the dfm methods
-residuals()
and fitted()
return observation
+residuals()
and fitted()
return observation
residuals and fitted values from the model. The default format is a
plain matrix, but the functions also have an argument to return data in
the original (input) format.
plot(resid(model1, orig.format = TRUE))
plot(fitted(model1, orig.format = TRUE))
Another way to examine the factor model visually is to plot the Quasi-Maximum-Likelihood (QML) factor estimates against PCA and Two-Step @@ -299,7 +298,7 @@
plot.dfm
.
-plot(model1, method = "all", type = "individual")
plot(model1, method = "all", type = "individual")
The plot with the various estimates shows that the QML estimates are more volatile in the initial periods where there are many missing @@ -327,13 +326,13 @@
DFM forecasts can be obtained with the predict()
method,
+
DFM forecasts can be obtained with the predict()
method,
which dynamically forecasts the factors using the transition equation
(default 10 periods), and then also predicts data forecasts using the
observation equation. Objects are of class ‘dfm_forecast’
# 12-period ahead DFM forecast
-fc = predict(model1, h = 12)
+fc = predict(model1, h = 12)
print(fc)
#> 12 Step Ahead Forecast from Dynamic Factor Model
#>
@@ -379,7 +378,7 @@ Forecasting9.
+plot(fc, xlim = c(320, 370))
# Predicting with Two-Step estimates
diff --git a/docs/authors.html b/docs/authors.html
index 76318f1..dccde00 100644
--- a/docs/authors.html
+++ b/docs/authors.html
@@ -17,7 +17,7 @@
Krantz S, Bagdziunas R (2023). dfms: Dynamic Factor Models. -R package version 0.2.0, https://sebkrantz.github.io/dfms/. +R package version 0.2.1, https://sebkrantz.github.io/dfms/.
@Manual{, title = {dfms: Dynamic Factor Models}, author = {Sebastian Krantz and Rytis Bagdziunas}, year = {2023}, - note = {R package version 0.2.0}, + note = {R package version 0.2.1}, url = {https://sebkrantz.github.io/dfms/}, }diff --git a/docs/index.html b/docs/index.html index cb2b141..bf86a37 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ @@ -86,7 +86,6 @@ -
dfms provides efficient estimation of Dynamic Factor Models via the EM Algorithm. Estimation can be done in 3 different ways following:
Doz, C., Giannone, D., & Reichlin, L. (2011). A two-step estimator for large approximate dynamic factor models based on Kalman filtering. Journal of Econometrics, 164(1), 188-205. doi:10.1016/j.jeconom.2011.02.012
summary.dfm
: print method showed that model had AR(1) errors even though idio.ar1 = FALSE
by default.Added argument idio.ar1 = TRUE
allowing estimation of approximate DFM’s with AR(1) observation errors.
Added a small theoretical vignette entitled ‘Dynamic Factor Models: A Very Short Introduction’. This vignette lays a foundation for the present and future functionality of dfms. I plan to implement all features described in this vignette until summer 2023.
library(collapse)
-#> collapse 1.9.4, see ?`collapse-package` or ?`collapse-documentation`
+#> collapse 1.9.5, see ?`collapse-package` or ?`collapse-documentation`
#>
#> Attaching package: ‘collapse’
#> The following object is masked from ‘package:vars’:
diff --git a/docs/reference/ainv.html b/docs/reference/ainv.html
index 2953c54..55716a5 100644
--- a/docs/reference/ainv.html
+++ b/docs/reference/ainv.html
@@ -17,7 +17,7 @@