Creating new variables using MOVCOR
Moderators: EViews Gareth, EViews Moderator
-
- Posts: 6
- Joined: Tue Mar 06, 2012 6:59 am
Creating new variables using MOVCOR
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?
-
- Posts: 6
- Joined: Tue Mar 06, 2012 6:59 am
Re: Creating new variables using MOVCOR
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 Developer
- Posts: 2671
- Joined: Wed Oct 15, 2008 9:17 am
Re: Creating new variables using MOVCOR
You can also loop over a list of names.
-
- Posts: 6
- Joined: Tue Mar 06, 2012 6:59 am
Re: Creating new variables using MOVCOR
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.
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.
Re: Creating new variables using MOVCOR
Could you explain what each command, from the loop, does?
Thanks!!
Thanks!!
Return to “General Information and Tips and Tricks”
Who is online
Users browsing this forum: No registered users and 24 guests