Dear Stata Forum Community,
I am conducting research on financial statement comparability and need to compute two metrics:
drop if companyid == companyid2 // Remove self-comparison
gsort companyid Year Industry -CompAcct // Sort by highest comparability
bysort companyid Year Industry: gen rank = _n // Rank firms j for each firm i
bysort companyid Year Industry: egen Com1 = mean(CompAcct) if rank <= 4 // Average top 4 firms
bysort companyid Year Industry: egen Com2 = mean(CompAcct) if rank <= 10 // Average top 10 firms
I want to confirm: Is this approach correct for calculating the comparability metrics?
I am conducting research on financial statement comparability and need to compute two metrics:
- CompAcct4it: The average CompAcctijt of the four firms (j) with the highest comparability to firm i during period t.
- CompAcct10it: The average CompAcctijt of the ten firms (j) with the highest comparability to firm i during period t.
- Firm i (companyid)
- Firm j (companyid2)
- Year (Year)
- Industry (Industry)
- CompAcct (a measure of financial statement comparability between firm i and firm j)
drop if companyid == companyid2 // Remove self-comparison
gsort companyid Year Industry -CompAcct // Sort by highest comparability
bysort companyid Year Industry: gen rank = _n // Rank firms j for each firm i
bysort companyid Year Industry: egen Com1 = mean(CompAcct) if rank <= 4 // Average top 4 firms
bysort companyid Year Industry: egen Com2 = mean(CompAcct) if rank <= 10 // Average top 10 firms
I want to confirm: Is this approach correct for calculating the comparability metrics?