Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Robson Glasscock <glasscockrc@vcu.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Implementing a Momentum Investment Strategy with Stata |

Date |
Wed, 7 Mar 2012 07:24:42 -0500 |

Daniel, I agree with Richard. His advice is much better than mine. I was suggesting a manual approach instead of using -egen, xtile-. The identifier variable would mark the top 10% of performers in each window. If you know each stock in each respective window, then you can write a statement that is conditional on each window and would mark the subsequent returns for these stocks during the following 6 months. These are the returns you would then use to calculate the return on the momentum portfolios. All apologies for the rabbit trail, Robson Glasscock On Tue, Mar 6, 2012 at 2:10 PM, Richard Herron <richard.c.herron@gmail.com> wrote: > You're right it is -egenmore- from SSC. > > The -egen, xtile- command should generate a variable -portfolio- with > integers 1 through 10. When there is no return for that month -egen, > xtile- won't be able to assign a portfolio. > > The -f6.-, -l6.-, and -s6.- are time series operators that shift > forward, lag, or seasonally difference by 6 observations. Before you > can use them you will need to tell Stata your panel identifiers with > -tsset- or -xtset-. > > I don't understand your return notation. You should just have one > variable that contains the n month returns for all stocks. After you > -tsset- your data (something like -tsset permno date_ym-) then the > code from my first reply should work. > > On Tue, Mar 6, 2012 at 10:49, <schmani@gmx.de> wrote: >> Dear Robson, dear Richard, >> >> thank you very much for your input! >> I haven't yet decided whose approach I am gonna follow, hence I have some more issues for clarification: >> >> Robson: >> By introducing an "identifier" variable do you mean that I need to have one variable for each time-window and hence e.g. tag the top 10 performers with a "1"? How can I achieve this when I only have 385 observations, yet the before-mentioned 1400 stocks? I'm not sure I got the intuition behind your idea. Could you kindly clarify this for me? >> >> Richard: >> I assume you meant the egenmore package from ssc, since I could not find egemore? You are right that Jegadeesh and Titman used equally weighted portfolios, this will also be the approach I follow for my study. I tried using your egen command for one sample-portfolio. Is it correct that the generated variable "portfolio" now has only 1s in it for the time period where the stock has returns? >> I probably need to fully understand what you were trying to achieve with your usage of f6., l6. and f6. Could you kindly elaborate on that? I should have mentioned that I have log-returns (named: return_v#-return_v####) whose observations consist of the cumulated previous 6m returns where available. >> It seems to me that the command generates a portfolio based on only one asset (ret6), not on a portfolio of several assets. >> >> (my command looked like this: egen portfolio = xtile( return_v1377), nquantiles(10) by (date) ) Do I have to use the whole set of data (i.e. return_v#-return_v####) instead of just one return set? >> >> Your help is greatly appreciated, as I am quite a novice in Stata. >> >> Best regards, >> >> Daniel >> >> >> -------- Original-Nachricht -------- >>> Datum: Sun, 4 Mar 2012 17:40:42 -0500 >>> Von: Richard Herron <richard.c.herron@gmail.com> >>> An: statalist@hsphsun2.harvard.edu >>> Betreff: Re: st: Implementing a Momentum Investment Strategy with Stata >> >>> I don't think there's a need to use -rolling-. I think there are two >>> main steps here. Generating the portfolios, then generating the time >>> series of returns for eash of these portfolios. >>> >>> I would generate the portfolios using -xtile- from the -egemore- package >>> (SSC). >>> >>> generate ret6 = s6.price / l6.price >>> egen portfolio = xtile(ret6), nquantiles(10) by(date_ym) >>> >>> where -ret6- is your holding period return and -date_ym- is the >>> year-month date (say 2001m5). Now generate the portfolio holding >>> period returns using collapse and time series operators. >>> >>> collapse (mean) f6.ret6, by(date_ym portfolio) >>> >>> You may also want to use weightings to determine portfolio weights >>> (although I think Jegadeesh and Titman is all equally weighted). Now >>> you can use these portfolios to generate returns to your strategy. >>> HTH. >>> >>> On Sun, Mar 4, 2012 at 09:20, Robson Glasscock <glasscockrc@vcu.edu> >>> wrote: >>> > Christopher Baum's "An Introduction to Stata Programming" discusses >>> > moving-windows in Chapter 8. The -rolling- command is mentioned as >>> > well as Cox and Baum's -mvsumm- and -mvcorr- programs (available from >>> > SSC). Looking into these may help you think about a modified approach >>> > to your problem. >>> > >>> > Instead of using matrices, I wonder if it would be better to generate >>> > two new variables that would help you identify the top 10% of firms in >>> > each window. First, generate a "window" variable that would take on a >>> > value of 1 for months 1-6, 2 for months 2-7, 3 for months 3-8, etc. >>> > Second, generate an "identifier" variable that tags the top 10% of >>> > firms in each window. You would know exactly which firms were included >>> > in each window and then it would be possible for you to calculate the >>> > returns for those firms over the next six months. Or maybe clever use >>> > of -rolling- is the better approach here. I'm not sure, but I hope >>> > this is enough to get you started. >>> > >>> > best, >>> > Robson Glasscock >>> > >>> > >>> > On Sun, Mar 4, 2012 at 7:43 AM, <schmani@gmx.de> wrote: >>> >> Dear all, >>> >> >>> >> I am trying to implement a Momentum Strategy following >>> Jegadeesh/Titman(1993): Returns to Buying Winners and Selling Losers: Implications for >>> Stock Market Efficiency, JoF 48(1), pp. 65-91. >>> >> >>> >> I have monthly returns for ~1400 stocks for a total of 385 time periods >>> and now have to proceed in the following way: >>> >> >>> >> 1) build cumulated returns over a formation period of 6months (I did >>> that by generating new variables) >>> >> >>> >> 2) select the top 10% performing stocks in order to invest. This is >>> done every month in order to generate so-called "overlapping" portfolios. >>> >> >>> >> 3) invest in those stocks for a holding period of 6 months >>> >> >>> >> 4) determine the average of the returns and adjust for risk >>> >> >>> >> >>> >> For now, my approach was to generate matrices for every month t that >>> consist of the cumulated returns over the previous 6 months. >>> >> However I can not find an efficient way to sort these matrices while >>> being able to identify which assets to invest in (this is crucial as I need >>> to tell Stata somehow which assets to invest in). >>> >> >>> >> I am sure there is a better way to sort the cumulated returns of the >>> previous 6 months in every month t while still being able to somehow "track" >>> the variable name in order to invest in the corresponding stock. >>> >> I hope I made myself clear, any help would be greatly appreciated! >>> >> >>> >> Best, >>> >> Daniel >>> >> -- >>> >> NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! >>> >> Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a >>> >> * >>> >> * For searches and help try: >>> >> * http://www.stata.com/help.cgi?search >>> >> * http://www.stata.com/support/statalist/faq >>> >> * http://www.ats.ucla.edu/stat/stata/ >>> > >>> > * >>> > * For searches and help try: >>> > * http://www.stata.com/help.cgi?search >>> > * http://www.stata.com/support/statalist/faq >>> > * http://www.ats.ucla.edu/stat/stata/ >>> >>> * >>> * For searches and help try: >>> * http://www.stata.com/help.cgi?search >>> * http://www.stata.com/support/statalist/faq >>> * http://www.ats.ucla.edu/stat/stata/ >> >> -- >> NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! >> Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a >> * >> * For searches and help try: >> * http://www.stata.com/help.cgi?search >> * http://www.stata.com/support/statalist/faq >> * http://www.ats.ucla.edu/stat/stata/ > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Implementing a Momentum Investment Strategy with Stata***From:*schmani@gmx.de

**Re: st: Implementing a Momentum Investment Strategy with Stata***From:*Robson Glasscock <glasscockrc@vcu.edu>

**Re: st: Implementing a Momentum Investment Strategy with Stata***From:*Richard Herron <richard.c.herron@gmail.com>

**Re: st: Implementing a Momentum Investment Strategy with Stata***From:*schmani@gmx.de

**Re: st: Implementing a Momentum Investment Strategy with Stata***From:*Richard Herron <richard.c.herron@gmail.com>

- Prev by Date:
**st: RE: generating variables based on the co-occurrence of ids in groups over time** - Next by Date:
**RE: st: Copying Stata code with line numbers** - Previous by thread:
**Re: st: Implementing a Momentum Investment Strategy with Stata** - Next by thread:
**st: Censored Least Absolute Deviation and Probit** - Index(es):