Page 1 of 3
structural models for time series
Posted: Wed Feb 08, 2012 6:39 pm
by mcorozcos
Hello,
I have some problems with the space state models, because it is the first time that I use the instrution dlm. I need to simulate one space state model. Someone can to help me.
The idea is to make a simulation a space state model, with factors no stationary and seasonal, errors have to a distribution noise white gaussian.
I don´t know how to use the instruction dlm for simulate. Please help me.
And I have a question about structural models, Do I use the same instruction? ¿How do I use the instrution dlm for this kind models?
Thanks for your help
Re: structural models for time series
Posted: Thu Feb 09, 2012 9:19 am
by TomDoan
What's your model? Write it in state-space form. Note, however, that if you're just trying to simulate a model, it's often easier to just do that directly. For instance, if you have a standard local level model:
x(t)=x(t-1)+w(t)
y(t)=x(t)+v(t)
where w(t) and u(t) are the shocks, the easiest way to do that is
Code: Select all
allocate (# of data points you want)
set(first=0.0) x = x{1}+%ran(sigmaw)
set y = x+%ran(sigmav)
To do the same thing with DLM, you would convert that to the state-space model
State equation:
x(t) = [1] x(t-1) + w(t)
Measurement equation:
y(t) = [1] x(t) + v(t)
An example would be:
Code: Select all
all 100
compute sigmav=2.0,sigmaw=1.0
dlm(a=1.0,c=1.0,sv=sigmav^2,sw=sigmaw^2,type=simulate,yhat=yhat)
set y = %scalar(yhat)
Re: structural models for time series
Posted: Mon Feb 13, 2012 7:02 pm
by mcorozcos
Hello Tom,
Thanks for your help. I have two models:
The first one has factors no stationary:
y1t 1 0 f1t e1t
y2t = 0 1 * f2t + e2t
y3t 0 0 e3t
Where:
f1t, f2t: matrix (2x1) of the factors which have an ARIMA model.
e1t, e2t, e3t: matrix (2x1) of noise white Gaussian with distribution normal.
y1t, y2t, y3t: matrix (3X1) of observations
1 0 identity matrix (3x2)
0 1
0 0
The second one has a factor no stationary y other seasonal:
y1t = p11 0 * f1t + e1t
y2t = p21 p22 * f2t + e2t
Where
f1t, f2t: matrix (2x1) of the factors with f1t: is a factor with ARIMA model and f2t: is a factor with SARIMA model
e1t, e2t: matrix (2x1) noise white Gaussian with distribution normal.
y1t, y2t: matrix (2x1) observations
p11 0
p21 p22 loading matrix (2x2)
I need to simulate two models, I don´t have idea how do I use the instruction dlm for this kind of models?
Thanks for your help
Re: structural models for time series
Posted: Wed Feb 15, 2012 5:02 pm
by TomDoan
Again, it's simpler to simulate that in pieces rather than by trying to put together a state-space model with two observables and two separate state vectors. You would need something like this:
Code: Select all
all 400
*
* This is the ARIMA model (1-L)(1-.4L)y=(1+.3L)u
*
equation(coeffs=||1.4,-.4,.3||,noconstant) arimaeq y 2 1
@armadlm(a=a1,f=f1,c=c1) arimaeq
*
* This is the "airline" SARIMA model (1-L)(1-L^12)y=(1-.7L)(1-.6L^12)u
*
equation(coeffs=||1.0,1.0,-1.0,-.7,-.6,.42||,noconstant,ar=||1,12,13||,ma=||1,12,13||) sarimaeq y
@armadlm(a=a2,f=f2,c=c2) sarimaeq
dlm(a=a1,f=f1,c=c1,yhat=fac1,sw=1.0,type=simulate,presample=ergodic)
dlm(a=a2,f=f2,c=c2,yhat=fac2,sw=4.0,type=simulate,presample=ergodic)
set e1 = %ran(2.0)
set e2 = %ran(0.5)
*
compute p11=1.0,p21=0.5,p22=1.0
*
set y1 = p11*fac1(t)(1)+e1
set y2 = p21*fac1(t)(1)+p22*fac2(t)(1)+e2
Re: structural models for time series
Posted: Sun Feb 19, 2012 10:56 am
by mcorozcos
Thanks for your help
Re: structural models for time series
Posted: Sun Mar 25, 2012 3:46 pm
by mcorozcos
Hello Tom,
I have another question. I want to know, how do I remove the common trend for two series in RATS? I know that exist common trend in the series I need to remove in other to analyze the results.
Thanks for your help
Re: structural models for time series
Posted: Mon Mar 26, 2012 1:31 pm
by TomDoan
mcorozcos wrote:Hello Tom,
I have another question. I want to know, how do I remove the common trend for two series in RATS? I know that exist common trend in the series I need to remove in other to analyze the results.
Thanks for your help
This will extract a common H-P trend from a pair of series:
http://www.estima.com/forum/viewtopic.php?f=8&t=1395
Re: structural models for time series
Posted: Sun Sep 09, 2012 7:43 pm
by mcorozcos
Hello,
I need to create a code in RATS in order to retort the article that I attachment for apply the methodology to colombian data. I hope you can help me.
Thanks
Re: structural models for time series
Posted: Thu Sep 13, 2012 11:00 am
by mcorozcos
Hello Tom,
Can you help me with last post (sep 09)?
Thanks for your help
Re: structural models for time series
Posted: Thu Sep 13, 2012 1:09 pm
by TomDoan
How far have you gotten on it? This is a paper with no citations in the literature, so it's clearly not in common use. It's not a particularly complicated state-space model, since it just has random walk coefficients on the deterministic seasonals, and the tests appear to be zero restrictions on the variances of those.
Re: structural models for time series
Posted: Sun Oct 07, 2012 10:58 pm
by mcorozcos
Hello Tom
Can you help to simulate this equation in Rats:
zt(h) = (cos λ(h)t, sin λ(h)t)'
Let s be the number of seasons and λ(h) = 2πh/s, h = 1, ..., [s/2], be the seasonal frequencies. Denote by zt(h), h = 1, ..., [s/2], the spectral indicator variable associated with each of the λ(h), that is zt(h) = (cos λ(h)t, sin λ(h)t)' for h < s/2 and, when s is even, zt(s/2) = cos λ(s/2)t = cos πt.
thanks for your help
regards
Re: structural models for time series
Posted: Mon Oct 08, 2012 8:01 am
by TomDoan
Is there anything random about those? (I'm puzzled about the use of "simulate", since they appear to be deterministic).
Re: structural models for time series
Posted: Mon Oct 08, 2012 8:49 pm
by mcorozcos
Hello Tom,
Sorry, I make a mistake in my question, for this reason I make a new one.
I need to simulate some series with base at next structural model for time series:
yt = μt+st + εt,
μt = Xtβ,
st = sum of h = 1 to [s/2] of Zt(h)γt(h),
γt(h) = γt−1(h) + ηt(h), h= 1, ..., [s/2], is a random walk
ηt(h) ∼ IID (0, Σ η(h)) , h= 1, ..., [s/2],
εt ∼ IID (0, Σ ε) ,
where:
Xt = (IN ⊗ xt') ,
β =(β1', ..., βN')' ,
Zt(h) = (IN ⊗ zt(h)') ,
zt(h) = (cos λ(h)t, sin λ(h)t)0 for h < s/2 and, when s is even, zt(s/2) = cos λ(s/2)t = cos πt.
γt(h) =(γ1t(h)', ..., γNt(h)')' , h = 1, ..., [s/2].
ηt(h) is independent of ηs(l)l, i.e. the seasonal components at different frequencies are orthogonal, and also independent of the irregular disturbance εs, for all t, s; ⊗ denotes the Kronecker product.
S=be the number of seasons and
λ(h) = 2πh/s, h = 1, ..., [s/2], be the seasonal frequencies.
Thanks for your help
Re: structural models for time series
Posted: Sun Oct 14, 2012 9:48 pm
by TomDoan
The gamma's are the states, so the Z's will be the loadings (C's). Their notation is a bit odd, since they have a combination of 2-vectors and 1-vectors. This sets up the C formula:
Code: Select all
dec vect[series] zt(s-1)
dec frml[vect] cf
do h=1,s/2
set zt(2*h-1) = cos(2*%pi*h*t/s)
if 2*h<=s-1
set zt(2*h) = sin(2*%pi*h*t/s)
end do h
frml cf = %xt(zt,t)
Re: structural models for time series
Posted: Wed Jan 02, 2013 3:12 pm
by mcorozcos
Hello Tom,
Thanks for your help. I tried to do the last code, but it don´t show a vector of series that I need, for this reason I write you again.
I need to create a vector (100 rows,1 column) with simulated data for this equation:
st = summation of h=1 until h=[s/2] of Zt(h)
where, zt(h), is the spectral indicator variable associated with each of the λ(h), that is:
zt(h) = (cos λ(h)t, sin λ(h)t)' for h < s/2 and,
when s is even, zt(s/2) = cos λ(s/2)t = cos πt.
where s be the number of seasons and λ(h) = 2πh/s, h = 1, ..., [s/2], are the seasonal frequencies.
I hope, you can help me.
Thanks again.
Regards