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
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
Comment