Page 1 of 1
How to make impulse response lines an area
Posted: Tue Aug 25, 2020 1:47 am
by tony
Hi there,
I did a VAR model and obtained the IRF lines, and I want to make a confidence area and an estimated line.
How to do that?
Thanks.
Re: How to make impulse response lines an area
Posted: Tue Aug 25, 2020 10:46 am
by EViews Matt
Hello,
Is the issue that the confidence lines are not being shown or that you want the area between the confidence lines to be filled?
Re: How to make impulse response lines an area
Posted: Tue Aug 25, 2020 7:33 pm
by tony
Hello,
Is the issue that the confidence lines are not being shown or that you want the area between the confidence lines to be filled?
Yes, I want the area between the confidence lines to be filled.
Re: How to make impulse response lines an area
Posted: Wed Aug 26, 2020 4:04 pm
by EViews Matt
Unfortunately, I'm not aware of a simple way to accomplish what you want. I've reworked an old example of mine to show how you could create a graph with a filled area band for the confidence interval. This example is probably overkill, but it demonstrates the core task of creating a mixed type graph. The mixed graph then includes, at least, a band area element for the confidence interval and a line element for the response proper.
Code: Select all
' Generate example data
create u 100
series x = rnd
series y = nrnd
series z = nrnd
var v.ls 1 2 x y z
' Generate impulse data
v.impulse(20,m,se=a,matbyr=irf_data)
' Create individual graphs for each IRF
for !i = 1 to irf_data.@cols
vector irf = @columnextract(irf_data, !i)
vector se = @columnextract(irf_data_se, !i)
matrix m = @hcat(@hcat(@hcat(irf - se, irf + se), @hcat(irf - se, irf + se)), irf)
freeze(gr!i) m.mixed band(1, 2) line(3, 4, 5)
gr!i.setelem(1) fillcolor(@rgb(238,196,162))
gr!i.setelem(1) linecolor(@rgb(218, 124, 48)) linepattern(2)
gr!i.setelem(2) linecolor(@rgb(218, 124, 48)) linepattern(2)
gr!i.setelem(3) linecolor(@rgb(57, 106, 177)) linepattern(1)
gr!i.options linepat
gr!i.legend -display
next
' Alter vertical axes so that each variable uses the same scale.
for !i = 1 to irf_data.@cols step v.@neqn
!min = gr!i.@axismin("l")
!max = gr!i.@axismax("l")
for !j = !i + 1 to !i + v.@neqn - 1
if gr!j.@axismin("l") < !min then
!min = gr!j.@axismin("l")
endif
if gr!j.@axismax("l") > !max then
!max = gr!j.@axismax("l")
endif
next
for !j = !i to !i + v.@neqn - 1
gr!j.axis("l") range(!min, !max)
next
next
' Combine all individual graphs and display.
%all_graphs = @wlookup("gr*")
graph gr.merge {%all_graphs}
show gr
' Cleanup.
delete irf* se m gr?*