Open nk027 opened 3 years ago
Would be a nice addition, indeed. In related packages (e.g. vars
), they are visualized through stacked bar charts, might also be a possibility.
Yeah I think that'd be even better!
Will get onto it!
How to look for the fevd in the number form, contribution of each variable. Is there any way to plot it in the stacked histogram form. I have used fevd(x) , but i can not view the decomposition. Any help in this regard is appreciated.
Hi, you can access the draws of the FEVDs by using obj$fevd
where obj <- fevd(x)
. You can also access the quantiles for the FEVDs by using obj$quants
.
A plotting function is yet to be finally implemented, but you can take a look at 69_fevd_plot.R.
I have attached the image plot(fevd(x)) is giving error. In this second image is this the variance decomposition, top row being variables and first column period?
For the plotting function to work, you would have to source the code (commenting it out before) in the file that I sent you the link to. Did you do that?
With regards to the fevd
object it is an array with dimensions draws x shock x horizon x impact
. In the screenshot below, it would be interpreted as follows: "On impact, 100% of the variation in the first variable is due to a shock associated with the first column (or variable). For the second variable, around 95% of the variation is due to a shock of its own, the rest from the first variable (or rather the shock associated with it, ...." Hope that helps.
If I have n variables, how can I reflect the numerical form of this fevd into the matrix form of n x n. I directly check the form of quant as follows: How do I construct a final variance decomposition matrix?
Hey Curtis, from the outputs here, you could just subset, e.g., the median at a specific horizon, and should then get a variables variables* matrix.
I'm not 100% sure what the order was, but you can call dim(irf[["fevd"]][["quants"]])
and should have one dimension for the quantiles and one for the horizon, which you can identify via their lengths.
Hey @lqvecon,
I always mess these up, but quickly checked again and it seems to me that draws x shock x horizon x impact
is correct:
f$fevd[1, , 1, ]
[,1] [,2] [,3]
[1,] 1.00000000 0.00000000 0.0000000
[2,] 0.11747481 0.88252519 0.0000000
[3,] 0.02342656 0.00820949 0.9683639
Here we subset to the first draw (dim-1) on impact (dim-3). In row 1 (dim-2), we have a shock of 1 on 1 etc.
Also see:
f$fevd[1, 1, , ]
[,1] [,2] [,3]
[1,] 1.0000000 0.0000000000 0.00000000000
[2,] 0.9990679 0.0008683616 0.00006375813
[3,] 0.9975037 0.0022802601 0.00021599611
[4,] 0.9957108 0.0038347691 0.00045438926
[5,] 0.9939046 0.0053227681 0.00077259284
[6,] 0.9921923 0.0066457662 0.00116190901
[7,] 0.9906200 0.0077675053 0.00161247577
[8,] 0.9892005 0.0086854136 0.00211409150
[9,] 0.9879293 0.0094139586 0.00265676977
[10,] 0.9867938 0.0099751010 0.00323109692
[11,] 0.9857786 0.0103929632 0.00382844675
[12,] 0.9848679 0.0106909869 0.00444109283
where you can track a shock of 1 (on 1–3 in the columns) over time (rows).
We could add a quick and dirty plot for FEVDs: