standard deviation and average

For questions regarding programming in the EViews programming language.

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

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

standard deviation and average

Postby miorinnovo » Tue Jan 29, 2019 3:56 pm

I'd like to create charts of my variables that include the average and the standard deviation of each series. SO the first variable x1 would be plotted against the average of x1 and the average of x1 plus and minus the standard deviation. Now in order to do this I believe I have to create a scalar for each and then generate a new series of that one variable repeated. I have many variables with different naming conventions. My question, is there a simple way to program the creation of these scalars and series? Thanks!

EViews Matt
EViews Developer
Posts: 563
Joined: Thu Apr 25, 2013 7:48 pm

Re: standard deviation and average

Postby EViews Matt » Tue Jan 29, 2019 4:38 pm

Hello,

My quick-and-dirty way to create such graphs is via a group, e.g.,

Code: Select all

group g x1 @mean(x1) @mean(x1)+@stdev(x1) @mean(x1)-@stdev(x1)
g.line

The graph can be frozen and it's line styles, legend, etc., modified to create the look you want.

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

Re: standard deviation and average

Postby miorinnovo » Tue Jan 29, 2019 6:36 pm

Thats so much better than what i was going for. Thanks!

And can I program this for all variables in one shot somehow?

EViews Matt
EViews Developer
Posts: 563
Joined: Thu Apr 25, 2013 7:48 pm

Re: standard deviation and average

Postby EViews Matt » Wed Jan 30, 2019 10:02 am

Sure, you can always introduce a loop that will iterate through your series. For example,

Code: Select all

%series = @wlookup("*", "series")
for %s {%series}
   group g {%s} @mean({%s}) @mean({%s})+@stdev({%s}) @mean({%s})-@stdev({%s})
   %graph_name = %s + "_graph"
   freeze({%graph_name}) g.line
next
delete g

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

Re: standard deviation and average

Postby miorinnovo » Wed Jan 30, 2019 1:22 pm

Fantastic, thanks!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 24 guests