Mean of values of the series for decile of another series

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

sierov
Posts: 7
Joined: Thu Aug 01, 2019 7:26 am

Mean of values of the series for decile of another series

Postby sierov » Thu Aug 01, 2019 12:31 pm

Hi everyone,

Could you please help me solve this puzzle? I have a time series A filled with observations and a series B filled with observations for the same time frame. Is there a way to find a mean of values of series B corresponding to every decile of series A?

As an example, you can imagine a time series A filled with 1000 observations ranging from 1 to 10 and a series B of 1000 observations. I would like to take the last decile (from 9 to 10) of series A and calculate a mean of the corresponding observations from series B.

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

Re: Mean of values of the series for decile of another series

Postby EViews Matt » Thu Aug 01, 2019 1:57 pm

Hello,

As an example, the following creates scalars mean1, mean2, ..., mean10 for the means of b matching the observations spanning the deciles of a.

Code: Select all

for !i = 1 to 10
   smpl if @ceil(@pctiles(a) / 10) = !i
   scalar mean!i = @mean(b)
next

sierov
Posts: 7
Joined: Thu Aug 01, 2019 7:26 am

Re: Mean of values of the series for decile of another series

Postby sierov » Sat Aug 03, 2019 2:46 am

Hi Matt,

Thank you for your help! Logically it is a great solution even though I needed to use @100 * @ranks(a, “a”, ties) / @obs(a) instead of @pctiles(a) in order to get it to work for my setup.

EViews Matt wrote:Hello,

As an example, the following creates scalars mean1, mean2, ..., mean10 for the means of b matching the observations spanning the deciles of a.

Code: Select all

for !i = 1 to 10
   smpl if @ceil(@pctiles(a) / 10) = !i
   scalar mean!i = @mean(b)
next

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

Re: Mean of values of the series for decile of another series

Postby EViews Matt » Sat Aug 03, 2019 6:30 am

Ah, you're using EViews 10 or earlier. No problem.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 22 guests