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.
Extracting strucutral shocks from SVAR
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Re: Extracting strucutral shocks from SVAR
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.
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.
Re: Extracting strucutral shocks from SVAR
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.
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
Re: Extracting strucutral shocks from SVAR
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})Who is online
Users browsing this forum: No registered users and 1 guest
