Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loop of time series regression

    Hi all,

    I am new to Stata and I have the following problem.

    I have to conduct an event study for 1,500 US firms, having different event dates, i.e. announcement of activism campaign.

    I have the following data:
    - For each firm, I have the series of returns in the 250 days before the announcement, paired (in the next column) with the corresponding date
    - For each of the 4 Fama French Carhart factors, I have the series of returns paired with the corresponding dates, which cover the entire of range of dates of the returns of the firms.

    As far as I am concerned, the first step would be to estimate a time series regression of the returns of a firm on the returns 4 Fama-French-Carhart factors in the 250 days before the announcement. This time series regression should be repeated for each firm in the sample, so:
    - The y variable (i.e. returns of the firm) should be different in each of the 1,500 time series regressions;
    - The dependent variables are the same for each regression (FFC factors)
    - The 250 dates are different for each regression

    I was thinking to build a "loop" that for each company should automatically regress its returns on the 4 FFC Factors, automatically selecting only 250 the relevant dates for the FFC factors.

    Did I explain sufficiently clearly my problem?

    Any suggestions on how to do it?

  • #2
    I don't understand the Fama French Carhart factors, but it sounds like you want to do the same regression analysis separately in each firm in your data. If that's right, and given the size of your data set, rather than looping over the firms explicitly, you will get things done faster by using the -rangestat- command. -rangestat- is written by Robert Picard, Nick Cox, and Roberto Ferrer and is available from SSC.

    Something like this:
    Code:
    rangestat (reg) Y X1 X2 X3 X4 X5 if in_window, by(firm_id)
    If the regression you need to do is more complicated than a simple OLS, or if you also need to do some post-estimation calculations, then look instead at -runby-, written by Robert Picard and me, also available from SSC.

    If you need more concrete help with coding, be sure to use the -dataex- command to show an example of your data when you post back. If you are running version 15.1 or a fully updated version 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    Comment

    Working...
    X