Hi there,
I would like to compute the within-firm covariance(wage_t, wage_{t-1}) for each year. I listed some sample panel data below.
year firm job wage
2000 1 1 10
2000 1 2 11
2000 1 3 10
2000 2 4 8
2000 2 5 4
2000 2 6 11
2000 2 7 5
2000 3 8 5
2000 3 9 9
2000 4 10 7
2000 4 11 8
2001 1 1 10.5
...
...
If it were not covariance, I could have just used egen ... by (year firm) to generate a wage moment for each firm each year and then take the mean across firms to get one number for each year to compute the average within-firm wage moment for each year. With tabstat I could easy print the within-firm moment by year as a table. But egen does not go with corr command.
But since I need covariance, so far I tried bysort firm year: cor wage lagwage, covariance, it gives me a matrix for each firm-year pair, but then I will have to manually select the covariance I need from a matrix in each firm-year pair and then compute the average cov across firms for each year. There are too many firms and year, and thus their pairs in the real data to make this an efficient approach. Any better solutions that allow me to calculate and print the results out by year as a table?
Thanks!
Related Posts with within-group covariance by year
Combining MICE with predictive mean matchingI am trying to multiply impute n=30 data sets, and I am hoping to do this using both chained equatio…
Creating plots to investigate non-linear effectsHi, I'm having trouble creating and understanding plots that show a non-linear effect and how this …
Error message: no room to add more variablesHi all, I am trying to combine three DHS surveys by appending them all using following command. us…
Is there a model for Spatial Panel Regression with a binary/dummy dependent variable?Hello, this is my first topic in Statalist. However, I have been using it as reader throughout the l…
Error message: Repeated time values within panelHi, I am struggling to understand why I am unable to xtset my panel data. I have used the Understa…
Subscribe to:
Post Comments (Atom)
0 Response to within-group covariance by year
Post a Comment