Announcement

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

  • How to exclude one group from fixed effect when running forvalue loop

    I ran the following regression with importer fixed efects

    ppml trade exp_fe_* imp_fe_1-imp_fe_`=$NoC-1' LN_DIST CNTG import_cost_1, iter(30) noconst

    The regression runs but it drops importer 9 FE, because of

    note: imp_fe_9 omitted because of collinearity

    So as a next step, when I try to run the following:

    forvalues i=1(1)`=$NoC-1'{ // use fixed effects estimates (MR)
    qui replace exp_fe_`i'=exp_fe_`i'*exp(_b[exp_fe_`i'])
    qui replace imp_fe_`i'=imp_fe_`i'*exp(_b[imp_fe_`i'])
    }


    I get

    [imp_fe_9] not found

    How can I tell STATA to skip imp_fe_9 when running the forvalues loop?

    Thanks!!

  • #2
    Code:
    capture replace
    will eat any error.

    Comment


    • #3
      Or
      Code:
      forvalues i=1(1)`=$NoC-1'{ // use fixed effects estimates (MR)
          if `i' != 9 {
              qui replace exp_fe_`i'=exp_fe_`i'*exp(_b[exp_fe_`i'])
              qui replace imp_fe_`i'=imp_fe_`i'*exp(_b[imp_fe_`i'])
          }
      }

      Comment

      Working...
      X