Announcement

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

  • an error occurred when svy executed mlogit: option baseoutcome() is required with prefix svy bootstrap

    Hi,
    Using the code below, I am trying to obtain and save marginal estimates for each iteration of my multinomial logisitic regression. I am getting the error: "an error occurred when svy executed mlogit: option baseoutcome() is required with prefix svy bootstrap". How can I fix this?
    Thanks,
    NM

    set more off
    use http://www.stata-press.com/data/r14/nhanes2f, clear
    svyset psuid [pweight=finalwgt], strata(stratid) psu(psuid)

    capture program drop savemargins
    program savemargins, rclass
    svy, subpop(race): mlogit health i.agegrp##c.zinc
    margins, at(zinc=(0 10)) predict(outcome(1)) post
    end

    bootstrap _b, saving(margins, replace) reps(200): savemargins

  • #2
    Originally posted by Nader Mehri View Post
    I am getting the error: "an error occurred when svy executed mlogit: option baseoutcome() is required with prefix svy bootstrap". How can I fix this?
    Um, maybe by specifying a base outcome using the -baseoutcome()- option of -mlogit-?

    See below.

    .ÿ
    .ÿversionÿ16.1

    .ÿ
    .ÿ/*ÿsetÿmoreÿoffÿ*/
    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿuseÿhttp://www.stata-press.com/data/r14/nhanes2f,ÿclear

    .ÿ
    .ÿsvysetÿpsuidÿ[pweight=finalwgt],ÿstrata(stratid)ÿpsu(psuid)

    ÿÿÿÿÿÿpweight:ÿfinalwgt
    ÿÿÿÿÿÿÿÿÿÿVCE:ÿlinearized
    ÿÿSingleÿunit:ÿmissing
    ÿÿÿÿÿStrataÿ1:ÿstratid
    ÿÿÿÿÿÿÿÿÿSUÿ1:ÿpsuid
    ÿÿÿÿÿÿÿÿFPCÿ1:ÿ<zero>

    .ÿ
    .ÿ/*ÿcaptureÿprogramÿdropÿsavemarginsÿ*/
    .ÿprogramÿsavemargins,ÿrclass
    ÿÿ1.ÿÿÿÿÿÿÿÿÿversionÿ16.1
    ÿÿ2.ÿÿÿÿÿÿÿÿÿsyntax
    ÿÿ3.ÿ
    .ÿÿÿÿÿÿÿÿÿsvy,ÿsubpop(race):ÿmlogitÿhealthÿi.agegrp##c.zinc,ÿbaseoutcome(1)
    ÿÿ4.ÿÿÿÿÿÿÿÿÿmargins,ÿat(zinc=(0ÿ10))ÿpredict(outcome(1))ÿpost
    ÿÿ5.ÿend

    .ÿ
    .ÿtempfileÿmargins

    .ÿbootstrapÿ_b,ÿsaving(`margins'ÿ/*,ÿreplaceÿ*/)ÿreps(20ÿ/*200ÿ*/):ÿsavemarginsÿ
    (runningÿsavemarginsÿonÿestimationÿsample)

    Bootstrapÿreplicationsÿ(20)
    ----+---ÿ1ÿ---+---ÿ2ÿ---+---ÿ3ÿ---+---ÿ4ÿ---+---ÿ5ÿ
    ....................

    PredictiveÿmarginsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ9,188
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿReplicationsÿÿÿÿÿÿ=ÿÿÿÿÿÿÿÿÿ20

    ------------------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿObservedÿÿÿBootstrapÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNormal-based
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿ_atÿ|
    ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ.1371592ÿÿÿ.0369608ÿÿÿÿÿ3.71ÿÿÿ0.000ÿÿÿÿÿ.0647175ÿÿÿÿÿ.209601
    ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.1233056ÿÿÿ.0330288ÿÿÿÿÿ3.73ÿÿÿ0.000ÿÿÿÿÿ.0585704ÿÿÿÿ.1880408
    ------------------------------------------------------------------------------

    .ÿ
    .ÿuseÿ`margins',ÿclear
    (bootstrap:ÿsavemargins)

    .ÿ
    .ÿlistÿinÿ1/2,ÿnoobs

    ÿÿ+---------------------+
    ÿÿ|ÿÿÿÿ_bs_1ÿÿÿÿÿÿ_bs_2ÿ|
    ÿÿ|---------------------|
    ÿÿ|ÿ.1016489ÿÿÿÿ.092148ÿ|
    ÿÿ|ÿ.1981432ÿÿÿ.1738499ÿ|
    ÿÿ+---------------------+

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .

    Comment


    • #3
      I’ve never seen the error before but it makes sense. By default, mlogit chooses the category with the highest N as the base category. When bootstrapping, the category with the highest N could change from one bootstrap to the next.

      Personally, I always choose the base category myself anyway. If I analyzed different sub samples I wouldn’t want the base category to keep changing.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://www3.nd.edu/~rwilliam

      Comment


      • #4
        Originally posted by Richard Williams View Post
        Personally, I always choose the base category myself anyway. If I analyzed different sub samples I wouldn’t want the base category to keep changing.
        Good advice, and I will make it a point to do so in the future if I haven't always in the past.

        Comment

        Working...
        X