Creating dummies that vary over time and across funds

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

lb85
Posts: 11
Joined: Tue May 08, 2012 9:55 am

Creating dummies that vary over time and across funds

Postby lb85 » Tue May 08, 2012 12:45 pm

Hello,

I have an unbalanced panel data set of 1381 funds over 145 months and I'll run a regression with monthly net flows as dependent variable and lagged monthly returns as independent variable (plus some control variables). I have two (related) questions regarding dummy creation (in Eviews 6 student version):

1) For the descriptive statistics part I'd like to do a univariate analysis of e.g. the independent variable ln_return and check whether the mean of returns below the median is significantly different from those above the median. I know that you can do this by "Equality Tests by Classification" and insert a dummy but I wonder how to create this dummy.
If I use something like "series dummy_median=@recode(ln_return<median(ln_return),0,1)" does it take all monthly returns (no matter in which month or for which fund), calculate the median and then assign the dummy as to whether the return is below or above this median?

2) This leads me to the second question: As I'd like to use a piecewise regression later on with the ln_return split into quartiles, I need to create a dummy variable for each quartile with for instance dummy Q1 taking the value 1 if the fund's return in a specific month is above the 75th of all funds in the cross-section in existence in this month and 0 otherwise. How can I create such a dummy that is varying over cross-section and over time-series?

Many thanks for your help and please let me know if you need additional information.

Cheers, LB

lb85
Posts: 11
Joined: Tue May 08, 2012 9:55 am

Re: Creating dummies that vary over time and across funds

Postby lb85 » Thu May 10, 2012 2:01 am

Hi Eviews moderators..

I'd really appreciate your help regarding my question above as I'm stuck right now.

Many thanks in advance.

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

Re: Creating dummies that vary over time and across funds

Postby EViews Gareth » Thu May 10, 2012 7:43 am

1) Yes.
2) Use the @mediansby function to create median values by time (entering @month, @year as the by variables), or by cross-section (entering @crossid as the by variable).

lb85
Posts: 11
Joined: Tue May 08, 2012 9:55 am

Re: Creating dummies that vary over time and across funds

Postby lb85 » Thu May 10, 2012 8:54 am

Hi Gareth

Many thanks for your reply.

I started with the function in 1. and a pop-up window said that "median" is not defined. What is the exact function I need to use to calculate the median as described in 1. ? Isn't there a function to calculate this similar as calculating a log by just typing log(x)?

Thanks, lb

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

Re: Creating dummies that vary over time and across funds

Postby EViews Gareth » Thu May 10, 2012 9:02 am

@median

lb85
Posts: 11
Joined: Tue May 08, 2012 9:55 am

Re: Creating dummies that vary over time and across funds

Postby lb85 » Sat May 26, 2012 9:13 am

Hi Gareth

The dummy creation worked fine but now I'd need your help on the following:

For the same panel, I need to assign percentile ranks to the variable ln_return. In particular, I'd like to create a new series that instead of the ln_return states the percentile rank for the fund compared to its cross section and this for every month. The percentile ranking should take values between 0 and 1.

Is there something like @ranksby or do you have any other idea?

I need the ranks to then split the variable ln_return into quintiles and run a piecewise linear regression.

Thanks again for the help,
lb85

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

Re: Creating dummies that vary over time and across funds

Postby EViews Gareth » Sat May 26, 2012 3:12 pm

There's no function built in that will do that.

lb85
Posts: 11
Joined: Tue May 08, 2012 9:55 am

Re: Creating dummies that vary over time and across funds

Postby lb85 » Sun Jun 03, 2012 6:37 am

Isn't there a way to normalize a return series (stacked data) to a series that takes values between 0 and 1?

In Excel, I would calculate the following for each a cross section:

To get rid of the negative values:
abs_series = return_series+abs(min(return_series))

To get values between 0 and 1:
rank_series = abs_series-min(abs_series)/max(abs_series)-min(abs_series)

But as I have a panel data set, it should apply the values between 0 and 1 grouped by period and not for all the values in the return series.
How could I implement this in Eviews 6?

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

Re: Creating dummies that vary over time and across funds

Postby EViews Gareth » Sun Jun 03, 2012 10:09 am

Use the @minsby and @maxsby with "@crossid" as the by variable.

lb85
Posts: 11
Joined: Tue May 08, 2012 9:55 am

Re: Creating dummies that vary over time and across funds

Postby lb85 » Mon Jun 04, 2012 5:41 am

Hi Gareth

Thanks for your help. I was able to create a new series that contains ranks (from 0 to 1) named ranks_ret instead of the return.The next step is to split this series into quintiles which I thought is rather simple.

For example, to calculate the quintile 1-3 I did:
Quintile_1_ranks=@min(0.2,ranks_ret)
Quintile_2_ranks=@min(0.2,ranks_ret-quintile_1_ranks)
Quintile_3_ranks=@min(0.2,ranks_ret-(quintile_1_ranks+quintile_2_ranks))
...

However, I'm not able to create these new series. It always returns the following error message "Error in Sample: Illegal date ranks_ret"

Could I share the file with you?

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

Re: Creating dummies that vary over time and across funds

Postby EViews Gareth » Mon Jun 04, 2012 7:53 am

What are you trying to do with the line:

Code: Select all

Quintile_1_ranks=@min(0.2,ranks_ret)

lb85
Posts: 11
Joined: Tue May 08, 2012 9:55 am

Re: Creating dummies that vary over time and across funds

Postby lb85 » Mon Jun 04, 2012 10:23 am

Series quintile_1_ranks should take the value from the series ranks_ret if it is below 0.2 or 0.2 else and so on...
Please find attached an example of how the values should be in each quintile.
Attachments
Quintile_example.xlsx
(9.39 KiB) Downloaded 801 times

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

Re: Creating dummies that vary over time and across funds

Postby EViews Gareth » Mon Jun 04, 2012 11:24 am

Code: Select all

series quantile_1_ranks = @recode(ranks_ret<0.2, ranks_ret, 0.2)

lb85
Posts: 11
Joined: Tue May 08, 2012 9:55 am

Re: Creating dummies that vary over time and across funds

Postby lb85 » Mon Jun 04, 2012 11:26 am

Thanks Gareth, that's what I did as well, but I just wonder why it's not working with the @min function...

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

Re: Creating dummies that vary over time and across funds

Postby EViews Gareth » Mon Jun 04, 2012 11:41 am

Because the @min function doesn't find the minimum of two series. It find the minimum of a single series (through time/observations).


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests