Simple coding question. How do I mean correct a set of panel data. The example here is a set of values to TSR by Year and Company, and the companies fall into categories in the variable Category
The coding I was trying is:
gen MeanTSR = 0
forvalues Y = 2005/2018 {
bysort Category: egen meanTSR`Y' = mean(TSR) if Year == Y
replace MeanTSR = meanTSR`Y' if Year == Y
}
gen corrTSR = TSR - MeanTSR
What I find is that I get the same value for all years, as if the if Year == Y was not effective.
There must be a better "Stata" way to do this.
Many thanks
Jamie
Related Posts with Mean correcting a panel data set
Q about specific Difference-in-Difference design with unbalanced Panel dataHi all, I am currently thinking about an empirical design which im unsure of if it is really a DiD a…
ANOVA test, and margins after multiple regressionHello guys, I have a count data. The independent variable is the number of children. I have two nomi…
Number of firms and observations decreases in fixed effects ordered logit modelHi Statalist members, I recently found we are able to run fixed effects to the ordered logit model.…
Fixed effect ordered logitDear all, I have a panel dataset of 2700 firms with quarterly dates from 1985 to 2017. My panel is …
Create a variable that indicates when unit was first treated with panel dataHello everyone. This is my first post here, I have been looking for information on how to do this bu…
Subscribe to:
Post Comments (Atom)
0 Response to Mean correcting a panel data set
Post a Comment