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
Bootstrapping or robust standard errors?Hi, I am new to stata and self-thought, so please have overlook if I have missunderstood anything. I…
Computing predictive margins (mimrgns) for gsem with random effectsDear Statalisters, I would much appreciate your help with the following problem: I am not able to …
Heckman MLE and convergence issueHello Everyone, I am currently trying to estimate a gravity model for migrations and face a problem…
keep the observation nearest to 4/20?Dear All, I found this question here (https://bbs.pinggu.org/thread-7644841-1-1.html). The data is …
Coefficient change sign from negative to positive when control variables are added. Why?Hi! I'm making multiple regression and has a variable namned RP as an independent/control variable.…
Subscribe to:
Post Comments (Atom)
0 Response to within-group covariance by year
Post a Comment