Extracting strucutral shocks from SVAR

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

basher
Posts: 7
Joined: Tue Nov 04, 2008 3:44 am

Extracting strucutral shocks from SVAR

Postby basher » Tue Feb 21, 2012 11:10 pm

Hello,

I have estimated a SVAR with LR restrictions. In Eviews, I think, structural shocks (u) are related to VAR residuals (e) in the following way:
u = inverse(B)A*e

Now, I want to recover the structural shocks. Could you help me in verifying whether the following Eviews language, for a bivariate VAR, is correct for this purpose:

'make matrix inv(B)*A
matrix p = @inverse(var01.@svarbmat)*var01.@svaramat
'get residuals
var01.makeresids r1 r2
group g r1 r2
'convert residuals to matrix
stom(g,r)
'make u matrix
matrix u = r*p

Thank you.

abossie
Posts: 15
Joined: Tue Jan 31, 2012 10:54 am

Re: Extracting strucutral shocks from SVAR

Postby abossie » Sat Dec 07, 2013 2:03 pm

I am bumping this becuase I have a similar question. Is this the right way to calculate the structural shocks using the A and B matrix?

I was using the HDecomp add-in, but for some reason when I try to run it in a loop more than twice I get an error message.

abossie
Posts: 15
Joined: Tue Jan 31, 2012 10:54 am

Re: Extracting strucutral shocks from SVAR

Postby abossie » Sat Dec 07, 2013 3:24 pm

I figured it out. I checked this against the results for HDecomp. This is probably an insanely crude way to go about it, but it functions. Feel free to double check this or tell me how I could do it more efficiently. For instance, I know my C matrix is weird because the notation Eviews uses is the opposite of what I am used to which gets me turned around.

Essentially, I calculated Ae=Bu for every individual time period separately and then dumped them into a matrix. I needed this for a six variable SVAR.

Code: Select all

!variables=6 var.makeresids e1 e2 e3 e4 e5 e6 group evec e1 e2 e3 e4 e5 e6 stom(evec, reduced) matrix mat_a=var.@svaramat matrix mat_b=var.@svarbmat matrix mat_c=(@inverse(mat_a))*mat_b !rowcount=@rows(reduced) matrix(!rowcount, !variables) struct for !i=1 to !rowcount vector reducedt=@rowextract(reduced, !i) vector primative=@inverse(mat_c)*(@transpose(reducedt)) rowvector primativeprime=@transpose(primative) rowplace(struct},primativeprime, !i) delete reducedt primativeprime primative next 'i

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Extracting strucutral shocks from SVAR

Postby trubador » Sun Dec 08, 2013 7:11 am

I have not checked it, but the following should work for a more generic use:

Code: Select all

'Name of the VAR model %myvar = "core" 'Type of factorization for the decomposition %imp = "struct" 'Make some name reservations for objects to be generated %resgr = @getnextname("resgr") %resmat = @getnextname("resmat") %srmat = @getnextname("srmat") %sresids = @getnextname("sresids") 'Gather the page sample %pagesmpl = @pagesmpl 'Retrieve the residuals and convert to matrix {%myvar}.makeresids(n={%resgr}) smpl @all 'This is necessary to match the workfile range stomna({%resgr},{%resmat}) 'Generate the matrix of structural residuals and convert back to group matrix {%srmat} = @transpose(@inverse({%myvar}.@svarbmat)*{%myvar}.@svaramat*@transpose({%resmat})) mtos({%srmat},{%sresids})


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 3 guests