Announcement

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

  • Recording the same coefficient from a series of regressions

    Hi all,

    I'm running a FE model looking at how a group of firms learn over time. I've had no trouble running the FE regression on the data as a whole, but I'm now compiling some descriptive statistics to dive deeper and running into a bit of trouble. One variable I'm hoping to find is the learning curve coefficient for each plant. I can get the data using:

    Code:
    bysort Company: xtreg lnthpp lnprevcpn, fe i(Company)
    However, when I run the above, I get the needed coefficients of lnprevcpn (the learning curve coefficient) for each company, but I have dozens of companies and haven't figure out how to pull the coefficient from all the individual regressions. Does anyone know how to do this? I feel like using a loop is the answer...but I haven't gotten it to work yet.


    Here is the data I'm working with:
    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str19 Company float(Time lnprevcpn lnthpp)
    "Aeronca" -6178  3.555348      .841875
    "Aeronca" -6150 4.2195077     1.368276
    "Aeronca" -6119 4.7095304     1.368276
    "Aeronca" -6089   5.17615     .8674005
    "Aeronca" -6058  5.517453       .47045
    "Aeronca" -6028  5.765191       .47045
    "Aeronca" -5997  5.966147     .2407028
    "Aeronca" -5966  6.144186    .23789136
    "Aeronca" -5936  6.289716     .4542553
    "Aeronca" -5905  6.428105     .2451846
    "Aeronca" -5875  6.543912     .4087929
    "Aeronca" -5844   6.64639    .27057222
    "Aeronca" -5813  6.739336     .3789256
    "Aeronca" -5784  6.796824     .3789256
    "Beech"   -6543  .6931472     1.901655
    "Beech"   -6515 1.7917595     1.901655
    "Beech"   -6484 1.7917595    1.4674554
    "Beech"   -6454  2.944439    1.0514572
    "Beech"   -6423  3.871201     .6917826
    "Beech"   -6393  4.564348     .4726517
    "Beech"   -6362  5.003946    .24851587
    "Beech"   -6331   5.70711    .23853956
    "Beech"   -6301   6.05444    .15596718
    "Beech"   -6270  6.327937    .03834617
    "Beech"   -6240  6.559615 -.0042514447
    "Beech"   -6209  6.731018     .2600305
    "Beech"   -6178  7.003066    .18433976
    "Beech"   -6150  7.090077     -.089991
    "Beech"   -6119   7.17012     -.089991
    "Beech"   -6089  7.244227     -.089991
    "Beech"   -6058  7.313221     -.089991
    "Beech"   -6028  7.377759     -.089991
    "Beech"   -5997  7.438384     -.089991
    "Beech"   -6849         0    1.8184277
    "Beech"   -6819 1.0986123    1.0487404
    "Beech"   -6788  1.609438    1.5365766
    "Beech"   -6758 2.0794415    1.4260347
    "Beech"   -6727 2.6390574    1.4129626
    "Beech"   -6696 3.0910425    1.3823677
    "Beech"   -6666  3.465736    1.3231963
    "Beech"   -6635   3.78419    1.2766453
    "Beech"   -6605  4.060443     1.292726
    "Beech"   -6574 4.2904596    1.2188873
    "Beech"   -6543  4.812184    1.1772776
    "Beech"   -6515  5.313206    1.0638937
    "Beech"   -6484  5.673323     .7529046
    "Beech"   -6454  5.902633     .6173171
    "Beech"   -6423  6.115892     .5447693
    "Beech"   -6393  6.317165     .4450232
    "Beech"   -6362  6.504288      .446149
    "Beech"   -6331  6.661855     .4032539
    "Beech"   -6301  6.806829     .3868723
    "Beech"   -6270  6.926577     .4192548
    "Beech"   -6240  7.037028      .397741
    "Beech"   -6574 1.3862944    1.1664267
    "Beech"   -6543 2.0794415     1.149939
    "Beech"   -6515   2.70805    1.1489885
    "Beech"   -6484 3.0445225    1.1331748
    "Beech"   -6454  3.433987    1.1331748
    "Beech"   -6423  3.637586    1.1331748
    "Beech"   -6393 3.8286414     1.115961
    "Beech"   -6362 4.0253515     1.115961
    "Beech"   -6331  4.158883     1.115961
    "Beech"   -6301  4.248495    1.0986123
    "Beech"   -6270 4.3438053    1.0986123
    "Beech"   -6240 4.4188404    1.0986123
    "Beech"   -6209 4.4188404    1.1121864
    "Beech"   -6178 4.4188404    1.0777291
    "Beech"   -6150 4.6151204     .9266371
    "Beech"   -6119 4.7361984     .9266371
    "Beech"   -6089   4.85203     .8413516
    "Beech"   -6058  4.955827     .8413516
    "Beech"   -6028  5.036952     .8413516
    "Beech"   -5997  5.111988     .7483454
    "Beech"   -5966  5.181784     .7483454
    "Beech"   -5936  5.252274     .7483454
    "Beech"   -5905  5.327876     .7236764
    "Beech"   -5875  5.433722     .7236764
    "Beech"   -5844  5.513429     .7236764
    "Beech"   -5813  5.598422     .6983835
    "Beech"   -5784   5.68358     .6983835
    "Beech"   -5753  5.774551     .7190586
    "Beech"   -5723  5.846439     .5521595
    "Beech"   -5692  5.918894    .58193624
    "Beech"   -5662  5.934894     .5521595
    "Beech"   -6178  5.669881    1.0742844
    "Beech"   -6150  5.799093     1.054404
    "Beech"   -6119  5.991465     .9986796
    "Beech"   -6089  6.109248     .9475459
    "Beech"   -6058  6.214608      .867547
    "Beech"   -6028   6.39693     .8162609
    "Beech"   -5997   6.55108     .7645634
    "Beech"   -5966  6.684612     .6643144
    "Beech"   -5936  6.802395     .6094617
    "Beech"   -5905  6.907755     .5431446
    "Beech"   -5875  7.090077     .4988392
    "Beech"   -5844  7.313221     .4603728
    "Beech"   -5813  7.495542     .4332105
    "Beech"   -5784  7.600903      .404399
    "Beech"   -5753  7.824046      .361604
    end
    format %td Time

  • #2
    Code:
    rangestat (reg) lnthpp lnprevcpn, by(Company) interval(Time . .)
    -rangestat- is written by Robert Picard, Nick Cox, and Roberto Ferrer, and is available from SSC.

    Note that you are not really doing fixed-effects regression here. Whether using -rangestat- or -by Company- or other iterative approaches, you are only doing regression within one company at a time--so the distinction between ordinary least squares regression and fixed-effects regression evaporates.

    Comment


    • #3
      Something like

      Code:
      egen cgroup = group(Company)
      reg lnthpp i.cgroup i.cgroup#c.lnprevcpn
      will effectively run separate regressions for each company and give the coefficients.
      Last edited by Jackson Monroe; 17 Nov 2021, 10:27.

      Comment


      • #4
        Rangestat (#2) worked perfectly!

        And Clyde, you're absolutely right. I'm not sure what I was thinking with the FE; the only thing I could do would be to add vce(robust) to the regression (but I don't think this can be done in rangestat)—that said, this won't impact the coefficient which is what I'm interested in here.

        Thank you!!

        Comment

        Working...
        X