Skip to content

Error in calculating mdd for bivariate MF-BVAR models #23

@sunyoung73ji

Description

@sunyoung73ji

Hello! :) I'm currently having difficulty calculating the MDD for bivariate MF-BVAR models. I have six monthly indicators and quarterly hpi data. I want to compute the MDD for the bivariate MF-BVAR models between hpi and each indicator, but I keep encountering the following error:

'Error in apply(Y[, freq == "m"], 2, is.na) :
dim(X) must have a positive length value'

However, there seems to be no issue when calculating the MDD for multivariate models with two or more indicators along with hpi. Please look at the following code. When I add only one indicator to mflist, I encounter the error, but with two or more, I can obtain the MDD.


mflist <- list()
#mflist[['dax']] <- ts(dax, start = c(2007, 4), frequency = 12)
mflist[['cpi']] <- ts(cpi, start = c(2007, 4), frequency = 12)
mflist[['hpi']] <- ts(hpi, start = c(2007, 2), frequency = 4)

c_interval <- t(sapply(mflist, CI, ci=0.95))
prior_intervals <- c_interval[,c('upper','lower')]
moments <- interval_to_moments(prior_intervals)

prior <- set_prior(Y = mflist, n_lags = 5, n_reps = 1000,
                   d = 'intercept',
                   prior_psi_mean = moments$prior_psi_mean,
                   prior_psi_Omega = moments$prior_psi_Omega,
                   n_fcst = 24,
                   aggregation = "average") # forecast 24 months ahead


mfbvar <- estimate_mfbvar(prior, prior = 'ss', variance = 'iw')
mdd(mfbvar)


Could you please advise me to solve this problem?
Thank you in advance!

you can find the data here (all variables are log-differenced):

dax <- c(
  0.0210208714, 0.0115995430, 0.0381296902, 0.0351225865, -0.0841469730,
  0.0220691589, 0.0308116863, -0.0073562701, 0.0077104509, -0.0459201627,
  -0.0314345640, -0.0481828142, 0.0155563311, -0.0023364747, -0.0481093988,
  -0.0286984452, -0.0114323500, -0.0461231012, -0.2237445071, -0.0325402685,
  -0.0261829952, -0.0014145884, -0.0326075965, -0.0487289541, 0.0756980526,
  0.0592410660, 0.0132207689, 0.0268199289, 0.0656594330, 0.0345225028,
  0.0124849128, 0.0099508413, 0.0174303621, 0.0166116769, -0.0234752993,
  0.0748180864, 0.0159662680, -0.0637937051, 0.0288340481, 0.0143127967,
  -0.0059073927, 0.0149225240, 0.0344798460, 0.0591198871, 0.0227186615,
  0.0043557414, 0.0561068704, -0.0333309675, 0.0017759685, 0.0097389527,
  -0.0123045357, 0.0327373718, -0.2159789815, -0.0952049924, 0.0945431298,
  -0.0073821309, -0.0034890913, 0.0574219378, 0.0881430114, 0.0349949609,
  -0.0572929921, -0.0493798744, -0.0246701275, 0.0680222600, 0.0621511758,
  0.0378666621, 0.0156350968, -0.0098531667, 0.0374203248, 0.0095248564,
  -0.0098939220, 0.0234584489, -0.0149767762, 0.0621947538, -0.0139142225,
  0.0190843686, 0.0283291709, 0.0093335020, 0.0571496195, 0.0321556778,
  -0.0027477093, 0.0195940364, -0.0057543323, -0.0146085884, -0.0043199380,
  0.0262817185, 0.0391677100, -0.0079347873, -0.0403590293, 0.0289933544,
  -0.0499589327, 0.0463717964, 0.0238067003, 0.0241594997, 0.0765136917,
  0.0598505336, 0.0119315556, -0.0362173873, -0.0162724983, 0.0153410130,
  -0.0321038514, -0.0913114716, 0.0476930801, 0.0624628994, -0.0368554257,
  -0.0891720669, -0.0568994080, 0.0350455169, 0.0314633701, -0.0171441862,
  -0.0004348846, 0.0179361453, 0.0685333809, -0.0068587704, 0.0264498673,
  -0.0121363892, 0.0545530364, 0.0272918596, 0.0143335355, 0.0173963116,
  -0.0049331592, 0.0348151634, 0.0153386638, -0.0183995600, -0.0092490162,
  0.0267016887, 0.0538651073, 0.0038792781, -0.0063155933, 0.0039217185,
  -0.0548846076, -0.0478017377, 0.0320240414, 0.0223966039, -0.0111506395,
  -0.0007542676, 0.0006210201, -0.0167319416, -0.0358246677, -0.0359814330,
  -0.0442273980, -0.0028575609, 0.0406223103, 0.0212661309, 0.0209506824,
  -0.0010267499, 0.0113181025, 0.0270988242, -0.0491369052, 0.0585968602,
  0.0323549090, 0.0344937681, 0.0027843113, -0.0052160232, 0.0079563961,
  -0.2787368261, 0.0068759905, 0.0589472742, 0.1155108035, 0.0420819034,
  0.0188796295, 0.0229869591, -0.0111888030, 0.0007493698, 0.0359441134,
  0.0075967103, 0.0169345350, 0.0426524623, 0.0415879580, -0.0020845684,
  0.0224927419, 0.0066952210, 0.0204241553, 0.0071960154, 0.0102541827,
  0.0012938153, -0.0285036834, -0.0134725997, -0.0382911232, -0.0553133867,
  -0.0165786834, -0.0058413403, -0.0256364714, -0.0343558319, 0.0402412489,
  -0.0342980225, 0.0219169677, 0.0683298694, -0.0039444074, 0.0206153023,
  0.0389949378, 0.0129467612, 0.0072029141, 0.0169598725, 0.0113985958,
  0.0160833066, -0.0116375298, 0.0124148770, -0.0138123623, 0.0004151994,
  0.0517433830
)


cpi <- c(
  3.421949e-03, 1.285583e-04, 2.200683e-04, 2.991822e-03, 7.573014e-04,
  2.882468e-03, 3.502666e-03, 7.971361e-03, 1.180742e-03, 1.551776e-03,
  1.997345e-03, 1.076072e-03, 1.440401e-03, 3.624166e-03, 2.418888e-03,
  4.514742e-03, -2.091488e-03, 2.062724e-03, -1.282320e-03, -2.439978e-03,
  -2.411692e-03, 5.083342e-04, 2.748292e-03, -3.233075e-03, 3.383509e-05,
  3.871869e-04, 2.521607e-03, -6.462024e-04, 2.869723e-03, -2.125515e-03,
  1.890191e-03, 7.507979e-04, 3.539148e-03, -6.090657e-04, 3.470256e-05,
  2.908550e-03, 7.117895e-04, 8.491295e-04, -4.556957e-04, 5.658585e-04,
  1.288805e-03, 1.023589e-03, 1.843402e-03, 2.591125e-03, 3.102646e-03,
  1.528623e-03, 2.816665e-03, 2.929426e-03, 9.237205e-04, 1.215559e-03,
  1.070699e-03, 1.136561e-03, 1.273823e-03, 2.645859e-03, 2.080522e-03,
  1.965247e-03, -4.774183e-04, 3.893266e-03, 2.315451e-03, 3.331489e-03,
  -2.275364e-04, 5.761129e-05, -1.107425e-03, 1.441564e-03, 4.656634e-03,
  1.885799e-03, 1.547217e-03, 8.275479e-04, 1.204143e-03, 1.233706e-03,
  1.096041e-03, 1.760404e-04, 6.295074e-04, 2.566338e-03, 8.913336e-04,
  1.890254e-03, 4.298011e-04, 5.181289e-04, -1.050205e-04, 3.360305e-03,
  2.593154e-03, -1.296685e-05, 1.384176e-03, -1.181841e-04, -1.565062e-03,
  -1.148653e-03, 1.708177e-03, 5.810279e-04, 6.233925e-04, 4.093822e-04,
  -1.236961e-04, 2.383374e-03, -2.503684e-03, -2.728707e-03, 4.003980e-03,
  2.704227e-03, 2.349644e-03, 1.538716e-03, -4.788312e-04, -4.906213e-04,
  -2.187303e-04, -5.964867e-04, 1.753494e-03, -2.751741e-03, -1.349025e-03,
  -4.280035e-04, 7.091174e-05, 1.372278e-03, 2.542391e-03, 2.293922e-03,
  3.616350e-04, 6.641572e-04, -2.726073e-05, 1.443233e-03, 2.435285e-03,
  -1.530154e-03, 4.911365e-03, 1.579289e-03, 2.421390e-03, -5.893851e-04,
  4.013436e-04, -5.923769e-04, 2.159205e-03, 1.672468e-03, 2.115565e-03,
  4.606171e-04, 2.941810e-04, 1.086921e-03, 2.774866e-03, 1.099364e-03,
  6.454277e-04, 1.019935e-04, 3.835245e-03, 4.410956e-03, 4.259166e-06,
  1.610113e-03, 2.268797e-03, 2.550036e-03, 2.021839e-03, -9.038428e-04,
  -8.281639e-04, -2.824342e-03, 1.618694e-03, 1.237922e-03, 5.673914e-03,
  1.857255e-03, 2.090041e-03, 1.554950e-03, 5.375420e-04, 8.030342e-04,
  5.740253e-04, -2.494418e-03, 5.020574e-03, 2.091625e-03, 7.367329e-05,
  -6.760454e-04, -1.517710e-03, -8.850859e-05, 4.551716e-04, -1.012598e-02,
  1.647796e-03, 1.001611e-03, 1.894510e-03, 1.809671e-03, 1.787169e-03,
  1.524509e-02, 2.211461e-03, 2.511909e-03, 1.080568e-03, 2.168796e-03,
  2.630533e-03, 3.310471e-03, 2.376406e-03, 3.785229e-03, 4.410583e-03,
  5.388374e-03, 3.068107e-03, 7.467588e-03, 3.379116e-03, 1.739787e-02,
  4.947693e-03, 9.477781e-03, 8.622562e-05, 3.713700e-03, 4.426699e-03,
  1.851200e-02, 6.657766e-03, 5.458855e-03, -3.487605e-03, 1.232332e-02,
  3.550463e-03, 5.455758e-03, 2.685571e-03, -2.670526e-04, 2.885344e-03,
  2.159832e-03, 3.698031e-03, 2.804774e-03, -1.138347e-04, -1.170011e-04,
  1.398571e-03
)

hpi <- c(
  0.0124269344, 0.0088300796, -0.0002018073, 0.0133747834, -0.0048233605,
  -0.0085420567, 0.0023566688, -0.0011841842, 0.0079377284, 0.0064045986,
  0.0151997196, -0.0146145343, 0.0079479453, 0.0077010990, -0.0063140169,
  0.0266969274, 0.0051661362, 0.0017115265, 0.0072166719, 0.0082802480,
  0.0056757617, 0.0199374049, 0.0144094497, -0.0018981385, 0.0117352675,
  0.0025052690, 0.0027258812, 0.0104599969, 0.0120312830, 0.0094239188,
  0.0013957864, 0.0192994879, 0.0135535040, 0.0079902690, 0.0149033884,
  0.0245509578, 0.0211521489, 0.0195009654, 0.0146492295, 0.0101684094,
  0.0136256149, 0.0164957674, 0.0186893511, 0.0164634222, 0.0139835354,
  0.0183855857, 0.0101490479, 0.0099244680, 0.0208371406, 0.0098212484,
  0.0214134931, 0.0199084792, 0.0130957151, 0.0243937483, 0.0259963127,
  0.0262438352, 0.0321042819, 0.0352908028, 0.0249990799, 0.0179931139,
  0.0134833329, -0.0134818450, -0.0542328104, -0.0159266229, -0.0176073777,
  -0.0189710228, -0.0215395656
)


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions