Weighted average of group of time series

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

nupogodi
Posts: 53
Joined: Thu Jun 03, 2010 12:50 am

Weighted average of group of time series

Postby nupogodi » Tue Nov 16, 2010 7:22 am

Could you point me the optimal way of calculating weighted average of time series without using loops?
There is a group (A) of indices available and another group (B) containing some absolute values i.e weights. The group of weights (B) should be normalized first. The number of time series to be weighted is not known a priori...

=(A.1*B.1 + A.2*B.2 + A.3*B.3 + ...)/sum(B)

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

Weighted average of group of time series

Postby EViews Gareth » Tue Nov 16, 2010 7:57 am

I don't think you can do it without loops.

nupogodi
Posts: 53
Joined: Thu Jun 03, 2010 12:50 am

Re: Weighted average of group of time series

Postby nupogodi » Tue Nov 16, 2010 8:47 am

yes it can be done, I figured it out myself...

Code: Select all

series a1 = rnd series a2 = rnd series a3 =rnd series b1 = rnd series b2 = rnd series b3 =rnd group a a* group b b* %c = "("+ @wdelim(@replace(@winterleave(@wcross(A.@members, "* "),b.@members),"* ","*")," ","+") +")/@rsum(B)" series w_avg = {%c}
Last edited by nupogodi on Mon Nov 22, 2010 8:11 am, edited 3 times in total.

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

Re: Weighted average of group of time series

Postby EViews Gareth » Tue Nov 16, 2010 9:06 am

Ha, fair enough.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests