Trimmed mean

For questions regarding programming in the EViews programming language.

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

PMaier
Posts: 36
Joined: Sat Sep 11, 2010 10:12 am

Trimmed mean

Postby PMaier » Sun Feb 13, 2011 6:19 am

Hi,

I was wondering whether you had any tips on how to calculate a trimmed mean... I have a matrix of forecasting results from different models, and rather than to average them across models, I would like to calculate trimmed means - that is, exclude the highest and lowest observation and average over the rest.

I can think of a couple of complicated ways to do this, but maybe someone has a really easy solution...? :-)

Thanks, Philipp

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Trimmed mean

Postby trubador » Mon Feb 14, 2011 1:32 am

Something like the following might work for calculating the trimmed means:

Code: Select all

vector trmean = (@rows(ymat)*@cmean(ymat)-(@cmin(ymat)+@cmax(ymat)))/(@rows(ymat)-2)

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

Re: Trimmed mean

Postby EViews Gareth » Mon Feb 14, 2011 9:05 am

or,

Code: Select all

smpl @first+1 @last-1 scalar mean = @mean(x)
Or for more general trimming, use the Trim Add-in.

PMaier
Posts: 36
Joined: Sat Sep 11, 2010 10:12 am

Re: Trimmed mean

Postby PMaier » Mon Feb 14, 2011 4:14 pm

Solution 1 works perfectly!

Thanks, Philipp


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests