Announcement

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

  • Multiple fixed effects using areg, absorb(fe)

    Hello everyone,

    I am having three different regions for my regression analysis. Every region consists of distinct countries. I am running regression region wise and everything is looped over. Now, for example, I have 20 countries (and i want to use country wise fixed effects) thus have generated 20 dummies for all 20 countries which means 20 columns consist of 0 and 1. Here is the command i am using for regression

    Code:
    areg `v' evt_time evt_l* `controls' [pweight=rwtresp], absorb(dum*)  cluster(hhid)

    for v local is defined where i have all the variables of interest. Since i have dum1 dum2.....dum20. That's how i am trying to use dummies with absorb. It works fine if i use only one 1 dummy like dum15 or dum2. But it does not work altogether in the current format and gives me this error

    absorb(): too many variables specified
    Can you please suggest how to fix this problem.



  • #2
    Syed:
    what you're experiencing is related to -areg- mechanism.
    -absorb()- should be fed with one categorical variable only, as you can see from the following toy-example:
    Code:
    . sysuse auto
    (1978 Automobile Data)
    
    . areg price weight length, absorb(rep78)
    
    Linear regression, absorbing indicators         Number of obs     =         69
    Absorbed variable: rep78                        No. of categories =          5
                                                    F(   2,     62)   =      22.98
                                                    Prob > F          =     0.0000
                                                    R-squared         =     0.4341
                                                    Adj R-squared     =     0.3793
                                                    Root MSE          =  2294.5106
    
    ------------------------------------------------------------------------------
           price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          weight |   5.478309   1.158582     4.73   0.000     3.162337    7.794281
          length |  -109.5065   39.26104    -2.79   0.007    -187.9882   -31.02482
           _cons |   10154.62   4270.525     2.38   0.021      1617.96    18691.27
    ------------------------------------------------------------------------------
    F test of absorbed indicators: F(4, 62) = 2.079               Prob > F = 0.094
    
    . tab rep78, g(dummy)
    
         Repair |
    Record 1978 |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              1 |          2        2.90        2.90
              2 |          8       11.59       14.49
              3 |         30       43.48       57.97
              4 |         18       26.09       84.06
              5 |         11       15.94      100.00
    ------------+-----------------------------------
          Total |         69      100.00
    
    . areg price weight length, absorb(dummy*)
    absorb():  too many variables specified
    r(103);
    
    . g categorical_rep78=1 if dummy1==1
    (72 missing values generated)
    
    . replace categorical_rep78=2 if dummy2==1
    (8 real changes made)
    
    . replace categorical_rep78=3 if dummy3==1
    (30 real changes made)
    
    . replace categorical_rep78=4 if dummy4==1
    (18 real changes made)
    
    . replace categorical_rep78=5 if dummy5==1
    (11 real changes made)
    
    . areg price weight length, absorb( categorical_rep78 )
    
    Linear regression, absorbing indicators         Number of obs     =         69
    Absorbed variable: categorical_rep78            No. of categories =          5
                                                    F(   2,     62)   =      22.98
                                                    Prob > F          =     0.0000
                                                    R-squared         =     0.4341
                                                    Adj R-squared     =     0.3793
                                                    Root MSE          =  2294.5106
    
    ------------------------------------------------------------------------------
           price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          weight |   5.478309   1.158582     4.73   0.000     3.162337    7.794281
          length |  -109.5065   39.26104    -2.79   0.007    -187.9882   -31.02482
           _cons |   10154.62   4270.525     2.38   0.021      1617.96    18691.27
    ------------------------------------------------------------------------------
    F test of absorbed indicators: F(4, 62) = 2.079               Prob > F = 0.094
    Hence, you have to create am unique 20-level categorical variable and plug it in as the argument of -absorb()-.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      You are right I just figure that out. In addition to this, I have already created 20 unique variables I used local for dummies where i

      Code:
      local fes "dum1 dum2 dum3 dum4 dum5 dum6 dum7 dum8 dum9 dum10 dum11 dum12 dum13 dum14 dum15 dum16 dum17 dum18 dum19 dum20"
      local outcomes "oop_spend age_hosp working ritearnsemp sitearnsemp hgovt hittot log_hittot"
      
      
      foreach fe in `fes' {
      
      foreach v of varlist `outcomes' { 
      
          local controls ""
          if "`fe'"=="hhidpn" {
              xi i.wave
              drop _Iwave_11
              local controls "_I*"
              if regexm("`v'","_c")==1 {
                  drop _Iwave_2 _Iwave_3 
              }
              
              drop _Iwave_2 _Iwave_3 
          }
      
      
      
      areg `v' evt_time evt_l* `controls' [pweight=rwtresp], absorb(`fes')  cluster(hhidpn)
      
      }
      }
      but still, the error remains the same. I don't know why?

      Comment


      • #4
        I want to use argument because i want to add one more fixed effect (cohortXwave) in my regression in addition to country fixed effects. In that case, it will not work even if i recode all the dummies into one categorical variable.

        Comment


        • #5
          Syed:
          - I cannot say what went wrong with your code;
          . as far as your last question is concerned, you can take a look at the user-written programme -reghdfe- by Sergio Correia.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            solved thanks

            Comment


            • #7
              Syed:
              happy with reading that you've found a solution.
              You may want to share it with the list, as other could benefit from it.
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment

              Working...
              X