HDecomp (historical decomposition)
Moderators: EViews Gareth, EViews Moderator, EViews Esther

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 12637
 Joined: Tue Sep 16, 2008 5:38 pm
HDecomp (historical decomposition)
This thread is about the HDecomp addin, written by Eren Ocakverdi (Trubador), that performs historical decomposition on a VAR object.
Follow us on Twitter @IHSEViews

 Posts: 38
 Joined: Tue Jan 21, 2014 4:04 am
Re: HDecomp (historical decomposition)
Hi,
I don't understand how to interpret what each column of the histmat that I get refers to. Basically, all I want to do is find a measure of the output gap using hdecomp from the Blanchard Quah model (figure 8 in the BQ paper).
So HDdecomp creates a matrix of n(n+1) columns, where n is the number of variables in a VAR, a n(n+1) matrix of series.
The BQ program in the example file stops short of extracting the effect of demand shocks on output.
Perhaps then let me reference the case study provided by trubadour.
His VAR had the following variables: Dlog(imported price index), Dlog(gdp) and Dlog(cpi).
And there are three structural disturbances:
1)a component that affects all three variables
2) " that doesnt affect Dlog(imported price index)
3) " that affects only Dlog(cpi)
with the corresponding lr restrictions.
He pulls out the 12th column from the matrix, and that corresponds to core inflation. Could you help me understand the logic of that the ordering?
Thanks
I don't understand how to interpret what each column of the histmat that I get refers to. Basically, all I want to do is find a measure of the output gap using hdecomp from the Blanchard Quah model (figure 8 in the BQ paper).
So HDdecomp creates a matrix of n(n+1) columns, where n is the number of variables in a VAR, a n(n+1) matrix of series.
The BQ program in the example file stops short of extracting the effect of demand shocks on output.
Perhaps then let me reference the case study provided by trubadour.
His VAR had the following variables: Dlog(imported price index), Dlog(gdp) and Dlog(cpi).
And there are three structural disturbances:
1)a component that affects all three variables
2) " that doesnt affect Dlog(imported price index)
3) " that affects only Dlog(cpi)
with the corresponding lr restrictions.
He pulls out the 12th column from the matrix, and that corresponds to core inflation. Could you help me understand the logic of that the ordering?
Thanks
Re: HDecomp (historical decomposition)
For each series, there is a base forecast plus the total impact of structural shocks. Hence, the matrix dimension is equal to n(n+1). In your case, there are two variables (unemployment and gdp), so histmat will be a 2x3 matrix. Since gdp is the first variable, columns 1, 2 and 3 will correspond to the base forecast for GDP, historical impact of the first shock and the historical impact of the second shock, respectively.
Figure 8 of the paper is called "Output fluctuations due to demand". If this is what you want, then the third column of the histmat will be of your interest. However, an output gap estimation would require the construction of potential gdp first. And this would require the use of all three columns.
As a final remark, please be careful in replicating the results of the original paper since there are some data preparation steps like demeaning and detrending.
Figure 8 of the paper is called "Output fluctuations due to demand". If this is what you want, then the third column of the histmat will be of your interest. However, an output gap estimation would require the construction of potential gdp first. And this would require the use of all three columns.
As a final remark, please be careful in replicating the results of the original paper since there are some data preparation steps like demeaning and detrending.

 Posts: 38
 Joined: Tue Jan 21, 2014 4:04 am
Re: HDecomp (historical decomposition)
Hi Trubador,
Thank you for the clarification. On the point you made on constructing potential output first: if Histmat’s column 3 is the demand component of output, then it should correspond precisely to potential minus actual (assuming demand shocks do not affect potential GDP at all).
Actually, not quite rightthe third column of histmat is the first difference of the demand component of output, so presumably one has to pick a point where actual=output and undifference.
Something quite important I would like to draw your attention on: the third column of histmat looks nothing like figure 8 (output fluctuations due to demand) in the original paper.
I first thought that might be something to do with BQ splitting the gdp data in two samples, filtering the unemployment rate, putting a dummy in, an whatever other small adjustments. Except that these changes must be very, very slight, and in fact the IRFs from the Eviews sample program you wrote correspond pretty much exactly to those in the article. So something else is amiss here, but I cannot think what.
Do you have any suggestions?
By the way, I've just looked at the RATS' replication code for that paper, and from I can see what that uses for figure 8 is indeed the third column of the historical decompostion matrix (without any adjustment of sorts) I've attached the program output from that code to this post.
As a check to see whether I was hallucinating, I took the series that they get after detrending, demeaning etc and that they put into the VAR (gdpadjust and uradjust) and still what I get from the historical decomposition in eviews isn't what they get. I'm puzzled as I have to have this model working with eviews.
I look forward to hearing from you.
Regards
Thank you for the clarification. On the point you made on constructing potential output first: if Histmat’s column 3 is the demand component of output, then it should correspond precisely to potential minus actual (assuming demand shocks do not affect potential GDP at all).
Actually, not quite rightthe third column of histmat is the first difference of the demand component of output, so presumably one has to pick a point where actual=output and undifference.
Something quite important I would like to draw your attention on: the third column of histmat looks nothing like figure 8 (output fluctuations due to demand) in the original paper.
I first thought that might be something to do with BQ splitting the gdp data in two samples, filtering the unemployment rate, putting a dummy in, an whatever other small adjustments. Except that these changes must be very, very slight, and in fact the IRFs from the Eviews sample program you wrote correspond pretty much exactly to those in the article. So something else is amiss here, but I cannot think what.
Do you have any suggestions?
By the way, I've just looked at the RATS' replication code for that paper, and from I can see what that uses for figure 8 is indeed the third column of the historical decompostion matrix (without any adjustment of sorts) I've attached the program output from that code to this post.
As a check to see whether I was hallucinating, I took the series that they get after detrending, demeaning etc and that they put into the VAR (gdpadjust and uradjust) and still what I get from the historical decomposition in eviews isn't what they get. I'm puzzled as I have to have this model working with eviews.
I look forward to hearing from you.
Regards
 Attachments

 Ratsoutput.WF1
 (62.66 KiB) Downloaded 1101 times
Re: HDecomp (historical decomposition)
I am not going to delve into a deep discussion on the issues you mention, but they are not that much straightforward. Original paper has a very nice and a detailed discussion. And now you can carry out those analyses in EViews with the help of this addin. Replicating such a seminal paper is not an easy task, but for the sake of further clarifying the use of this addin I've prepared the code below with the data you have supplied:
Code: Select all
'Open the file
wfopen ratsoutput.wf1
'Create a copy of the page to compare the results
pagecopy
'Make the necessary transformations
series loggnp = log(gnp)
series loggd = log(gd87)
series logrgnp = loggnp  loggd + log(100)
series dlogrgnp = 100*d(logrgnp)
'Generate the dummies for two regimes
series dummy1 = @before("1974q1")
series dummy2 = @after("1974q1")
'Adjust the gdp series with respect to different regimes (demeaning)
equation eq1.ls dlogrgnp dummy1 dummy2
series gdpadjust = resid
series means_from_gnp = dummy1*c(1) + dummy2*c(2)
'Remove the trend in unemployment (detrending)
equation eq2.ls lhmur c @trend
series uradjust = resid
eq2.fit trend_from_ur
'Build and estimate the VAR Model
var bq.ls 1 8 gdpadjust uradjust @ c
%varsmpl = bq.@smpl
'Longrun restriction matrix
matrix(2,2) matc = NA
matc(1,2) = 0
'Estimate structural factorization
bq.svar(rtype=patlr,namelr=matc)
'Get the estimated factor
matrix bqfactor = bq.@svarbmat
'Adjust the sign
if bqfactor(1,2)<0 then
vector sign = @ones(2)
sign(2) = 1
bqfactor = bqfactor*@makediagonal(sign)
endif
'Undo the degreeoffreedom adjustment, which is the default estimation in EViews
!dofadjust = (bq.@regobs(bq.@ncoefs/bq.@neqn))/bq.@regobs
bqfactor = bqfactor*@sqrt(!dofadjust)
'Carry out the historical decomposition
bq.hdecomp(imp=7,fname=bqfactor)
'Retrieve the result as series
!k = 0
for !i = 1 to 2
for !j = 1 to 3
!k = !k+1
vector v_!k = @columnextract(histmat01,!k)
mtos(v_!k,histdecomp_!j_!i_)
delete v_!k
next
next
'Generate the series of interest
histdecomp_1_1_ = histdecomp_1_1_ + means_from_gnp
histdecomp_1_2_ = histdecomp_1_2_ + trend_from_ur
for !j = 1 to 3
histdecomp_!j_1_ = @cumsum(histdecomp_!j_1_,%varsmpl)/100
next
histdecomp_1_1_ = histdecomp_1_1_ + @elem(logrgnp,"1950q1")
series lessdemand = histdecomp_1_1_ + histdecomp_2_1_
'Selected graphical output from the paper
freeze(figure1_and_2) bq.impulse(40,a,g,imp=user,fname=bqfactor)
show figure1_and_2
graph figure7.line lessdemand
figure7.label(r) Output fluctuations absent demand
show figure7
graph figure8.line histdecomp_3_1_
figure8.label(r) Output fluctuations due to demand
figure8.recshade
figure8.draw(line, left) 0
show figure8
Re: HDecomp (historical decomposition)
Hi,
Does anybody know what the error message "(1002,1) is not a valid index for matrix SHOCK" stands for when using the addin? I have pm'ed trubador with more info on this problem, but if someone knows how to solve this problem off the top of one's head, I would greatly appreciate the help on this problem.
Thank you in advance,
Regards,
Vincent
Does anybody know what the error message "(1002,1) is not a valid index for matrix SHOCK" stands for when using the addin? I have pm'ed trubador with more info on this problem, but if someone knows how to solve this problem off the top of one's head, I would greatly appreciate the help on this problem.
Thank you in advance,
Regards,
Vincent
Re: HDecomp (historical decomposition)
That is because you are trying to use the addin for panel data, which would not work. And please see the following post before going any further on your study: VAR estimation in a Panel setting
Re: HDecomp (historical decomposition)
Hi guys,
I'm trying to replicate the BQ results in figure 8 of their paper (as was the gentleman above).
I've got the original data in the attached workfile and cannot, for the life of me, get the results to match using hdecomp.
I'd be very grateful if you could advise me where I am going wrong or if there is something wrong with the hdecomp function?
Thanks,
Jamie
I'm trying to replicate the BQ results in figure 8 of their paper (as was the gentleman above).
I've got the original data in the attached workfile and cannot, for the life of me, get the results to match using hdecomp.
I'd be very grateful if you could advise me where I am going wrong or if there is something wrong with the hdecomp function?
Thanks,
Jamie
 Attachments

 bq decomp.wf1
 (26.71 KiB) Downloaded 911 times

 Posts: 38
 Joined: Tue Jan 21, 2014 4:04 am
Re: HDecomp (historical decomposition)
Just run the program written by trubador, it will give the output for figure 8
Re: HDecomp (historical decomposition)
Hi fregensberg,
I ran the Hdecomp addin on the VAR, selected structural decomposition and looked at the histmat.
None of the columns looks anything like figure 8, whether the shocks are accumulated or not.
If you don't mind me asking, does it work on your machine?
Thanks,
Jamie
I ran the Hdecomp addin on the VAR, selected structural decomposition and looked at the histmat.
None of the columns looks anything like figure 8, whether the shocks are accumulated or not.
If you don't mind me asking, does it work on your machine?
Thanks,
Jamie
Re: HDecomp (historical decomposition)
Not the addin. The code in one of the previous posts in this thread: viewtopic.php?f=23&t=5901#p33926
Re: HDecomp (historical decomposition)
Hi Trubador,
Thanks for this very useful addin and the replication code.
I have a question, why do you adjust the sign of the BQfactor in the code? Thanks
C.
Thanks for this very useful addin and the replication code.
I have a question, why do you adjust the sign of the BQfactor in the code? Thanks
C.
HDecomp with a Cointegrated VAR
Does anybody know how to use this addin when the VAR contains Cointegration relationships. I tried but I receive the error message "RESGR is not defined". Thanks in advance for your attention.
Re: HDecomp (historical decomposition)
The addin works on the structural factorization matrix, which EViews does not estimate for VECs and BVARs at the moment.
Re: HDecomp (historical decomposition)
Hi Trubador,
Thanks for making historical decomposition available in Eviews.
I have a question. Say we have 3 variables: inflation, output gap and exchange rate. Then, in the histmat we will have 12 columns. In my understanding, the first columns is forecast base of inflation, the second column is the first structural shock (inflation shock), the third column is second structural shock (output gap), and 4th column is the third structural shock (exchange rate). What about column 5 to 8? Column five is the forecast base of output gap right? Is column 6 represents structural shock output gap, column 7 represents structural shock of inflation and column 8 represents structural shock of exchange rate?
looking forward for your kindly explanations.
Thanks for making historical decomposition available in Eviews.
I have a question. Say we have 3 variables: inflation, output gap and exchange rate. Then, in the histmat we will have 12 columns. In my understanding, the first columns is forecast base of inflation, the second column is the first structural shock (inflation shock), the third column is second structural shock (output gap), and 4th column is the third structural shock (exchange rate). What about column 5 to 8? Column five is the forecast base of output gap right? Is column 6 represents structural shock output gap, column 7 represents structural shock of inflation and column 8 represents structural shock of exchange rate?
looking forward for your kindly explanations.
Who is online
Users browsing this forum: No registered users and 2 guests