Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Origin Dest Airline Data

    My airline data looks like this:

    input str3(origin dest) str41 unique_carrier_name int departures_performed long passengers int year byte quarter

    "ATL" "BNA" "Regions Air, Inc." 47 218 2005 1
    "ATL" "BNA" "Regions Air, Inc." 47 292 2005 1
    "ATL" "MIA" "American Airlines Inc." 165 13314 2005 1
    "ATL" "ORD" "American Airlines Inc." 102 9202 2005 1
    "ATL" "DFW" "American Airlines Inc." 319 29358 2005 1

    I want to generate a new variable the Herfindahl–Hirschman Indices (HHI) — a conventional measure of market concentration, constructed as the sum of the squares of the market shares of all the firms on the market. Data is than the marketshare of an airline on a specific origin/dest pair route per quarter
    However I do not have an OD pair in my dataset. How can I generate this? Thanks!

    I think my following syntax looks like this:


    Code:
    #generate groups for route
    sort ODpair
    by ODpair: gen ODpairgroup = 1 if _n==1
    replace ODpairgroup = sum(ODpairgroup)
    replace ODpairgroup =.if missing(ODpair)
    
    #generate HHI variable option2
    gen MS2=(npaxtotal/paxroute)^2
    sort ODpairgroup
    egen HHI=sum(MS2), by(ODpairgroup)

  • #2
    You didn't get a quick answer. You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

    You don't tell us what the measure of market share is - departures, passengers, or what? For your specific question, you can generate the od pair by
    generate pair=origin + dest

    As I read your example, you have more than one set of observations for Regions between Atl and BNA in the first quarter of 2005. So, after generating the odpairs, first I'd collapse the data to generate a summary number for each odpair, airline, date.

    This might be a case where doing the calculations in wide format is easier than long. Then you can use egen with rowtotal and similar functions to do the calculations.

    Comment


    • #3
      Thank you for answering my question Phil. I generated a new ODpair.

      Comment

      Working...
      X