Announcement

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

  • Stata encountering negative weights, but no negative weights in data!!

    Hi everyone,

    I am trying to run a weighted regression using reghdfe. Here is my code:

    Code:
    local filename "an1"
    local X0 "oberegion#year year unitid" //fixed effects
    local eventtime exp1
    local sample "if ever_certonly!=1 & ever_not24yr!=1 & ever_notpub!=1 & ever_special_use!=1"
    
    
    preserve
    set more off
    local r replace
    forvalues s=0/1{    
            if `s'==0 {
                local spec " & iclevel ==1 | treated == 1"
            }
            else if `s'==1 {
                local spec " & iclevel==2 | treated == 1 "
            }
            reghdfe log_eftotlt_ftf _T_`eventtime'* `sample' `spec' [w=wt], a(`X0') cl(fips)
    }
    
    restore
    And I am getting this error!

    (analytic weights assumed)
    weight wt can only contain strictly positive reals, but 25242 negative values were found!
    r(402);

    I double checking my weight variable (wt) and there are no negative values. Not sure why this error is coming up. Any ideas?

  • #2
    Thanks for providing code.

    Originally posted by Dana Shaat View Post
    I double checking my weight variable (wt) and there are no negative values.
    How exactly did you do that? Type

    Code:
    summarize wt
    count
    assert (wt > 0) & !mi(wt)
    and show us the output.

    Comment


    • #3
      The community-contributed package reghdfe (ssc describe reghdfe) , which requires the community-contributed ftools package, is possibly returning an incorrect error message. See -help trace- to debug.
      Last edited by Bjarte Aagnes; 01 Jul 2020, 05:34.

      Comment

      Working...
      X