Page 1 of 1

Generating a time series variable as a function of the other variables

Posted: Fri Sep 01, 2017 12:08 pm
by mbeckr18
Hello,
I am new to programming and I would need help with an equation.
My goal is to generate a new series (variable) for my time-series dataset. My dataset consists of 17 variables and 200 weeks.
The new series (diss) should represent the absolute difference between all my variables in week t and the variables in week t-1 to t-13 (in the last 13 weeks).
Thus, I have written the following code.
series dis = resid
for !i = 1 to 17
for !t = 1 to 13
distance = @sum(abs(Var{!i} - Var{!i}(-!t)))
next
next

However, this code only gives me a scalar. I am not sure how to tell eviews that I need a value for each week (starting in week 14). I would highly appreciate any help.
Thank you so much in advance.

Re: Generating a time series variable as a function of the other variables

Posted: Fri Sep 01, 2017 12:54 pm
by EViews Gareth

Code: Select all

series dis=0
for !i=1 to 17
for !t=1 to 13
dis = dis+@abs(var{!i} - var{!i}(-!t))
next
next


Not 100% certain what you want from your description, but that code does what I think you want.