Announcement

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

  • Parmest command for recovering dummy variable coefficients with labels

    Hi All,

    I have dataset that looks like the following:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(year y x) long code
    1990  23 123 1
    1991  23 432 1
    1990 235  24 2
    1991  45 324 2
    1992  34 324 3
    1993 543 324 3
    1990  43 324 4
    1990 543 432 4
    1990  43  32 4
    end
    label values code code2
    label def code2 1 "ABC", modify
    label def code2 2 "CDN", modify
    label def code2 3 "ESP", modify
    label def code2 4 "USA", modify

    In this dataset, I have the y variable, x variable and an indicator for country and year.

    The regression I am performing takes the form:

    regress y x i.code i.year

    I wish to recover the country specific fixed effects (estimates of the country dummies), and merge them back to the dataset. The issue is that when I use the parmest command to store the coefficients, the country specific labels disappear, making it impossible to merge them with the dataset. Any insights on this are most welcome.



  • #2
    You are wanting to store the country fixed effects in a variable? If so, something like this should work:
    Code:
    reg y x i.code i.year
    preserve
        parmest, norestore
        
        gen code = regexs(1) if regexm(parm, "([0-9])b?\.code")
        destring code, replace
        keep if code!=.
        keep estimate code
        rename estimate FE
        save "your_path\temp_data.dta", replace
    restore
    
    merge m:1 code using "your_path\temp_data.dta"
    Just change "your_path" to somewhere on your computer.

    Comment


    • #3
      Thanks for your reply. This however, does not work, as it stores the country fixed effects by a numeric label (between 0-9) that does not correspond to the original dataset. I would ideally want the country fixed effects stored alongside a column that contains the original country code the fixed effects correspond to.

      Comment


      • #4
        I'm not sure I understand.

        The output from the regression is:
        HTML Code:
        note: 1993.year omitted because of collinearity
        
              Source |       SS           df       MS      Number of obs   =         9
        -------------+----------------------------------   F(6, 2)         =      1.10
               Model |  300917.082         6   50152.847   Prob > F        =    0.5479
            Residual |  91162.4738         2  45581.2369   R-squared       =    0.7675
        -------------+----------------------------------   Adj R-squared   =    0.0700
               Total |  392079.556         8  49009.9444   Root MSE        =     213.5
        
        ------------------------------------------------------------------------------
                   y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                   x |   .9933606   .7294518     1.36   0.306    -2.145217    4.131939
                     |
                code |
                CDN  |   219.8128   226.4536     0.97   0.434    -754.5383    1194.164
                ESP  |   275.0696    317.468     0.87   0.478    -1090.885    1641.024
                USA  |   2.662364   243.7776     0.01   0.992    -1046.228    1051.553
                     |
                year |
               1991  |  -397.4783   308.0871    -1.29   0.326     -1723.07    928.1136
               1992  |       -509   301.9312    -1.69   0.234    -1808.105    790.1053
               1993  |          0  (omitted)
                     |
               _cons |  -53.91842    206.236    -0.26   0.818    -941.2802    833.4434
        ------------------------------------------------------------------------------
        and the final dataset looks like this:
        HTML Code:
        year    y    x    code    FE    _merge
        1990    23    123    ABC    0    matched (3)
        1991    23    432    ABC    0    matched (3)
        1990    235    24    CDN    219.81282    matched (3)
        1991    45    324    CDN    219.81282    matched (3)
        1992    34    324    ESP    275.06958    matched (3)
        1993    543    324    ESP    275.06958    matched (3)
        1990    43    324    USA    2.6623636    matched (3)
        1990    543    432    USA    2.6623636    matched (3)
        1990    43    32    USA    2.6623636    matched (3)
        which is what I thought you wanted. Can you clarify what you want the final dataset to look like?




        Comment

        Working...
        X