procedure plotting the characteristic roots for ARIMA models

For questions and discussion related to graphs, reports, and other output, including issues related to presenting or publishing results.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

procedure plotting the characteristic roots for ARIMA models

Unread post by ac_1 »

Hi Tom,

Further to viewtopic.php?f=4&t=3566 attached is a procedure for calculating roots of the characteristic polynomial and inverse roots of the characteristic polynomial for ARIMA models.

The procedure plots the inverse roots for non-seasonal ARIMA models, e.g. https://estima.com/ratshelp/index.html?arimarpf.html

Code: Select all

*===============================
source(noecho) "path to acbjCR.src"

open data quarterly.xls
calendar(q) 1960:1
data(format=xls,org=columns) / tbill r10

* Compute spread and first difference of spread:
set spread = r10 - tbill
diff spread / dspread

* ARMA(2,(1,7))
boxjenk(constant,ar=2,ma=||1,7||) spread 1961:4 2008:1

* characteristic roots
@ACBJCR(CONST=0,ARNUMB=2,MANUMB=2,COEFFS=%BETA,TITLE="inverse roots of the characteristic polynomial",FPLOT=1) spread
I think it's correct, please check! And could be improved upon - any pointers greatly appreciated.

How would I extend to include the inverse roots for seasonal ARIMA models? for e.g. AUTOBOX.rpf

Code: Select all

*===============================
cal(m) 1992:1
open data x12test.xls
data(format=xls,org=columns) 1992:1 2008:7 u11bvs
set ldata = log(u11bvs)
*
@bjdiff(diffs=2,sdiffs=1) ldata
*
@gmautofit(diffs=%%autod,sdiffs=%%autods,const=%%autoconst,report) ldata
*
boxjenk(diffs=%%autod,sdiffs=%%autods,const=%%autoconst,$
  ar=%%autop,sar=%%autops,ma=%%autoq,sma=%%autoqs) ldata
Amarjit
Attachments
acbjCR.src
(6.4 KiB) Downloaded 837 times
Last edited by ac_1 on Tue Jan 24, 2023 10:30 am, edited 1 time in total.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by ac_1 »

Hi Tom,

I am confused in understanding seasonal characteristic roots :?:

From https://estima.com/textbooks/johnston-d ... n4p236.rpf specification ARIMA(1,0,0)*(1,0,0)[12], BOXJENK with SAR=1 requests one seasonal AR parameter, which, because this is monthly data, will be on lag 12.

Code: Select all

boxjenk(constant,ar=1,sar=1,define=multar) hs * 1984:12
has 13 AR roots = 1 AR root + 12 seasonal AR roots, but there are only 2 coeffs + the constant? And it doesn't appear to be estimating a separate AR(1) and then a separate AR(12) and putting both the characteristic roots plots 'together', or easier in separate plots!

Further, from p.346, Forecasting Methods,3e, by Makridakis, Wheelwright, and Hyndman (1998, Wiley), specification ARIMA(1,1,1)*(1,1,1)[4], quarterly data, it's simple to multiply out the factors, but the general model has 8 AR terms at lags 1,2,4,5,6,8,9 and 10 (implying 8 roots) and 3 MA lagged terms at 1,4,5 (implying 3 roots). Accordingly, shouldn't ARIMA(1,1,1)*(1,1,1)[4] have 5 AR roots and 5 MA roots?

I'd be grateful for a response.

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

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by TomDoan »

ac_1 wrote:Hi Tom,

I am confused in understanding seasonal characteristic roots :?:

From https://estima.com/textbooks/johnston-d ... n4p236.rpf specification ARIMA(1,0,0)*(1,0,0)[12], BOXJENK with SAR=1 requests one seasonal AR parameter, which, because this is monthly data, will be on lag 12.

Code: Select all

boxjenk(constant,ar=1,sar=1,define=multar) hs * 1984:12
has 13 AR roots = 1 AR root + 12 seasonal AR roots, but there are only 2 coeffs + the constant? And it doesn't appear to be estimating a separate AR(1) and then a separate AR(12) and putting both the characteristic roots plots 'together', or easier in separate plots!

Further, from p.346, Forecasting Methods,3e, by Makridakis, Wheelwright, and Hyndman (1998, Wiley), specification ARIMA(1,1,1)*(1,1,1)[4], quarterly data, it's simple to multiply out the factors, but the general model has 8 AR terms at lags 1,2,4,5,6,8,9 and 10 (implying 8 roots) and 3 MA lagged terms at 1,4,5 (implying 3 roots). Accordingly, shouldn't ARIMA(1,1,1)*(1,1,1)[4] have 5 AR roots and 5 MA roots?

I'd be grateful for a response.

Cheers,
Amarjit
That's just wrong. The number of free coefficients has nothing to do with the number of roots. The number of roots (counting multiplicities) is equal to the degree of the polynomial---that's the fundamental theorem of algebra. If you have a multiplicative model, the set of roots of the combined polynomials is the union of the set of roots of one and the roots of the other. (In order for the product to be zero, one of the two factors must be zero). 1-z^4 has *no* estimated parameters but 4 roots (+1, -1, +i, -i).

This uses the polynomial functions to graph the (inverted) roots of the MA polynomial from another of the MWH examples.

Code: Select all

*
* Makridakis et al, Forecasting Methods and Applications, 3rd edition
* Example 7/7 on pp 364-365
*
open data writing.dat
calendar(m) 1963
data(format=free,org=columns) 1963:1 1972:12 writing
*
boxjenk(diffs=1,sdiffs=1,ma=1,sma=1,maxl,define=deq) writing
*
set ustd = %resids/sqrt(%seesq)
*
graph(footer="Figure 7-25 Analysis of Residuals")
# ustd
@regcorrs ustd
compute mapoly=%eqnlagpoly(deq,%mvgavge)
compute maroots=%polycxroots(mapoly)
ewise maroots(i)=1.0/maroots(i)
set realz 1 %size(maroots) = %real(maroots(t))
set imagz 1 %size(maroots) = %imag(maroots(t))
scatter
# realz imagz
set unitr 1 1001 = cos(2*%pi*(t-1)/1000)
set unitc 1 1001 = sin(2*%pi*(t-1)/1000)
scatter(style=dots,overlay=line) 2
# realz imagz
# unitr unitc
Note that there are 13 roots, since it's an MA(1) x SMA(1) so degree 13. 12 are equally spaced around a not-quite unit circle as the roots of the SMA, while there is a separate real root for the MA(1).
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by ac_1 »

Hi Tom,

Thanks.

If I plot inverse AR roots on the following specification:

Code: Select all

boxjenk(diffs=1,sdiffs=1,ar=1,sar=1,maxl,define=deq) writing

compute arpoly=%eqnlagpoly(deq,writing)
compute arroots=%polycxroots(arpoly)
ewise arroots(i)=1.0/arroots(i)
set realz 1 %size(arroots) = %real(arroots(t))
set imagz 1 %size(arroots) = %imag(arroots(t))
scatter
# realz imagz
set unitr 1 1001 = cos(2*%pi*(t-1)/1000)
set unitc 1 1001 = sin(2*%pi*(t-1)/1000)
scatter(style=dots,overlay=line) 2
# realz imagz
# unitr unitc
There are too many roots? Which is not correct.

Also, am I right in thinking the coefficients of ARIMA models are not necessarily restricted to be between -1 and +1, implying a non-explosive model; it's the inverse roots which should be inside the complex unit circle: i.e. if AR roots lie inside the complex unit circle ARIMA model is stationary, and if MA roots lie inside the complex unit circle ARIMA model is invertible?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by TomDoan »

DEQ is the full model for WRITING, which includes the DIFFS and SDIFFS. It should have 25 distinct roots (+1.0 is duplicated), 12 on the unit circle and 13 inside.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by ac_1 »

Here's a few variations in p, d, P and D for AR and SAR models, including a constant, and printing the inverse roots, I'll presume -0.00000 = 0.00000.


boxjenk(const,diffs=0,sdiffs=0,ar=1,sar=0,maxl,define=deq) writing; * 0 inverse root on the complex unit circle, 1 inverse root inside (DISTINCT)
( 0.44583, 0.00000)


boxjenk(const,diffs=1,sdiffs=0,ar=1,sar=0,maxl,define=deq) writing; * 1 inverse root on the complex unit circle (DISTINCT), 1 inverse root inside (DISTINCT)
( -0.25631, -0.00000)
( 1.00000, 0.00000)


boxjenk(const,diffs=0,sdiffs=1,ar=0,sar=0,maxl,define=deq) writing; * 4 inverse roots on the complex unit circle (DISTINCT), 8 inverse roots inside (DISTINCT)
( 1.00000, 0.00000)
( 0.00000, 1.00000)
( -0.86603, 0.50000)
( -0.50000, -0.86603)
( -0.50000, 0.86603)
( -0.00000, -1.00000)
( 0.50000, 0.86603)
( -1.00000, -0.00000)
( 0.50000, -0.86603)
( 0.86603, -0.50000)
( -0.86603, -0.50000)
( 0.86603, 0.50000)


boxjenk(const,diffs=0,sdiffs=0,ar=0,sar=1,maxl,define=deq) writing; * 0 inverse roots on the complex unit circle, 12 inverse roots inside (DISTINCT)
( 0.86255, -0.49799)
( -0.99599, -0.00000)
( -0.86255, -0.49799)
( 0.86255, 0.49799)
( -0.86255, 0.49799)
( 0.99599, 0.00000)
( -0.49799, -0.86255)
( -0.49799, 0.86255)
( -0.00000, -0.99599)
( 0.00000, 0.99599)
( 0.49799, 0.86255)
( 0.49799, -0.86255)


boxjenk(const,diffs=0,sdiffs=1,ar=0,sar=1,maxl,define=deq) writing; * 4 inverse roots on the complex unit circle (DISTINCT), 20 inverse roots inside (DISTINCT)
( -0.23962, -0.89427)
( 0.23962, 0.89427)
( 0.65465, 0.65465)
( -0.65465, 0.65465)
( 0.89427, -0.23962)
( -0.89427, -0.23962)
( -0.65465, -0.65465)
( 0.65465, -0.65465)
( 0.89427, 0.23962)
( 0.23962, -0.89427)
( -0.23962, 0.89427)
( -0.89427, 0.23962)
( -0.50000, 0.86603)
( -0.86603, -0.50000)
( -1.00000, -0.00000)
( -0.50000, -0.86603)
( 1.00000, 0.00000)
( -0.86603, 0.50000)
( 0.00000, -1.00000)
( -0.00000, 1.00000)
( 0.50000, 0.86603)
( 0.86603, 0.50000)
( 0.50000, -0.86603)
( 0.86603, -0.50000)


boxjenk(const,diffs=1,sdiffs=0,ar=1,sar=1,maxl,define=deq) writing; * 1 inverse roots on the complex unit circle (DISTINCT), (1+12) inverse roots inside (DISTINCT)
( -0.52425, -0.00000)
( 0.99589, 0.00000)
( 0.86247, 0.49795)
( 0.86247, -0.49795)
( 0.49795, -0.86247)
( 0.49795, 0.86247)
( -0.00000, -0.99589)
( -0.00000, 0.99589)
( -0.49795, -0.86247)
( -0.49795, 0.86247)
( -0.86247, -0.49795)
( -0.86247, 0.49795)
( -0.99589, -0.00000)
( 1.00000, 0.00000)


boxjenk(const,diffs=1,sdiffs=1,ar=1,sar=1,maxl,define=deq) writing; * 5 inverse roots on the complex unit circle (4 DISTINCT), 21 inverse roots inside (DISTINCT), i.e. 25 DISTINCT roots
( -0.52835, -0.00000)
( 0.89834, -0.24071)
( 0.89834, 0.24071)
( 0.65763, -0.65763)
( 0.65763, 0.65763)
( 0.24071, 0.89834)
( 0.24071, -0.89834)
( -0.24071, 0.89834)
( -0.24071, -0.89834)
( -0.65763, -0.65763)
( -0.65763, 0.65763)
( -0.89834, -0.24071)
( -0.89834, 0.24071)
( 1.00000, 0.00000)
( 0.86603, -0.50000)
( 0.86603, 0.50000)
( 0.50000, -0.86603)
( 0.50000, 0.86603)
( -0.00000, -1.00000)
( -0.00000, 1.00000)
( -0.50000, -0.86603)
( -0.50000, 0.86603)
( -0.86603, -0.50000)
( -0.86603, 0.50000)
( -1.00000, -0.00000)
( 1.00000, 0.00000)


How do I exactly plot the blue complex unit circle? As with the last model I get the following plot, attached.

Then I can write a correct procedure for plotting inverse characteristic roots of ARIMA models, including seasonal.


For model 'stability', to confirm it is 'not wrong' for the coefficients of ARIMA models being outside -1 and +1, implying an explosive model, as in VAR's; it's the inverse roots which should be on or inside the complex unit circle?
Attachments
plot1.RGF
(8.35 KiB) Downloaded 790 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by TomDoan »

Resize the window to make it more circular.

BOXJENL(MAXL,...) forces the roots of the ARMA parts to be stationary and invertible, so there is nothing to check.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by ac_1 »

A mis-understanding on the previous post, as I didn’t plot the inverse roots and do not know how to display/print the coordinates (i,j) of the complex unit circle -- for the last 5 specifications there are 12 inverse roots which lie on the complex unit circle!

Attached is a procedure ACBJCRS.src for plotting the inverse roots for any ARIMA model; here's an example specification.

Code: Select all

boxjenk(const,diffs=1,sdiffs=1,ar=1,sar=1,maxl,define=deq) writing; * 12 inverse roots on the complex unit circle
@ACBJCRS(title='writing') deq writing
Within the ACBJCRS procedure I have used GCONTOUR as in https://estima.com/~estimaco/ratshelp/i ... ction.html to plot the inverse roots; IMHO both the complex unit circles should be next to each other regardless of specification, and they 'size and appear' better than using SCATTER for these plots.

I'd be very grateful if you would check ACBJCRS, and for any improvements e.g. I'd like to color the "AR" and "MA" in GRTEXT (or maybe use another function with x, y coordinates to display the roots, but GRTEXT works fine).

Questions:
1) For this example, I can visually see the 12 inverse roots (1 duplicated) which lie on the complex unit circle using GCONTOUR, and they are in the second half of the table. I have manually emboldened and manually placed a [#] next to the inverse roots which lie on the circle, as they appear anti-clockwise, from horizontal on the RHS.

Real Imag Modulus Period
-0.528 -0.000 0.528
0.898 0.241 0.930 24.000
0.898 -0.241 0.930
0.658 -0.658 0.930
0.658 0.658 0.930 8.000
0.241 0.898 0.930 4.800
0.241 -0.898 0.930
-0.241 -0.898 0.930
-0.241 0.898 0.930 3.429
-0.658 -0.658 0.930
-0.658 0.658 0.930 2.667
-0.898 -0.241 0.930
-0.898 0.241 0.930 2.182
1.000 0.000 1.000 [1]
0.866 -0.500 1.000 [12]
0.866 0.500 1.000 12.000 [2]
0.500 0.866 1.000 6.000 [3]
0.500 -0.866 1.000 [11]
-0.000 -1.000 1.000 [10]
-0.000 1.000 1.000 4.000 [4]
-0.500 -0.866 1.000 [9]
-0.500 0.866 1.000 3.000 [5]
-0.866 -0.500 1.000 [8]
-0.866 0.500 1.000 2.400 [6]
-1.000 0.000 1.000 2.000 [7]
1.000 0.000 1.000 [13]=[1]

The modulus can be used to check if the inverse roots exactly lie on the circle or inside or outside. Correct?

2) If the roots lie on the complex unit circle it means DIFFS or SDIFFS has been applied to account for stationarity in the series (unless there's parameters whose roots lie exactly on the circle). What does it mean if the inverse roots exactly lie on the circle with regard to stationarity and invertibility, or otherwise (series and model)?

3) On initial running of ACBJCRS the gridlines on the LHS plot, at 0, both horizontally and vertically do not appear, but they do appear running the procedure for a second time. Why? Similarly as previously with the ACBJCR procedure.

4) An example with all 4 parameters AR, MA, SAR, SMA, and diffs, sdiffs

Code: Select all

boxjenk(noconst,ar=2,diffs=1,ma=1,sar=1,sdiffs=1,sma=1,maxl,define=deq) writing
@ACBJCRS(title='writing') deq writing
Attachments
acbjCRS.src
(4.21 KiB) Downloaded 727 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by TomDoan »

I'm baffled about what you're trying to do. You *know* how many differences/seasonal differences you've done so you will know exactly how many unit roots you have. The AR parts are forced to be stationary by maximum likelihood. (There is no unconditional likelihood for a non-stationary model).

The MA's are also going to be forced inside or on the unit circle. An MA with a bad root has an equivalent model with the root flipped inside. (That has nothing to do with maximum likelihood). An MA with a unit root is permitted, but in practice would never be estimated since it's a boundary value, and is usually a sign of an overdifferenced model: for instance, if x is white noise, then x=u, so (1-L)x=(1-L)u so first differencing x induces a unit root MA process.

RATS graphs work from the outside in (which is pretty typical) and, by default, take the shape from the device on which they are displayed. If you want to control the dimensions, use the WIDTH and HEIGHT options on the SCATTER or other graphics instruction---probably something like HEIGHT=5.0,WIDTH=5.0 will give you the effect you want. I'm not sure I like the idea of using GRTEXT with BOX and a tiny font rather than SCATTER with DOTS---the box isn't as easy to localize as the dot.

The axis problem on the GCONTOUR appears to be a bug.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by ac_1 »

Thanks.

ACBJCRS procedure is useful for visualizing the inverse roots and checking the numerical values in the table.

On occasion BOXJENK does not converge using MAXL despite the various METHOD's, therefore I have had to resort to NOMAXL which is not ideal regarding sample size and estimation.

Using GRTEXT I tried TRANSPARENT to exactly view the position of GCONTOUR behind the BOX, but the unit circle is not visible. I am however happy with the plots as they are with GCONTOUR & GRTEXT, but agree SCATTER does a better job pinpointing the dot.

Although, if I use SCATTER I run into problems.

Attached is the SCATTER version of the procedure:
acbjCRS_s.src.

Also attached are plots:
plot1_g.rgf plot2_g.rgf - GCONTOUR & GRTEXT version
plot1_s.rgf plot2_s.rgf - SCATTER version

from running the following 2 specifications:

Code: Select all

boxjenk(const,diffs=1,sdiffs=1,ar=1,sar=1,maxl,define=deq) writing
@ACBJCRS(title='writing') deq writing

boxjenk(noconst,ar=2,diffs=1,ma=1,sar=1,sdiffs=1,sma=1,maxl,define=deq) writing
@ACBJCRS(title='writing') deq writing
How to improve the SCATTER version?
Attachments
acbjCRS_s.src
(3.85 KiB) Downloaded 744 times
plot2_s.rgf
(16.9 KiB) Downloaded 769 times
plot1_s.rgf
(8.5 KiB) Downloaded 765 times
plot2_g.rgf
(21.45 KiB) Downloaded 785 times
plot1_g.rgf
(21.15 KiB) Downloaded 791 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by TomDoan »

1. Use OVSAMESCALE on the SCATTER when the two are supposed to use the same scale. (That's why you are getting two axes in the one graph).

2. WIDTH and HEIGHT only apply to the outermost graph command---in your case the SPGRAPH. If you're doing a 2 x 1 graph, you probably want something more like WIDTH=10.0,HEIGHT=5.0 to get panes that are roughly square.

3. If BOXJENK with MAXL fails to estimate successfully, you should probably ignore the model. @BJAUTOFIT will put in the last log likelihood whether the model converges or not, which, if the model has a major issue, will generally be much worse than the better behaved models. Remember that if an ARMA(p,q) model is adequate, an ARMA(p+1,q+1) is unindentified, and unlikely to estimate properly, but it also is clearly dominated by smaller model.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by ac_1 »

SCATTER works well without attempting to color the DOTS. Inverse AR roots on the LHS panel and inverse MA roots on the RHS panel.

However, if I try to color the DOTS based on whether the inverse roots are: inside, on, or outside the circle, it's complicated.

For example, for inverse AR roots I have set indicator variables as

Code: Select all

* AR indicator series
 set arpatchz = %if( (%cabs(arroots(t)).eq.1.0), 1, 0)
 set arpatchz = %if( (%cabs(arroots(t)).gt.1.0), 2, arpatchz)
 set arrealz_0 1 %size(arroots) = %if(arpatchz == 0, %real(arroots(t)), %na); * inside
 set arimagz_0 1 %size(arroots) = %if(arpatchz == 0, %imag(arroots(t)), %na); * inside
 set arrealz_1 1 %size(arroots) = %if(arpatchz == 1, %real(arroots(t)), %na); * on
 set arimagz_1 1 %size(arroots) = %if(arpatchz == 1, %imag(arroots(t)), %na); * on
 set arrealz_2 1 %size(arroots) = %if(arpatchz == 2, %real(arroots(t)), %na); * outside
 set arimagz_2 1 %size(arroots) = %if(arpatchz == 2, %imag(arroots(t)), %na); * outside
 prin 1 %size(arroots) arpatchz arrealz_0 arimagz_0 arrealz_1 arimagz_1 arrealz_2 arimagz_2
and then tried to plot

Code: Select all

 scatter(style=dots,overlay=line,footer="If AR roots lie inside the unit circle ARIMA model is stationary", $
OVSAMESCALE,HMIN=-1.5,HMAX=+1.5,VMIN=-1.5,VMAX=1.5) 2
# arrealz_0 arimagz_0 / 3
# arrealz_1 arimagz_1 / 1
# arrealz_2 arimagz_2 / 4
# unitr unitc
but it's not right.

TomDoan wrote: 3. If BOXJENK with MAXL fails to estimate successfully, you should probably ignore the model. @BJAUTOFIT will put in the last log likelihood whether the model converges or not, which, if the model has a major issue, will generally be much worse than the better behaved models. Remember that if an ARMA(p,q) model is adequate, an ARMA(p+1,q+1) is unindentified, and unlikely to estimate properly, but it also is clearly dominated by smaller model.
I presume the same for @GMAUTOFIT? If I 'ignore the model' then how to feed-in 'the most appropriate/best' chosen specification from the automated sequence
@BJDIFF
@GMAUTOFIT
into BOXJENK always including MAXL (*very* occasionally change METHOD and include dummies with REGRESSORS, and to NOMAXL)?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by TomDoan »

ac_1 wrote:SCATTER works well without attempting to color the DOTS. Inverse AR roots on the LHS panel and inverse MA roots on the RHS panel.

However, if I try to color the DOTS based on whether the inverse roots are: inside, on, or outside the circle, it's complicated.

For example, for inverse AR roots I have set indicator variables as

Code: Select all

* AR indicator series
 set arpatchz = %if( (%cabs(arroots(t)).eq.1.0), 1, 0)
 set arpatchz = %if( (%cabs(arroots(t)).gt.1.0), 2, arpatchz)
 set arrealz_0 1 %size(arroots) = %if(arpatchz == 0, %real(arroots(t)), %na); * inside
 set arimagz_0 1 %size(arroots) = %if(arpatchz == 0, %imag(arroots(t)), %na); * inside
 set arrealz_1 1 %size(arroots) = %if(arpatchz == 1, %real(arroots(t)), %na); * on
 set arimagz_1 1 %size(arroots) = %if(arpatchz == 1, %imag(arroots(t)), %na); * on
 set arrealz_2 1 %size(arroots) = %if(arpatchz == 2, %real(arroots(t)), %na); * outside
 set arimagz_2 1 %size(arroots) = %if(arpatchz == 2, %imag(arroots(t)), %na); * outside
 prin 1 %size(arroots) arpatchz arrealz_0 arimagz_0 arrealz_1 arimagz_1 arrealz_2 arimagz_2
and then tried to plot

Code: Select all

 scatter(style=dots,overlay=line,footer="If AR roots lie inside the unit circle ARIMA model is stationary", $
OVSAMESCALE,HMIN=-1.5,HMAX=+1.5,VMIN=-1.5,VMAX=1.5) 2
# arrealz_0 arimagz_0 / 3
# arrealz_1 arimagz_1 / 1
# arrealz_2 arimagz_2 / 4
# unitr unitc
but it's not right.
Your SCATTER instruction says you're doing two pairs, but you actually have four.
ac_1 wrote:
TomDoan wrote: 3. If BOXJENK with MAXL fails to estimate successfully, you should probably ignore the model. @BJAUTOFIT will put in the last log likelihood whether the model converges or not, which, if the model has a major issue, will generally be much worse than the better behaved models. Remember that if an ARMA(p,q) model is adequate, an ARMA(p+1,q+1) is unindentified, and unlikely to estimate properly, but it also is clearly dominated by smaller model.
I presume the same for @GMAUTOFIT? If I 'ignore the model' then how to feed-in 'the most appropriate/best' chosen specification from the automated sequence
@BJDIFF
@GMAUTOFIT
into BOXJENK always including MAXL (*very* occasionally change METHOD, and to NOMAXL)?
If you're picking the "best" then a non-converging model won't be the best by any criterion.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by ac_1 »

Apologies I am getting ahead of myself. Before I begin to color the dots I have realized the plots are not being cleared!

E.g. if I run the following specifications back-to-back, the latter model remembers the inverse roots of the first.

Code: Select all

boxjenk(noconst,ar=2,diffs=1,ma=1,sar=1,sdiffs=1,sma=1,maxl,define=deq) writing
@acbjICRS(fplot=1) deq writing

boxjenk(noconst,ar=1,diffs=0,ma=0,sar=0,sdiffs=1,sma=0,maxl,define=deq) writing
@acbjICRS deq writing
Which is problematic when using in a recursive/rolling scheme.


Here's the plot code within the procedure.

Code: Select all

* Plot inverse characteristic roots

if (FPLOT == 1) {

   if %defined(title)
      compute ltitle=title
   else
      compute ltitle="inverse roots of the characteristic polynomial"


   spgraph(hfields=2,vfields=1,header=%l(depvar)+"\\"+ltitle,WIDTH=10.0,HEIGHT=5.0)
   grparm(bold)
   grparm footer 22

      if (%size(arroots).ne.0) {
         spgraph(hfields=1,vfields=1)
         scatter(style=dots,overlay=line,footer="If AR roots lie inside the unit circle ARIMA model is stationary", $
                  OVSAMESCALE,HMIN=-1.5,HMAX=+1.5,VMIN=-1.5,VMAX=1.5) 2
         # arrealz arimagz
         # unitr unitc
         spgraph(done)

         spgraph(hfields=1,vfields=1); * no MA graph
         spgraph(done)
      }


      if (%size(maroots).ne.0) {
         spgraph(hfields=1,vfields=1); * no AR graph
         spgraph(done)

         spgraph(hfields=1,vfields=1)
         scatter(style=dots,overlay=line,footer="If MA roots lie inside the unit circle ARIMA model is invertible", $
                  OVSAMESCALE,HMIN=-1.5,HMAX=+1.5,VMIN=-1.5,VMAX=1.5) 2
         # marealz maimagz
         # unitr unitc
         spgraph(done)
      }

   spgraph(done)


      if (%size(arroots).eq.0).and.(%size(maroots).eq.0) {
         disp ''
         disp 'NO PLOTS'
         disp ''
      }

}


if (FPLOT == 0) {
      disp ''
      disp 'NO PLOTS'
      disp ''
}
But not for the GCONTOUR version.

Code: Select all

* Plot inverse characteristic roots

if (FPLOT == 1) {

   if %defined(title)
      compute ltitle=title
   else
      compute ltitle="inverse roots of the characteristic polynomial"


   @gridseries(from=-1.5,to=1.5,n=150) z1grid
   @gridseries(from=-1.5,to=1.5,n=150) z2grid

   dec rect f(151,151)
   ewise f(i,j) = z1grid(i)^2 + z2grid(j)^2

   dec vect contours(1)
   ewise contours(i)=1.0*i

   disp contours


   spgraph(hfields=2,vfields=1,header=%l(depvar)+"\\"+ltitle,WIDTH=10.0,HEIGHT=5.0)
   grparm(bold)
   grparm footer 22

   gcontour(AXIS=BOTH,footer="If AR roots lie inside the unit circle ARMA model is stationary",f=f,x=z2grid,y=z1grid,number=1,contours=contours,$
            header="inverse AR roots",Hlabel="Real",Vlabel="Imaginary")
      do k = 1, %size(arroots)
         grtext(x=arrealz(k),y=arimagz(k),BOLD,BOX,SIZE=5,TRANSPARENT) "AR"
      end do k


   gcontour(AXIS=BOTH,footer="If MA roots lie inside the unit circle ARMA model is invertible",f=f,x=z2grid,y=z1grid,number=1,contours=contours,$
            header="inverse MA roots",HLABEL="Real",VLABEL="Imaginary")
      do l = 1, %size(maroots)
         grtext(x=marealz(l),y=maimagz(l),BOLD,BOX,SIZE=5,TRANSPARENT) "MA"
      end do l

   spgraph(done)


   if (%size(arroots).eq.0).and.(%size(maroots).eq.0) {
      disp ''
      disp 'NO PLOTS'
      disp ''
   }

}


if (FPLOT == 0) {
      disp ''
      disp 'NO PLOTS'
      disp ''
}
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: procedure plotting the characteristic roots for ARIMA mo

Unread post by TomDoan »

Works fine when I try it. You would need to attach the full procedure in case there is something in it that would be causing a problem.

I still don't understand what the point of this is.
Post Reply