Announcement

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

  • Bootstrap with -mi estimate-?

    Hi,
    I am trying to run the following program to estimate direct and indirect effects. I constantly get errors when I do this with –mi-. Like “pp” not found. Moreover, the commands for –matrix- don’t seem to work with –mi-

    Any feed is highly appreciated.


    program myprog , rclass
    capture drop lo pp io wt

    mi estimate, saving(miest, replace): logit x m1 m2 c1 c2

    mi predict lo using miest
    mi xeq: gen pp = exp(lo)/(1+exp(lo))
    mi xeq: gen io = ((1-pp)/pp)

    mi xeq: gen wt = 1 if x==0
    mi xeq: replace wt = io if x==1

    mi estimate, saving(miest, replace) eform post: glm y x c1 c2, fam(poisson) link(log) vce(robust)

    matrix bb_total= e(b)
    scalar b_total=(bb_total[1,1])
    return scalar b_total=bb_total[1,1]

    mi estimate, saving(miest, replace) eform post: glm y x c1 c2 [pweight=wt] , fam(poisson) link(log) vce(robust)
    matrix bb_direct = e(b)
    scalar b_direct=(bb_direct[1,1])
    return scalar b_direct=bb_direct[1,1]


    return scalar b_indirect = b_total-b_direct

    end


    bootstrap exp(r(b_indirect)) exp(r(b_direct)) exp(r(b_total)), seed(32222) reps(50): myprog
    estat bootstrap, all



  • #2
    Welcome to Statalist, Senor!

    This is the forum for discussing Mata, Stata's, matrix language program. Repost on the General Forum. Before you do, read FAQ 12, which asks, among other things 1) that you not describe problems by saying that something "doesn't work"; and 2) that you show all commands and what Stata responded and that you copy (from do file editor, screen, or log) and paste between CODE delimiters, described in the FAQ.
    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment

    Working...
    X