Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: -arima- vs. -sspace-

 From Jorge Eduardo Pérez Pérez To Subject st: -arima- vs. -sspace- Date Fri, 23 Mar 2012 16:55:54 -0400

```Dear Statalist:

I have been fitting arima models using the state space representation
and the -sspace- command instead of using -arima-. I am doing this
because I need the filtered state estimates for other purposes. I have
found that in some cases, -arima- achieves convergence while -sspace-
does not, even using the same optimization technique. See an example
below for an ARIMA(2,0,0). I have a couple of questions.

1. Why does this happen? I know that -arima- has its own
implementation of the Kalman Filter coded in the Stata matrix
language, while sspace is coded in mata and uses the mata optimization
routines. Can anyone point out the differences between the two
implementations? I would expect that a model that converges using
-arima-, would also converge using the -sspace- routines that are much
more up to date.
2. How do I get -sspace- to achieve the same results as -arima-?

Regards,

Jorge Eduardo Pérez Pérez.

--------------------------------------------
clear
* Input database
input dlym
.0076563
.0095813
.007427
.005337
.0038745
.0051258
.003782
.0024631
.0040767
.0053647
.003978
.0026186
-.0058362
-.0064847
-.0058587
-.0052264
-.0004542
-.0000188
-.0004647
-.0009081
.0058043
.0074041
.0056493
.0039375
.0035965
.0047967
.0035117
.002249
.0009463
.001651
.0009181
.0001924
-.0060084
-.0066926
-.0060337
-.0053675
-.0161679
-.0191143
-.0165818
-.0139391
-.0002768
.0001929
-.0002892
-.0007679
.000582
.0012176
.0005591
-.0000923
.0030711
.0041749
.0029995
.0018442
end
* Declare time series
gen t=_n
tsset t
* Estimate arima
arima dlym, arima(2,0,0) nocons

*Estimate via sspace
constraint 1 [dy]e.dy=1
constraint 2 [dlym]dy=1
constraint 3 [et]e.dy=1
constraint 4 [ldy]l.dy=1

sspace (dy l.dy l.ldy e.dy, state noconstant)  (ldy l.dy, state
noconstant ) (et e.dy, state noconstant) (dlym dy, noconstant) ///
, covstate(diagonal)  constraints(1/4) tech(bhhh 4 bfgs)

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```