Portmanteau for VAR(p)

For posting your own programs to share with others

Moderators: EViews Gareth, EViews Moderator

Posts: 86
Joined: Mon Nov 04, 2013 6:22 pm
Location: Here

Portmanteau for VAR(p)

Postby NicolasR » Fri Aug 25, 2017 5:02 pm

Just as an academic exercise the following code performs the estimation of the multivariate Ljung Box test for VAR already available in eviews.

Best regards,

Code: Select all

'Nicolás Ronderos Pulido - Time series analysis
'Test: Portmanteau for VAR(p)
'Lutkepohl (2005)
'H0: no autocorrelation until lag h
!h=12 'Max h
%var="var01" 'Estimated VAR(P)
group resids
for !i=1 to {%var}.@neqn
   if !i<10 then
      resids.add resid0!i
      resids.add resid!i
'Var-cov-aut error matrix
for !i=0 to !h
   matrix(@rows(U),@rows(U)) C!i=0
   for !t=1 to @columns(U)
      if !i+!t<=@columns(U) then
         matrix(@rows(U),@rows(U)) C!i=C!i+@columnextract(U,!i+!t)*@transpose(@columnextract(U,!t))
         statusline !t
'Q and adjusted Q
vector(!h) Q=0
vector(!h) Qa=0
for !j=1 to !h
   for !i=1 to !j
vector Qsa={%var}.@regobs*Q 'T
vector Qa=({%var}.@regobs)^2*Qa 'T^2/T-i
vector(!h) pvaloresQsa=0
vector(!h) pvaloresQa=0
for !i=1 to !h
   if !h>2 then
freeze(resultado) var01.qstats(!h)

Return to “Program Repository”

Who is online

Users browsing this forum: No registered users and 1 guest