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

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

mbeckr18
Posts: 13
Joined: Mon Oct 28, 2013 10:37 am

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

Postby mbeckr18 » Fri Sep 01, 2017 12:08 pm

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13306
Joined: Tue Sep 16, 2008 5:38 pm

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

Postby EViews Gareth » Fri Sep 01, 2017 12:54 pm

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.
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 21 guests