BoxJenk Instruction

Questions and discussions on Time Series Analysis
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

BoxJenk Instruction

Unread post by ivory4 »

BoxJenk can estimate a ARIMA model and shows the coefficients. Phi(1),...Phi(p), Theta(1),...Theta(q)
Is there a embedded function to generate roots of Polynomial Phi(z)=(1-Mu1(z))(1-Mu2(z))........(1-Mu(p))
And if there are complex roots, how will rats deal with them?
Because I may need to draw analytical spectral density using Mus.

Thanks
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BoxJenk Instruction

Unread post by TomDoan »

There is, but before you do that, you might want to look at the ARMASpectrum procedure, which directly computes the theoretical spectral density for an ARMA equation. This is an example from the Brockwell and Davis textbooks:

Code: Select all

*
* Example 4.4.1 from pp 133-134
*
open data sunspots.dat
cal 1770
data 1770:1 1869:1 spots
boxjenk(ar=2,demean,maxl,method=init,define=ar2) spots
@armaspectrum(footer="Figure 4-14. Spectral Density of Sunspot Data") ar2
The functions for extracting the roots are %EQNLAGPOLY, which extracts the lag polynomial, and %POLYCXROOTS, which finds the roots of the lag polynomial. You would use them in combination as follows:

Code: Select all

boxjenk(....,define=bjeq)
compute MAroots=%polycxroots(%eqnlagpoly(bjeq,%mvgavge))
compute ARroots=%polycxroots(%eqnlagpoly(bjeq,the dependent variable))
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

Re: BoxJenk Instruction

Unread post by ivory4 »

For procedure @armaspectrum

Code: Select all

cset 1 =1.0/%z(t,1)
Why take reciprocal again? I think previously that spectrum is calculated = sigma^2/2pi*(Phi(z)Phi(inverse(z)) (Phi is transfer func)

Code: Select all

 trfunc(...) 1
Cmult(...) 1 1 
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BoxJenk Instruction

Unread post by TomDoan »

The transfer function for the ARMA equation is the FFT of the lag polynomial in the (infinite) AR representation A(L)y(t)=u(t). The estimated spectral density of y(t) is sigmau^2/|A(w)|^2. So the TRFUNC makes series 1 = A(w), the CMULT then replaces that with |A(w)|^2/sigmau^2 so you have the flip that over to get the spectral density.
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

Re: BoxJenk Instruction

Unread post by ivory4 »

Morley Nelson Zivot ReStat 2003 has a UCUR, unrestricted unobserved component model, which allows correlation between cycle error and trend error. The analytical spectrum for differenced Real GDP deltaYt is not readily availlable with @ARMASPECT. Then I consider DYt=DTrend+Dcycle, f(DYt)=1/2PI*[1, (1-L)(Phi(L)][sigmaeta^2,sigma-eta-theta|sigma-eta-theta, sigmatheta^2][1, Conjugate((1-L)(Phi(L)))]'

= sigmaeta^2/2PI + |1-L|^2|Phi(L)|^2sigmatheta^2/2PI + sigma-eta-theta/2PI*{(Phi(L)(1-L)+conjugate(Phi(L)(1-L)}

the first one is white noise spectrum, readily available.
the second one is differenced-cycle spec, If I use estimated cycle to fit AR() and use @ARMASPECTrum then mutiply by |1-L|^2 to draw this one? |1-L|^2 is equal to 2-cosine(w), how to choose w to match the @ARMAspectrum calculated part?

How about the last part? Represent it use cosine function or there is a convenient way ?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BoxJenk Instruction

Unread post by TomDoan »

The reduced form ARMA model in that case is fairly complicated (if eta and epsilon are correlated). Instead, you'll probably find it easier to use the SSMSpectrum procedure, which computes the spectral density (matrices) for a state space model. In the MNZ paper, they're actually using the state space representation for estimation, not the reduced form ARMA model.
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

Re: BoxJenk Instruction

Unread post by ivory4 »

TomDoan wrote:The reduced form ARMA model in that case is fairly complicated (if eta and epsilon are correlated). Instead, you'll probably find it easier to use the SSMSpectrum procedure, which computes the spectral density (matrices) for a state space model. In the MNZ paper, they're actually using the state space representation for estimation, not the reduced form ARMA model.

How to define a series in terms of |1-exp(-iw)|^2?

Should I define it as 2-cosine(w) or define 1-exp(-iw) first and use cmult with its conjugate?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BoxJenk Instruction

Unread post by TomDoan »

ivory4 wrote:
How to define a series in terms of |1-exp(-iw)|^2?

Should I define it as 2-cosine(w) or define 1-exp(-iw) first and use cmult with its conjugate?
Assuming you mean 2-2*cos(w), you can do either. The first is clearly simpler.
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

Re: BoxJenk Instruction

Unread post by ivory4 »

In BN decomposition, yt=a*t+PSI(1)Sum(et)+ [(PSI(L)-PSI(1))/(1-L)]et
PSI(L) Sig_e^2 is estimated from ARMA(2,2)
specturm for Difference Cycle (1-L)ct=(PSI(L)-PSI(1))et
is a*|PSI(exp(-iw)-PSI(1)|^2
a=Sig_E^2/2*PI

How to load PSI(L)-PSI(1) with TRFUNC ?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BoxJenk Instruction

Unread post by TomDoan »

When you compute the transfer function of PSI, PSI(1) is just the value at entry 1 (zero frequency). So

CSET target = %z(source,t)-%z(source,1)

will give you the FT of PSI(L)-PSI(1), where target is the frequency domain series for PSI(L)-PSI(1), and source is the frequency domain series for the transfer function of PSI.
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

%zlag

Unread post by ivory4 »

To use %zlag(t,x) for tranfer function in @ARMASPECTURM procedure

Code: Select all

frequency 1 512
compute scale=0.05^2
equation(noconstant, coeffs=||1.2,-0.3,-1.4,0.5||) arma y 2 2
trfunc(equation=arma) 1
cmult(scale=2*%pi/scale) 1 1
cset 1 = 1.0/%z(t,1)
ctor 1 512/2
# 1
# abc
set freqs 1 512/2 = (t-1)*2.0/512
scatter(style=lines,hlabel="Frequency as fraction of pi")
# freqs armasp 1 512/2
is equivalent to

Code: Select all


frequency 1 512
compute scale=0.05^2
cset 2 = (1-1.2*%zlag(t,1)+0.3*%zlag(t,1)*%conjg(%zlag(t,1)))/$
          (1-1.4*%zlag(t,1)+0.5*%zlag(t,1)*%conjg(%zlag(t,1)))
cmult(scale=2*%pi/scale) 1 1
cset 1 = 1.0/%z(t,1)
ctor 1 512/2
# 1
# aaa
scatter(style=lines,hlabel="Frequency as fraction of pi")
# freqs aaa 1 512/2

what is wrong with the CSET part?
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

Re: BoxJenk Instruction

Unread post by ivory4 »

TomDoan wrote:When you compute the transfer function of PSI, PSI(1) is just the value at entry 1 (zero frequency). So

CSET target = %z(source,t)-%z(source,1)

will give you the FT of PSI(L)-PSI(1), where target is the frequency domain series for PSI(L)-PSI(1), and source is the frequency domain series for the transfer function of PSI.

For example if paramets are estimated like these,
AR Coeff Ph1=1.2;Phi2=-0.3
MA Coeff Theta1=-1.4, Theta2=0.5

Code: Select all

frequency 2 512
compute scale=0.05^2
equation(noconstant, coeffs=||1.2,-0.3,-1.4,0.5||) arma y 2 2
trfunc(equation=arma) 1
*PSI^-1
cset 1 = 1.0/%z(t,1) 
Is this the way to get PSI?
OR I need to get Phi DIRECTLY instead of Phi^-1 by change the input of equation(coeffs=||-Theta1,-Theta2, -Phi1, -Phi2||
Then

Code: Select all

cset  2 = %z(1,t)-%z(1,1)
cmult(scale=2*%pi/scale) 2 2
ctor 1 512/2
# 2
# abc

Last edited by ivory4 on Fri Jun 25, 2010 1:12 pm, edited 1 time in total.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: %zlag

Unread post by TomDoan »

ivory4 wrote:To use %zlag(t,x) for tranfer function in @ARMASPECTURM procedure

cset 2 = (1-1.2*%zlag(t,1)+0.3*%zlag(t,1)*%conjg(%zlag(t,1)))/$
(1-1.4*%zlag(t,1)+0.5*%zlag(t,1)*%conjg(%zlag(t,1)))

what is wrong with the CSET part?
First off, you're not fully using the %ZLAG function. You can simplify the whole calculation to:

cset 1 = (1-1.2*%zlag(t,1)+0.3*%zlag(t,2))/$
(1-1.4*%zlag(t,1)+0.5*%zlag(t,2))

Regarding the CSET, that's a situation in which the error message tells you exactly what the problem is.

## SR3. Tried to Use Series Number 2, Only 1 Are Available

You tried to use series number 2 when you only asked for 1. My CSET creates series 1.
ivory4
Posts: 144
Joined: Mon Aug 24, 2009 12:16 pm

Re: BoxJenk Instruction

Unread post by ivory4 »

What does %z return?
Manual only says that ARRAY of COMPLEX series defined by FREQUENCY, did not mention its parameter setting
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BoxJenk Instruction

Unread post by TomDoan »

See page 195 of the reference manual (under FREQUENCY).
Post Reply