Running variance plot

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

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

Re: Running variance plot

Postby EViews Gareth » Tue Sep 11, 2012 7:53 am

Not quite sure what you're asking.

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

Re: Running variance plot

Postby EViews Gareth » Tue Sep 11, 2012 10:36 am


s_r(n)²=1/(n-1)*sum[t=1 to n](x(t)-mean)²
ok, I'm going to assume that you wish to generate a series following the above formula. Without knowing what the components of that formula are, it is pretty difficult to tell you how to do so.

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

Re: Running variance plot

Postby EViews Gareth » Tue Sep 11, 2012 1:59 pm

The @trend, @cumsum and @mean functions will get you there. Something like:

Code: Select all

series s_r = 1/(@trend)*@cumsum(x-@mean(x))

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

Re: Running variance plot

Postby EViews Glenn » Tue Sep 11, 2012 2:15 pm

While Gareth has given you the command that matches your expression, the problem with this as a cumulative variance is that the mean adjustment to the original data uses a mean that isn't cumulative. So it's not quite a cumulative variance.

So while I'm not sure what you want, I will point out that there are recursive formulae for the variance:
http://mathworld.wolfram.com/SampleVari ... ation.html
http://blogs.sas.com/content/iml/2012/0 ... -variance/

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

Re: Running variance plot

Postby EViews Glenn » Wed Sep 12, 2012 9:39 am

That's fine if you are happy with that calculation. The only thing I was pointing out is that you are computing your variance using a mean that is taken from the full sample which is slightly different from the "draw the variance estimated from the first n terms" interpretation.

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

Re: Running variance plot

Postby EViews Glenn » Fri Sep 14, 2012 3:43 pm

That is correct.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest