Announcement

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

  • tnbreg does not converge

    I am trying to run a Zero-Truncated Negative Binomial Regression with the attached data. The code I used is down below. But it is not converging. What could be the problem? My stata version is 14.2


    Code:
    tnbreg PPE_tot Sex Age Educ_2 Educ_3 Educ_4 certification Off_farm_income live_in_farm Exp_AGRIC ProdVal_scale REGION2 REGION3 HHsz Cooperative Mines Cred_req Landsize_ha size_type if PPE_tot!=0 , vce(robust)
    
    tnbreg PPE_tot Sex Age Educ_2 Educ_3 Educ_4 certification Off_farm_income live_in_farm Exp_AGRIC cereals forage fruit_tree hoticulture_crop industrial_crop legumes_crop other_crop root_crop REGION2 REGION3 HHsz Cooperative Mines Cred_req Landsize_ha size_type if PPE_tot!=0 , vce(robust)

    I had this working but I seem not to be confident with the results considering the observations reported.
    Code

    Code:
    tnbreg PPE_tot Sex Age Educ_2 Educ_3 Educ_4 certification Off_farm_income live_in_farm Exp_AGRIC total REGION2 REGION3 HHsz Cooperative Mines Cred_req Landsize_ha size_type if PPE_tot>0 , vce(robust)
    How do i go about it or resolve it. The picture below shows the result of the just above code. I have also attached the data used (Data_2.dta)
    Attached Files
    Last edited by Michael Kwadwo; 23 Oct 2022, 20:31.

  • #2
    Try this:
    Code:
    version 14.2
    
    clear *
    
    use Data_2
    
    capture rename *, lower // Not sure when this new syntax was introduced.
    if _rc {
        foreach var of varlist _all {
            local new_name = lower("`var'")
            rename `var' `new_name'
        }
    }
    quietly compress
    
    /* nbreg ppe_tot i.sex c.age i.educ_ i.certification i.off_farm_income
           i.live_in_farm c.exp_agric c.prodval_scale i.region c.hhsz i.cooperative
           i.mines i.cred_req c.landsize_ha i.size_type, iterate(20)
       shows that i.size_type is the problem, so: */
    
    version 14.2: table size_type, contents(mean landsize_ha ///
        min landsize_ha max landsize_ha n landsize_ha)
    
    label list `: value label size_type'
    
    recode size_type (0=1) (2=0)
    version 14.2: table size_type, contents(mean landsize_ha ///
        min landsize_ha max landsize_ha n landsize_ha)
    
    // And now you get convergence
    quietly tnbreg ppe_tot i.sex c.age i.educ_ i.certification i.off_farm_income ///
        i.live_in_farm c.exp_agric c.prodval_scale i.region c.hhsz i.cooperative ///
        i.mines i.cred_req c.landsize_ha i.size_type if ppe_tot > 0
    display in smcl as result e(converged)
    
    // But you essentially have no better fit than with truncated Poisson regression:
    display in smcl as text "Alpha = " as result e(alpha), ///
        as text "Chi-square against Poisson = " as result e(chi2_c)
    
    // So, how about:
    tpoisson ppe_tot i.sex c.age i.educ_ i.certification i.off_farm_income ///
        i.live_in_farm c.exp_agric c.prodval_scale i.region c.hhsz i.cooperative ///
        i.mines i.cred_req c.landsize_ha i.size_type if ppe_tot > 0, nolog
    
    // or even better:
    tabulate ppe_tot, missing
    poisson ppe_tot i.sex c.age i.educ_ i.certification i.off_farm_income ///
        i.live_in_farm c.exp_agric c.prodval_scale i.region c.hhsz i.cooperative ///
        i.mines i.cred_req c.landsize_ha i.size_type /* if ppe_tot > 0 */, nolog
    
    exit

    Comment

    Working...
    X