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
Population Variable SignifcanceI am currently analysing a Log-Lin model, in which I am adding the independent variable LN Pop to te…
Pincipal Component Analysis IndexHi everyone. I am working with data from 126 schools in rural Angola. I want to create a index for …
Time Dummy Variables in stcoxHi, I am analyzing the factors that affect the time-on-market when selling a house using -stcox-. …
Regression on unbalanced panelHi, I'm currently working on impact of risk - taking behavior on firm growth, and here is my panel:…
Why is the mixed command slow? Can it be sped up?I'm attempting to do a simulation comparing resutls from a random effects model with a random interc…
Subscribe to:
Post Comments (Atom)
0 Response to Mean correcting a panel data set
Post a Comment