Announcement

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

  • Calculate the mean -- as part of a regression command

    Hello Statalist experts,

    I am trying to run a regression command -- where, within the *same* regression command -- I compute the mean of 3 values. Basically, I try to study the effect of a certain firm_strategy on firm_profits. However, the dependent variable firm_profits should *not* just be the firm profits in t0, but rather be the mean value of the firm profits in years t+1, t+2 and t+3.

    So I was wondering whether there is any way of computing the mean as part of a regression command -- and *not* as a separate command.
    It would make things in my context substantially easier if there was a way that doesn't require a line in the code first that computes the mean value of the firm profits in years t+1, t+2 and t+3. And then a second line that runs the regression. But rather do the both things in the same command.

    I am aware that "F." helps me to get the lead values. So, for example, if my DV should be the firm profits in year t+1, I would type the following command
    xtreg F1.firm_profits firm_strategy controls, fe

    However, instead of only getting the value of firm_profits in t+1 as the DV (through using "F1.") -- is there any way how I can get the mean of the years t+1, t+2 and t+3

    I also tried the following, but it did not work unfortunately as intended:
    xtreg F(1/3).firm_profits firm_strategy controls, fe
    The problem with this command is that it uses firm_profits in t+1 as the DV -- and includes firm_profits in t+2 and the firm_profits in t+3 as controls.

    Thank you so much for any help on this.

    Franz
    Last edited by Franz Hopp; 06 Nov 2019, 12:42.

  • #2
    You can calculate the mean profits in a forward 3-year window as
    [code]
    rangestat (mean) firm_profits, by(firm) interval(t 1 3)
    [code]
    Replace firm by the variable that identifies firms, and t by the variable that identifies years. -rangestat- is written by Robert Picard, Nick Cox, and Roberto Ferrer, and is available from SSC.

    This will not, however, also do the regression in a single step with the mean calculation. I don't know of any way to do that all in one command in Stata.

    Comment

    Working...
    X