Weighted moving Average
Moderators: EViews Gareth, EViews Moderator
Weighted moving Average
When I tried to do forcasting for the stoch market return series with Eviews, there was no provision for weighted moving average model (estimation/forecast) as was indicated for the ARCH models. What should I do? Please can someone help me urgently? Rgds
Re: Weighted moving Average
You can calculate the weighted moving average as shown below. However, please note that it will not work properly if you have NAs in the series.
Code: Select all
call wma(y,10)
subroutine wma(series y,scalar m)
'y is the name of your series
'm is the number that indicates the window size
%name = y.@name
%m = @str(m)
series {%name}_wma_{%m}
for !i = 0 to @obs({%name})-m
smpl @first+m-1+!i @first+m-1+!i
{%name}_wma_{%m} =0
for !j = 1 to m
{%name}_wma_{%m} = {%name}_wma_{%m} + (m-!j+1)*{%name}(-!j+1)
next
next
smpl @all
{%name}_wma_{%m} = {%name}_wma_{%m}/(m*(m+1)/2)
endsub
Re: Weighted moving Average
Thank you very much Sir. I am excited and indeed most grateful to you trubador. I still have an issue that am trying to resolve and I shall revert to you shortly on it, if am unable to resolve it. This forum is a wondeful innovation by QMS and a good learning ground. Please do not be weary in assisting learners and software neophytes like us. Rgds and God bless u.
Re: Weighted moving Average
Hello
this codes seems to work great but I would like to clarify 2 lines with whomever could help please.
in the line "smpl @first+m-1+!i @first+m-1+!i" why is the first argument repeated?
could anyone clarify this line please " {%name}_wma_{%m} = {%name}_wma_{%m} + (m-!j+1)*{%name}(-!j+1)
Much Appreciated your assistence
WN
this codes seems to work great but I would like to clarify 2 lines with whomever could help please.
in the line "smpl @first+m-1+!i @first+m-1+!i" why is the first argument repeated?
could anyone clarify this line please " {%name}_wma_{%m} = {%name}_wma_{%m} + (m-!j+1)*{%name}(-!j+1)
Much Appreciated your assistence
WN
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13307
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Weighted moving Average
The smpl command sets the sample. It takes a pair of dates as the arguments, the start date and the end date. Thus if you want the sample to be only one observation, you should use the same date as the start and end date.
That second line is just adding the lagged value of the series to the weighted series.
That second line is just adding the lagged value of the series to the weighted series.
Follow us on Twitter @IHSEViews
Re: Weighted moving Average
Thank You
Cheers
Cheers
Return to “Program Repository”
Who is online
Users browsing this forum: No registered users and 12 guests