mean and var of series by every two obs
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
mean and var of series by every two obs
hi
i have 500 obs named (rate), how can make series (mrate) like this (obs1+obs2)/2, (obs3+obs4)/2, (obs5+obs6)/2....etc
and make variance by two obs.
any idea with this.
i have 500 obs named (rate), how can make series (mrate) like this (obs1+obs2)/2, (obs3+obs4)/2, (obs5+obs6)/2....etc
and make variance by two obs.
any idea with this.
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: mean and var of series by every two obs
Perhaps @movav, @movvar
Re: mean and var of series by every two obs
i need this:
- Attachments
-
- meanvar.png (30.38 KiB) Viewed 10751 times
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: mean and var of series by every two obs
I haven't tried this code, but something like...
Code: Select all
series m=@movav(x,2) ' calculate moving statistics
series v=@movvar(x,2)
m = m(1) ' line up with first observation rather than second
v = v(1)
series isEven= 2*@floor(@obsnum/2) = @obsum ' find even numbered observations
smpl if isEven
m = na ' clear out obs you don't want
v = na
@smpl @all
Re: mean and var of series by every two obs
the problem there is no command or function to do this , and there is no way to do this by frequency conversion methods (hight to low) for integer date.
the code work, but not this result Mr startz
, thanks for all your efforts
any help.
the code work, but not this result Mr startz
any help.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: mean and var of series by every two obs
Not really sure what you're asking - Startz' code does what you want, doesn't it?
Re: mean and var of series by every two obs
the code of Mr startz work. thanks for his help :) .
but i explain: suppose i have 100 obs integer date or unstructured/undated, i would like to calculate mean for every two obs and so on(two observation divided by two) i can chose mean or 3 obs, four obs...... that's what i need , then the result for this manipulation will be 50 obs (new series with 50 obs), same for the variance.
all this like frequency conversion hight to low, but here I can choose the mean of obs (mean of 2 obs, or mean of 3obs,....etc).
are there a solution for this by command or to enhance frequency conversion to do this (mean, variance, median,....) that we can choose the size of observasions.
Warmest regards for Mr Gareth and Mr startz.
but i explain: suppose i have 100 obs integer date or unstructured/undated, i would like to calculate mean for every two obs and so on(two observation divided by two) i can chose mean or 3 obs, four obs...... that's what i need , then the result for this manipulation will be 50 obs (new series with 50 obs), same for the variance.
all this like frequency conversion hight to low, but here I can choose the mean of obs (mean of 2 obs, or mean of 3obs,....etc).
are there a solution for this by command or to enhance frequency conversion to do this (mean, variance, median,....) that we can choose the size of observasions.
Warmest regards for Mr Gareth and Mr startz.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: mean and var of series by every two obs
But startz's code does exactly what you want - you end up with 50 observations that has the mean of every two obs. If you want 3 instead of 2, change the 2s to 3s.
Re: mean and var of series by every two obs
this is my workfile you can see that all series m and v have one value for the first obs and NA for all, this is the code of Mr startz
for example: i have 6 obs 10 12 15 20 30 18
the fisrt mean = (10+12)/2=11
the second mean=(15+20)/2=17.5
the third mean=(30+18)/2=6.25
i need this: (x+x(-1))/2, (x(-2)+x(-3))/2,....etc
but @movav(x,2) calculate the first mean like this(x+x(-1))/2 = (10+12)/2, for the second (x(-1)+x(-2))/2 =(12+15)/2,....etc
Code: Select all
series m=@movav(x,2)
series v=@movvar(x,2)
m = m(1)
v = v(1)
series isEven= 2*@floor(@obsnum/2)
smpl if isEven
m = na ' clear out obs you don't want
v = na
smpl @allthe fisrt mean = (10+12)/2=11
the second mean=(15+20)/2=17.5
the third mean=(30+18)/2=6.25
i need this: (x+x(-1))/2, (x(-2)+x(-3))/2,....etc
but @movav(x,2) calculate the first mean like this(x+x(-1))/2 = (10+12)/2, for the second (x(-1)+x(-2))/2 =(12+15)/2,....etc
- Attachments
-
- st.wf1
- (14.81 KiB) Downloaded 372 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: mean and var of series by every two obs
You didn't copy Startz' code properly.
Re: mean and var of series by every two obs
because it not work, some error message appear 
1)series isEven= 2*@floor(@obsnum/2) = @obsum (@obsum in not a genr or series expression function)
2)@SMPL @all (@SMPL in not defined or is an illegal command)

1)series isEven= 2*@floor(@obsnum/2) = @obsum (@obsum in not a genr or series expression function)
2)@SMPL @all (@SMPL in not defined or is an illegal command)
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: mean and var of series by every two obs
I think you may just have some typos.
Re: mean and var of series by every two obs
i have followed the code step by step Mr startz by i get error (@SMPL in not defined or is an illegal command ) but if i use smpl @all the code work; and i get just the first mean and variance of the two obs. what can i do this is my workfile. 
- Attachments
-
- st.wf1
- (14.81 KiB) Downloaded 342 times
-
- mv.png (26.48 KiB) Viewed 10611 times
-
- error.png (24.16 KiB) Viewed 10611 times
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: mean and var of series by every two obs
The code I posted does not say "@smpl"
I suspect that you may still be suffering from typo problems. Computers are pretty literal minded, so trivial errors can really screw things up.
I suspect that you may still be suffering from typo problems. Computers are pretty literal minded, so trivial errors can really screw things up.
Re: mean and var of series by every two obs
ok! Mr stratz, thanks for all your efforts, same for Mr Gareth. :)
Who is online
Users browsing this forum: No registered users and 2 guests
