Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Richard Gates <rgates@stata.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: -arima- vs. -sspace- |

Date |
Fri, 23 Mar 2012 16:39:08 -0500 |

Jorge Eduardo Pérez Pérez wrote: > > 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-? Try scaling your data. -sspace- estimates the variance and -arima- the standard deviation. When you have a nonconvergent problem, use the -iterate()- option to terminate the optimization at a point where it looks like it is having trouble and take a look at the estimates. . do arima2 . clear . * Input database . input dlym dlym 1. .0076563 2. .0095813 3. .007427 ... (omitted) 44. -.0007679 45. .000582 46. .0012176 47. .0005591 48. -.0000923 49. .0030711 50. .0041749 51. .0029995 52. .0018442 53. end . * Declare time series . gen t=_n . tsset t time variable: t, 1 to 52 delta: 1 unit . replace dlym = 1000*dlym (52 real changes made) . * Estimate arima . arima dlym, arima(2,0,0) nocons (setting optimization to BHHH) Iteration 0: log likelihood = -132.81204 Iteration 1: log likelihood = -132.79176 Iteration 2: log likelihood = -132.78632 Iteration 3: log likelihood = -132.7844 Iteration 4: log likelihood = -132.78369 (switching optimization to BFGS) Iteration 5: log likelihood = -132.78337 Iteration 6: log likelihood = -132.78305 Iteration 7: log likelihood = -132.78304 ARIMA regression Sample: 1 - 52 Number of obs = 52 Wald chi2(2) = 193.17 Log likelihood = -132.783 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ | OPG dlym | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- ARMA | ar | L1. | 1.098012 .1706826 6.43 0.000 .7634798 1.432543 L2. | -.2922192 .1466112 -1.99 0.046 -.5795718 -.0048666 -------------+---------------------------------------------------------------- /sigma | 3.066515 .1590157 19.28 0.000 2.75485 3.37818 ------------------------------------------------------------------------------ Note: The test of the variance against zero is one sided, and the two-sided confidence interval is truncated at zero. . . *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 nr) /// > iterate(15) searching for initial values ........... (setting technique to bhhh) Iteration 0: log likelihood = -133.26724 Iteration 1: log likelihood = -133.08202 Iteration 2: log likelihood = -132.96335 Iteration 3: log likelihood = -132.89188 (switching technique to nr) Iteration 4: log likelihood = -132.84706 Iteration 5: log likelihood = -132.78316 Iteration 6: log likelihood = -132.78304 Iteration 7: log likelihood = -132.78304 Refining estimates: Iteration 0: log likelihood = -132.78304 Iteration 1: log likelihood = -132.78304 State-space model Sample: 1 - 52 Number of obs = 52 Wald chi2(2) = 163.02 Log likelihood = -132.78304 Prob > chi2 = 0.0000 ( 1) [dy]e.dy = 1 ( 2) [dlym]dy = 1 ( 3) [et]e.dy = 1 ( 4) [ldy]L.dy = 1 ------------------------------------------------------------------------------ | OIM dlym | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- dy | dy | L1. | 1.098088 .1304214 8.42 0.000 .8424671 1.35371 | ldy | L1. | -.2922904 .1330764 -2.20 0.028 -.5531154 -.0314655 e.dy | 1 (constrained) -------------+---------------------------------------------------------------- ldy | dy | L1. | 1 (constrained) -------------+---------------------------------------------------------------- et | e.dy | 1 (constrained) -------------+---------------------------------------------------------------- dlym | dy | 1 (constrained) -------------+---------------------------------------------------------------- Variance | dy | 9.403747 1.845373 5.10 0.000 5.786882 13.02061 ------------------------------------------------------------------------------ Note: Tests of variances against zero are one sided, and the two-sided confidence intervals are truncated at zero. I hope this is what you need. -Rich rgates@stata.com * * 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/

**References**:**st: -arima- vs. -sspace-***From:*Jorge Eduardo Pérez Pérez <perez.jorge@ur.edu.co>

- Prev by Date:
**Re: st: RES: RE: panel tobit with fixed effects** - Next by Date:
**Re: st: qplot , over()** - Previous by thread:
**st: -arima- vs. -sspace-** - Next by thread:
**Re: st: -arima- vs. -sspace-** - Index(es):