Hi all, I hope you can help me.
I have constructed panel data om which i have monthly returns (x) for 500+funds, for which I will be doing three factor regression (y,z) to estimate the constant.
Now I also have monthly data on a fourth variable (u). I want to create samples (quintiles) and attribute each cross section (fund) to a quintile based upon the average value of u over the entire period (10 years).
I could go back to excel and calculate the quintiles and work with dummies, but I would assume there is a much easier way to do this in eviews.
Thanks already for your help.
Creating quantile samples in paneldata
Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Creating quantile samples in paneldata
Hello,
I believe you can accomplish what you want with the following:
where "fund" is your fund/cross-section series.
I believe you can accomplish what you want with the following:
Code: Select all
for !i = 1 to 5
sample quintile!i if (!i = 1 or @meansby(u, fund) >= @quantile(@meansby(u, fund), .2 * (!i - 1))) and (!i = 5 or @meansby(u, fund) < @quantile(@meansby(u, fund), .2 * !i))
next
where "fund" is your fund/cross-section series.
Re: Creating quantile samples in paneldata
Hi,
you may try the following, obtaining the dummy series du
Alternatively, assuming that there are no NA's in the @last period:
with du=dv
Best, mamo
you may try the following, obtaining the dummy series du
Code: Select all
series du=@ceiling(@groupid(@ranks(@meansby(u,crossid, "@all"),a,l))/4)
Alternatively, assuming that there are no NA's in the @last period:
Code: Select all
dv=1
for !i=1 to 4
series dv=dv+(@meansby(u,fund, "@all")>=@quantile(@meansby(u,fund,"@all"),(!i)*0.2,"@last @last"))
next
with du=dv
Best, mamo
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Creating quantile samples in paneldata
Clever, but the division by four isn't quite right in the first example. I believe it should be:
Wasn't aware that @groupid preserved relative magnitude. That's more convenient than having to divide by @obsby(fund,fund) or equivalent.
Code: Select all
series du=@ceiling(@groupid(@ranks(@meansby(u,fund)))/(@max(@crossid)/5))
Wasn't aware that @groupid preserved relative magnitude. That's more convenient than having to divide by @obsby(fund,fund) or equivalent.
Re: Creating quantile samples in paneldata
You are right, and honestly, after second thoughts, the first suggestion does not work at all.
If anything, the divisor should be sth like @ceiling([number of crosssections]/[number of quantile].
But even that would not in general provide the desired result.
The reason is that the actual values of the series, rather than just the ranking, is required in order to determine the quantile limits precisely.
The 2nd suggestion, i.e. the for loop, which is similar to your proposal, should work (of course, provided that there are no NA in @last).
Best, mamo
If anything, the divisor should be sth like @ceiling([number of crosssections]/[number of quantile].
But even that would not in general provide the desired result.
The reason is that the actual values of the series, rather than just the ranking, is required in order to determine the quantile limits precisely.
The 2nd suggestion, i.e. the for loop, which is similar to your proposal, should work (of course, provided that there are no NA in @last).
Best, mamo
Who is online
Users browsing this forum: No registered users and 31 guests