Average, Ignoring "NA"

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

kcaron
Posts: 101
Joined: Wed Mar 04, 2015 11:46 am

Average, Ignoring "NA"

Postby kcaron » Sun May 15, 2016 4:09 pm

I have a number of calculated series with data that either is present or isn't ("NA").

I'm looking for a formula that will produce an average of the available data:

Field Value
Cat 2
Dog 4
Bird NA

Average = 3...

Easy stuff, but I'm stuck.

Help greatly appreciated...

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

Re: Average, Ignoring "NA"

Postby EViews Gareth » Sun May 15, 2016 4:34 pm

View->Descriptive Statistics.

kcaron
Posts: 101
Joined: Wed Mar 04, 2015 11:46 am

Re: Average, Ignoring "NA"

Postby kcaron » Mon May 16, 2016 6:49 am

Thanks, Gareth... Very cool...
But that's not what I mean...

I have ten calculated fields that assume values of either 1, 0.5, 0, or NA based on other fields' values... I need to find the average of the ten fields for the month of April.

If data is not available yet for one of the series that produce the values 1, 0.5, or 0, the value in the calculated field comes back as "NA". When "NAs" are present, I can't calculate the average of the individual calculated fields.

I know it may not be the best practice, but I really want that average to be calculated based on whatever number of values are available. I don't want the "NA" to prevent the average from being calculated.

...

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

Re: Average, Ignoring "NA"

Postby EViews Gareth » Mon May 16, 2016 9:38 am

You'll need to be more precise on what you are doing. The descriptive statistics of a series ignore NAs and will not pass them on, by default.

kcaron
Posts: 101
Joined: Wed Mar 04, 2015 11:46 am

Re: Average, Ignoring "NA"

Postby kcaron » Mon May 16, 2016 3:18 pm

I have three different calculated series. Two of them have numbers in them. One has a NA value.

I've got another series that calculates the average of the first three. If there is an NA value, my average doesn't work.

I'm just looking for a formula that will take the average of the two available numbers and ignore the NA.

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

Re: Average, Ignoring "NA"

Postby EViews Gareth » Mon May 16, 2016 3:28 pm

Still fairly vague...

It sounds like you are trying to calculate the mean of three series on an observation by observation basis. The way to do this in EViews is to put the three series in a group, then use the @rmean function. I assume that's what you're doing. But the @rmean function (like nearly all other functions) ignores NAs, so I don't know what the issue is.

Code: Select all

create u 100 series x=1 series y=2 series z=3 smpl 2 2 z = na smpl 5 5 z=na smpl @all group g x y z series mymean = @rmean(g) show mymean

kcaron
Posts: 101
Joined: Wed Mar 04, 2015 11:46 am

Re: Average, Ignoring "NA"

Postby kcaron » Mon May 16, 2016 3:43 pm

Yes. That's it. I didn't know about group row functions.

Now I do.

Thank you.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests