Announcement

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

  • saving estimated coefficients for individuals

    Hello, I have a balanced panel data in STATA, with 10 individuals (id) and 5 years (year). For each individual-year I have a variable capturing "compensation" and a variable capturing "performacne". I am interested in saving the extent of performance-based compensation for each individual. Specifically, I want a code that regresses compensation on performance separately for each individual and saves the estimated coefficient as well as P-value. The resulting outcome should contain 10 rows and 3 columns: id, alpha, p-val. I would greatly appreciate your help.
    Last edited by Ali Nickpour; 13 Feb 2024, 21:05.

  • #2
    The simplest way to do this is:
    Code:
    rangestat (reg) compensation performance, by(id) interval(year . .)
    -rangestat- is written by Robert Picard, Nick Cox, and Roberto Ferrer. It is available from SSC.

    Note: As no example data was provided, this code is untested and may contain errors. In the future, when asking for help with code it is always wise to include example data. And the most effective way to do that is with the -dataex- command. If you are running version 18, 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    Comment


    • #3
      Thank you Clyde. This is the output using -dataex- command. Can you please check if the rangestat achieves the right outcome?

      clear
      input float(id year compensation performance)
      1 1 67444 86
      1 2 63344 36
      1 3 56832 77
      1 4 51428 59
      1 5 93447 33
      2 1 67543 18
      2 2 53555 81
      2 3 66168 31
      2 4 77755 23
      2 5 93800 73
      3 1 60235 70
      3 2 94638 91
      3 3 79223 68
      3 4 68489 36
      3 5 92532 74
      4 1 69569 20
      4 2 55983 32
      4 3 87712 15
      4 4 84751 66
      4 5 84331 28
      5 1 96597 90
      5 2 72744 58
      5 3 53370 12
      5 4 66899 42
      5 5 98744 1
      6 1 86322 67
      6 2 52271 35
      6 3 87298 9
      6 4 74806 14
      6 5 85836 24
      7 1 92987 34
      7 2 56704 42
      7 3 74422 5
      7 4 93561 9
      7 5 88323 2
      8 1 62563 33
      8 2 58318 2
      8 3 87190 24
      8 4 99026 85
      8 5 86479 98
      9 1 95055 4
      9 2 63218 99
      9 3 94283 90
      9 4 94106 97
      9 5 87447 25
      10 1 95981 70
      10 2 84673 49
      10 3 60770 44
      10 4 91429 59
      10 5 52211 38
      end
      [/CODE]

      Comment


      • #4
        The results produced by -rangestat- are correct, but on re-reading #1 I realize that they do not include everything you asked for You asked for the p-values, and those aren't there. So you need to compute them. So the code becomes:
        Code:
        rangestat (reg) compensation performance, by(id) interval(year . .)
        gen tstat = b_performance/se_performance
        gen pvalue = 2*t(reg_nobs-2, -abs(tstat))

        Comment

        Working...
        X