Page 3 of 3

Re: structural models for time series

Posted: Fri Apr 19, 2013 2:59 pm
by mcorozcos
Hello Tom

I revised the examples about @seasonaldlm, but, I couldn´t run the code because I don´t have the data sets. You known where I can find those data sets for these examples.

Thanks for your help

Best regards

Re: structural models for time series

Posted: Fri Apr 19, 2013 3:59 pm
by TomDoan
The data are provided with RATS in the directory for the appropriate textbook. For instance, the data for the harveyxxx examples are in the Harvey textbook directory.

Re: structural models for time series

Posted: Fri Apr 26, 2013 2:23 pm
by mcorozcos
Hello Tom,
I need to simulated two series with the specification for this code:

Code: Select all

@SeasonalDLM(type=fourier,a=as,c=cs,f=fs,SPAN=12)
@LocalDLM(a=al,c=cl,f=fl)
dec symm sigmav(2,2) sigmal(2,2) sigmas(2,2)
dec symm sw
compute a=(al~\as)~\(al~\as)
compute f=(fl~\fs)~\(fl~\fs)
compute c=(cl~~cs)~\(cl~~cs)
dec packed pl(2,2) ps(2,2)
compute sw=%zeros(%rows(a),%rows(a))
function %%DLMSetupSW
local integer i
compute sigmal=%ltouterxx(pl),sigmas=%ltouterxx(ps)
compute sw(1,1)=sigmal(1,1),sw(1,13)=sigmal(1,2),sw(13,13)=sigmal(2,2)
do i=1,11
   compute sw(i+1,i+1)=sigmas(1,1)
   compute sw(i+1,i+13)=sigmas(1,2)
   compute sw(i+13,i+13)=sigmas(2,2)
end do i
end %%DLMSetupSW
compute sigmav=%mscalar(.005),pl=%mscalar(.0003),ps=%mscalar(0.0)
nonlin sigmav pl ps
dlm(start=%%DLMSetupSW(),sw=sw,a=a,c=c,f=f,sv=sigmav,yhat=ysim,type=simulate) 1 500
set y1 = ysim(t)(1)
print / y1 y2
graph 1
# y1
My problem is in “yhat”, because I don´t know which is the instruction for two series. Additionally, I need to simulated with trend that is random walk, and I don´t sure if with @localdlm its possible.

Thanks for your help

Re: structural models for time series

Posted: Fri Apr 26, 2013 2:37 pm
by TomDoan
Use

set y2 = ysim(t)(2)

What you're creating with localdlm is a "local level" which is a random walk.

@localdlm(type=trend)

generates the state-space representation for a local trend model, where the trend-rate is a random walk.

Re: structural models for time series

Posted: Fri May 03, 2013 7:57 pm
by mcorozcos
Hello Tom,

I am writing because, I need estimate a regression with two variables dependents and two variables independents and calculate the residuals, i.e. I need estimate a multivariate regression. And, I don´t know, which is the instruction for I do it.

Can I use “linreg”? but I think this instruction is only for univariate regresion ¿how do I use it? ¿Do I need another instruction? ¿which is new instruction?

I hope you can help me
Thanks

Re: structural models for time series

Posted: Fri May 03, 2013 11:00 pm
by TomDoan
mcorozcos wrote:Hello Tom,

I am writing because, I need estimate a regression with two variables dependents and two variables independents and calculate the residuals, i.e. I need estimate a multivariate regression. And, I don´t know, which is the instruction for I do it.

Can I use “linreg”? but I think this instruction is only for univariate regresion ¿how do I use it? ¿Do I need another instruction? ¿which is new instruction?

I hope you can help me
Thanks
Use SUR

Re: structural models for time series

Posted: Tue Jun 04, 2013 3:25 pm
by mcorozcos
Hello Tom,

I need generate the next equation with negative numbers, (for example f=-5) I need start the sequence from -5, the idea is to generate a list of numbers, with this equation (like how I did, para f=1 o f=2), from f=-1 o f=-5.
How could I do it? Because, I only could do, with positive numbers like you can see in the next code.

Code: Select all

compute m = 5

declare rectangular kernel
dim kernel(m,1)
do f=1, m
compute kernel(f,1) = 1-(abs(f)/(m+1))
end do kernel


I hope you can help me

Re: structural models for time series

Posted: Wed Jun 05, 2013 9:58 am
by TomDoan
Subscripts on RATS arrays are always 1-based, so you can't have negative subscripts. What you can do is to offset the position. So, for instance,

compute m = 5
dec vector bartlett(2*m+1)
ewise bartlett(i)=1-abs(i-(m+1))/(m+1)

will have the pattern

1/6,2/6,3/6,4/6,5/6,6/6,5/6,4/6,3/6,2/6,1/6

You would then need to adjust the position when you use it, since bartlett(6) is really the "0" point.

However, one question is whether you even need to do that. If you're applying this to a data series, you can just use FILTER with the TYPE=CENTERED and WEIGHTS options, and if you're applying it to calculation of a long-run covariance matrix, you can use use MCOV with the LWINDOW=NEWEYWEST option.