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
Calculating MHHI with triple summationHi everybody! I'm looking to create a Modified Herfindahl-Hirschmann Index (MHHI) in STATA from the …
Generating a new variable but missing values have been includedHi, My code is: Code: generate var_66 = 1 if var_33 >=2 However it has put a 1 in the new va…
Regression gives different results depending on the order of the independent variablesI am running what is essentially a difference in differences regression on a large dataset with a lo…
Trying to create a new variable out of the response of the respondents in the survey ! Your help will be much appreciatedHello Intelligent People, The version of STATA i am using is 14.2 on a Windows 10 Here is a glimps…
Create categorical variable*hi! new to stata/in a stats class... i have a dataset that has individual race dummy variables. Is t…
Subscribe to:
Post Comments (Atom)
0 Response to within-group covariance by year
Post a Comment