Announcement

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

  • esttab producing wrong estimates for imputed margins

    Hi, Im trying to use esttab to export my margins in some imputed data and while the estimates on the screen are correct the exported coefficients are wrong. Any help or guidance
    would be appreciated

    Code:
    capture program drop emargins_mlogit0
    program emargins_mlogit0, eclass properties(mi)
                    version 15
                    args var
                    mlogit mortality26_43 `var' sex, rrr
                    eststo margin1: margins, dydx(*) predict(pr) post
    end
    foreach var of varlist f_ses m_edu ownedu housing {
    mi estimate, post dots cmdok: emargins_mlogit0 `var'
            
            
    
    esttab  margin1 using "margins_ses.txt", ///
    cells(`"b(fmt(%9.3f) ) ci_l ci_u p (fmt(3))"') stats() modelwidth(20) ///
    plain nolabel nogaps varwidth (15) nolines  compress append   nolabel  ///
    collabels("") nocons  
    }

  • #2
    I do not think that eststo (from SSC?) should be inside of emargins_mlogit0. Probably you want something along these lines

    Code:
    capture program drop emargins_mlogit0
    program emargins_mlogit0, eclass properties(mi)
                    ...
                    margins, dydx(*) predict(pr) post
    end
    
    foreach var of varlist f_ses m_edu ownedu housing {
        mi estimate , post dots : emargins_mlogit0 `var'
        estimates store margins1 // <- new        
    
        esttab margin1 using "margins_ses.txt", ...
    }
    Best
    Daniel
    Last edited by daniel klein; 21 Jan 2020, 08:50.

    Comment

    Working...
    X