Creating new variables using MOVCOR

For requesting general information about EViews, sharing your own tips and tricks, and information on EViews training or guides.

Moderators: EViews Gareth, EViews Moderator

jlsmith09012
Posts: 6
Joined: Tue Mar 06, 2012 6:59 am

Creating new variables using MOVCOR

Postby jlsmith09012 » Tue Mar 06, 2012 7:08 am

I have 30 new variables that I need to create moving correlations between 1 of the variables and each of the other 29 variables. Is there an easy loop that will do this?

trubador
Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

Re: Creating new variables using MOVCOR

Postby trubador » Tue Mar 06, 2012 7:44 am


jlsmith09012
Posts: 6
Joined: Tue Mar 06, 2012 6:59 am

Re: Creating new variables using MOVCOR

Postby jlsmith09012 » Tue Mar 06, 2012 8:27 am

Thank you. I considered this solution, but my problem is that my variables have different names, such as A_ret, B_ret, C_ret, etc. I contemplated renaming the variables to X1 through X29, but I don't want to lose the descriptive data in the variable name. Is this possible?

EViews Glenn
EViews Developer
Posts: 2671
Joined: Wed Oct 15, 2008 9:17 am

Re: Creating new variables using MOVCOR

Postby EViews Glenn » Tue Mar 06, 2012 10:25 am

You can also loop over a list of names.

jlsmith09012
Posts: 6
Joined: Tue Mar 06, 2012 6:59 am

Re: Creating new variables using MOVCOR

Postby jlsmith09012 » Tue Mar 06, 2012 11:53 am

I'm not sure if this is the most elegant solution, but here's what I have (and it works):

for !i=1 to portfolio1.@count
%constant = "A_ret"
%name = portfolio1.@seriesname(!i)
%newname = %name +"A"+ "_mc"
series {%newname} =@Movcor({%constant},{%name},10)
next

This allows me to loop through the variables, add the name of the variable and the designator MC, and generate the new series. It does provide me a moving correlation with variable A and A, but that's a small price to pay. I'm sure there is a way to delete variable A from portfolio1.@seriesname(!i), but I'm okay with my 98% solution. thanks to Trubador and Eviews Glenn (as well as an unnamed co-author) for the help.

jsaldain
Posts: 2
Joined: Thu Apr 03, 2014 6:26 am

Re: Creating new variables using MOVCOR

Postby jsaldain » Thu Apr 03, 2014 6:32 am

Could you explain what each command, from the loop, does?

Thanks!!


Return to “General Information and Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 24 guests