a question on seasonally adjusted
a question on seasonally adjusted
Dear Tom:
When I learn ecourse state space,I have a deep question. In BN or UC decomposion, series have been seasonally adjusted before, and in commandeur & koopman's book, or stock & watson's dynamic factor model, they all estimate season component. Can we decompose directly a series into level, trend, seasonal, irregular and cycle with AR(2)? Addtional, for a same series and start point, if end points are different, seasonally adjusted series are also different under same method.
Best Regard
hardmann
When I learn ecourse state space,I have a deep question. In BN or UC decomposion, series have been seasonally adjusted before, and in commandeur & koopman's book, or stock & watson's dynamic factor model, they all estimate season component. Can we decompose directly a series into level, trend, seasonal, irregular and cycle with AR(2)? Addtional, for a same series and start point, if end points are different, seasonally adjusted series are also different under same method.
Best Regard
hardmann
Re: a question on seasonally adjusted
You could, but unless there's something else involved in the model, the combination of the AR(2) and the local level/trend is usually too much flexibility.hardmann wrote:Dear Tom:
When I learn ecourse state space,I have a deep question. In BN or UC decomposion, series have been seasonally adjusted before, and in commandeur & koopman's book, or stock & watson's dynamic factor model, they all estimate season component. Can we decompose directly a series into level, trend, seasonal, irregular and cycle with AR(2)?
That's true with any smoothing procedure.hardmann wrote: Addtional, for a same series and start point, if end points are different, seasonally adjusted series are also different under same method.
Re: a question on seasonally adjusted
Dear Tom:
OxMetics Stamp can decompose a time seriese to trend, seasonl, cycle, and irregular component, even multi cycle components. Is it too much flexibile?
OxMetics Stamp can decompose a time seriese to trend, seasonl, cycle, and irregular component, even multi cycle components. Is it too much flexibile?
Re: a question on seasonally adjusted
In practice, yes. You can typically get trend+cycle or cycle+irregular as combined components, but not trend + cycle + irregular separate without very, very strong assumptions about relative variances.hardmann wrote:Dear Tom:
OxMetics Stamp can decompose a time seriese to trend, seasonl, cycle, and irregular component, even multi cycle components. Is it too much flexibile?
Re: a question on seasonally adjusted
Dear Tom:
How to speciy trigonometric cycle,,could you add a subfuction such as @localdlm and @seasonaldlm.
Hardmann
How to speciy trigonometric cycle,,could you add a subfuction such as @localdlm and @seasonaldlm.
Hardmann
Re: a question on seasonally adjusted
See HARVEYP086.RPF for an example.hardmann wrote:Dear Tom:
How to speciy trigonometric cycle,,could you add a subfuction such as @localdlm and @seasonaldlm.
Hardmann
Re: a question on seasonally adjusted
Dear Tom:
Half year ago, I run harveyp086.rpf, which gave wrong estimation. I confused and did nothing. I purchased harvey monograph Forecasting, struture time series models and Kalman Filter. After learning the book, I run it using stamp, which give same result of harvey. I exmaine again the codes of rats, which ignore the initialization of lambda cycle (lc) and varince of cycle (sigsqkappa). While adding comp lc=0.0 , sigsqkappa = 0.1 * sigsqeps, same result is gotton. I confused that initialization is not vital, but fatal.
If I want to estimate two cycle with different frequence,how can I do?
Best regard
Hardmann
Half year ago, I run harveyp086.rpf, which gave wrong estimation. I confused and did nothing. I purchased harvey monograph Forecasting, struture time series models and Kalman Filter. After learning the book, I run it using stamp, which give same result of harvey. I exmaine again the codes of rats, which ignore the initialization of lambda cycle (lc) and varince of cycle (sigsqkappa). While adding comp lc=0.0 , sigsqkappa = 0.1 * sigsqeps, same result is gotton. I confused that initialization is not vital, but fatal.
If I want to estimate two cycle with different frequence,how can I do?
Best regard
Hardmann
Re: a question on seasonally adjusted
This corrects the procedure for the Harvey example. There's a rather long description of what the numerical issues are with the example.
Multiple frequencies are done using an A matrix which is a diagonal concatenation of the component A matrices, an SW matrix which is a diagonal concatenation of the component SW matrices and a C matrix which is a horizontal concatenation of the component C matrices. That's the standard procedure for creating a model which is a sum of independent components. Since, unlike a standard UC model, your "A" matrices aren't fixed, you'll have to do the concatenation as part of the definition of a FRML[RECT].
Code: Select all
*
* Harvey, "Forecasting, ..., Kalman Filter", example from 2.7.2, pp 86-87
* BSM with non-standard cycle
*
open data rainfall.prn
calendar(a) 1849
data(format=prn,org=columns) 1849:01 1979:01 rainfall
*
* Deterministic cycles model
*
* This apparently has the frequencies fixed. If lambda is added to the
* parameter set, the estimates are somewhat different.
*
* Note that (a1,ph1) and (a2,ph2) have multiple possible values. Adding
* or subtracting pi from either phase will give identical results if the
* corresponding amplitude is flipped in sign.
*
stats rainfall
compute mu=%mean
nonlin mu a1 a2 ph1 ph2
*
compute lambda=.240
compute a1=a2=0.0,ph1=ph2=2.0
frml cycles = mu+a1*cos(lambda*t+ph1)+a2*cos(2*lambda*t+ph2)
nlls(frml=cycles) rainfall
*
* State space model with cycles of estimated frequency.
*
nonlin mu rho lc sigsqeps sigsqkappa
*
stats rainfall
*
compute mu=%mean,sigsqeps=%variance
*
dec frml[rect] af
frml af = ||rho*cos(lc),rho*sin(lc)|$
-rho*sin(lc),rho*cos(lc)||
compute f=%identity(2)
compute c=||1.0,0.0||
*
* The likelihood for this model is extremely flat in the value of rho
* across a very wide range (from .5 to 1). Because the likelihood is
* discontinuous at rho=1 (as the unit roots force the likelihood to be
* conditional on two initial data points), it's very easy for a general
* search for the maximum of the log likelihood to end up at rho=1. To
* avoid numerical problems with that, this does a preliminary estimate
* which treats *all* likelihood evaluations as conditional on two data
* points. That makes the log likelihood continuous up through rho=1 so
* we can locate the true mode. Once that's done, the unconditional
* estimates can be done starting from the conditional estimates. If you
* don't do this, the estimation is very sensitive to guess values for
* rho.
*
nonlin mu rho lc sigsqeps sigsqkappa
compute rho=.90,lc=.24,sigsqkappa=.01*%variance
dlm(a=af,f=f,c=c,sv=sigsqeps,sw=sigsqkappa*%identity(2),mu=mu,condition=2,$
y=rainfall,method=bfgs,presample=ergodic) / xstates
dlm(a=af,f=f,c=c,sv=sigsqeps,sw=sigsqkappa*%identity(2),mu=mu,$
y=rainfall,method=bfgs,presample=ergodic) / xstates
*
diff(center) rainfall / demean
*
spgraph(vfields=2)
@mesa(poles=16,nologscale,header="Empirical Spectrum") demean
@SSMSpectrum(a=af(1),sw=sigsqkappa*%identity(2),components=||1||) ssmspec
set ssmreal 1 128 = %real(ssmspec(t)(1,1))
set frequencies 1 128 = (t-1.0)/128
scatter(style=lines,header="Model Spectrum")
# frequencies ssmreal 2 128
spgraph(done)
Re: a question on seasonally adjusted
Dear Tom:
If I have raw data series,then get seasonal adjusted series using X11_arima. I estimate the UC model with irregular component or not? Namely I decompose it into trend and cycle component.
Best Regard
Hardmann
If I have raw data series,then get seasonal adjusted series using X11_arima. I estimate the UC model with irregular component or not? Namely I decompose it into trend and cycle component.
Best Regard
Hardmann
Re: a question on seasonally adjusted
The seasonally adjusted series should have only the seasonal removed, so a UC analysis of the seasonal adjusted series would typically have a trend and irregular.