Skip to content

Commit edcf5a3

Browse files
authored
Merge pull request #74 from SebKrantz/development
Development
2 parents b5d3a85 + fae29f7 commit edcf5a3

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

R/EMBM_MQ.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ EMstepBMMQ = function(X, A, C, Q, R, Z_0, V_0, XW0, NW, dgind, dnkron, dnkron_in
5858
Qsr = (EZZ[sr, sr] - tcrossprod(A_new[sr, srp, drop = FALSE], EZZ_FB[sr, srp, drop = FALSE])) / TT
5959
Q_new[sr, sr] = if(rQi == 2L) Qsr else diag(diag(Qsr))
6060
} else Q_new[sr, sr] = diag(r)
61-
Q_new[rpC1nq, rpC1nq] = diag(diag(crossprod(Zsmooth[, rpC1nq, drop = FALSE]) + sum3(Vsmooth[rpC1nq, rpC1nq,, drop = FALSE])) / TT)
61+
Q_new[rpC1nq, rpC1nq] = diag(diag(crossprod(Zsmooth[, rpC1nq, drop = FALSE]) + sum3(Vsmooth[rpC1nq, rpC1nq,, drop = FALSE])) / TT, nrow = nq)
6262

6363
# E(X'X) & E(X'Z)
6464
# Estimate matrix C using maximum likelihood approach

R/init_cond.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ init_cond_MQ <- function(X, X_imp, F_pc, v, n, r, p, TT, nq, rRi, rQi) {
129129
Q[1:r, 1:r] <- switch(rQi + 1L, diag(r), diag(fvar(var$res)), cov(var$res))
130130
Q[(rpC+1):(rpC+nq), (rpC+1):(rpC+nq)] <- if(rRi == 2L)
131131
cov(res[, -seq_len(nm), drop = FALSE], use = "pairwise.complete.obs") else if(rRi == 1L)
132-
diag(fvar(res[, -seq_len(nm)], na.rm = TRUE)) else diag(nq)
132+
diag(fvar(res[, -seq_len(nm), drop = FALSE], na.rm = TRUE), nrow = nq) else diag(nq)
133133
diag(Q)[diag(Q) == 0] <- 1e-6 # Prevent singularity in Kalman Filter
134134

135135

tests/testthat/test-DFM.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,13 @@ expect_equal(mod$F_twostep, mod_BM$F_twostep, tolerance = 1e-2)
103103
expect_equal(mod$F_qml, mod_BM$F_qml, tolerance = 1e-2)
104104
expect_equal(mod$A, mod_BM$A, tolerance = 1e-1)
105105

106+
# testing #73
107+
y<-as.xts(rnorm(100),order.by = seq(from=as.Date("1980-04-01"),length.out=100,by="quarter")-1)
108+
x1<-as.xts(rnorm(100),order.by = seq(from=as.Date("1980-02-01"),length.out=100,by="month")-1)
109+
x2<-as.xts(rnorm(100),order.by = seq(from=as.Date("1980-02-01"),length.out=100,by="month")-1)
110+
111+
data<-cbind(y,x1,x2)
112+
data["1988-03-31",1]<-NA
113+
data1<-data[time(data)<="1987-12-31"]
114+
115+
expect_visible(DFM(data1[,c("x1","x2","y")], r = 1, p = 1, quarterly.vars = c("y")))

0 commit comments

Comments
 (0)