Skip to content

Commit a414489

Browse files
committed
Replace inv_sympd() -> inv(): more robust fitting.
1 parent 210b312 commit a414489

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: dfms
2-
Version: 0.2.1
2+
Version: 0.2.2
33
Title: Dynamic Factor Models
44
Authors@R: c(person("Sebastian", "Krantz", role = c("aut", "cre"), email = "[email protected]"),
55
person("Rytis", "Bagdziunas", role = "aut"))

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# dfms 0.2.1.9000
2+
3+
* Replace Armadillo `inv_sympd()` by Armadillo `inv()` in C++ Kalman Filter to improve numerical robustness at a minor performance cost.
4+
15
# dfms 0.2.1
26

37
* Fixed print bug in `summary.dfm`: print method showed that model had AR(1) errors even though `idio.ar1 = FALSE` by default.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
[![minimal R version](https://img.shields.io/badge/R%3E%3D-3.3.0-6666ff.svg)](https://cran.r-project.org/)
1212
[![status](https://tinyverse.netlify.com/badge/dfms)](https://CRAN.R-project.org/package=dfms)
1313
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
14-
[![R-CMD-check](https://github.com/SebKrantz/dfms/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/SebKrantz/dfms/actions/workflows/R-CMD-check.yaml)
1514
<!-- badges: end -->
1615

1716
<!-- **NOTE**: This package is under [rOpenSci Statistical Software Peer Review](https://stats-devguide.ropensci.org/). Peer review might result in changes to the API. -->

docs/index.html

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/news/index.html

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/KalmanFiltering.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Rcpp::List SKF(arma::mat X, arma::mat A, arma::mat C, arma::mat Q,
7070

7171
// Intermediate results
7272
VCt = Vp * Ci.t();
73-
S = inv_sympd(Ci * VCt + Ri); // .i();
73+
S = inv(Ci * VCt + Ri); // .i();
7474

7575
// Prediction error
7676
et = xt - Ci * Zp;
@@ -149,7 +149,7 @@ Rcpp::List FIS(arma::mat A,
149149
for (int i = T-1; i--; ) {
150150
Vfi = VTf.slice(i);
151151
Vpi = VTp.slice(i+1);
152-
Ji = Vfi * At * inv_sympd(Vpi); // .i();
152+
Ji = Vfi * At * inv(Vpi); // .i();
153153
ZsT.row(i) = ZTf.row(i) + (Ji * (ZsT.row(i+1) - ZTp.row(i+1)).t()).t();
154154
VsT.slice(i) = Vfi + Ji * (VsT.slice(i+1) - Vpi) * Ji.t();
155155
}
@@ -243,7 +243,7 @@ Rcpp::List SKFS(arma::mat X, arma::mat A, arma::mat C, arma::mat Q,
243243

244244
// Intermediate results
245245
VCt = Vp * Ci.t();
246-
S = inv_sympd(Ci * VCt + Ri); //.i();
246+
S = inv(Ci * VCt + Ri); //.i();
247247

248248
// Prediction error
249249
et = xt - Ci * Zp;
@@ -298,7 +298,7 @@ Rcpp::List SKFS(arma::mat X, arma::mat A, arma::mat C, arma::mat Q,
298298
VsT.slice(i) = Vf + Ji * (VsT.slice(i+1) - VTp.slice(i+1)) * Jimt;
299299
// Cov(Z_t, Z_t-1): Needed for EM
300300
if(i > 0) {
301-
Jimt = (VTf.slice(i-1) * At * inv_sympd(VTp.slice(i))).t(); // .i()
301+
Jimt = (VTf.slice(i-1) * At * inv(VTp.slice(i))).t(); // .i()
302302
VVsT.slice(i) = Vf * Jimt + Ji * (VVsT.slice(i+1) - A * Vf) * Jimt;
303303
}
304304
}

0 commit comments

Comments
 (0)