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
mhodds and test for trendDear Listers, I am considering using the -mhodds- command for an expvar with more than 2 levels in …
Error in finding host for ssc package downloadHi all, I'm currently working on my thesis with the Abadie-Imbens estimator and have been using Sta…
Choosing reference/base periods in panel data and normalizing the corresponding coefficient to zeroHi I am looking to do two things with a panel dataset (c350 firms and annual data from 2008 to 2016…
Regression with change relative to base yearHello! I am sorry if this topic came up before, I tried searching for answers but without luck. I ha…
How to deal with circular causalityThis is a statistics question rather than a Stata question. But I figured I'd ask anyway, since the …
Subscribe to:
Post Comments (Atom)
0 Response to within-group covariance by year
Post a Comment