Announcement

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

  • Margins dydx(*), atmeans command after running twopm (two-part model)

    Hello,

    I am running a two-part model for a large sample survey data. After defining the svysetelements (see below), I ran the twopmprocedure with defined subpopulation which produced estimable outcomes. However, while running the next step of the margins command, almost all covariates were not estimable.
    Can you identify an issue with the code or suggest a better method of defining the svyset elements?

    Also, the margins command takes an awfully long time (2 full days!). What could be the reason?

    CODE:

    svyset hosp_nrd [pweight=discwt], strata(nrd_stratum) vce(linearized) singleunit(missing)

    pweight: discwt
    VCE: linearized
    Single unit: missing
    Strata 1: nrd_stratum
    SU 1: hosp_nrd
    FPC 1: <zero>


    svy, subpop(indexevent_ard): twopm readmitcost_2 i.female i.agecat i.patloc i.pay1 i.zipinc_qrtl i.tot_unrel_comor i.hcup_ed2 i.h_contrl i.hosp_urcat4 i.hosp_ur_teach i.dmonth los, firstpart(logit) secondpart(glm, family(gamma) link(log))

    margins, dydx(*) atmeans



    OUTPUT:

    ---------------------------------------------------------------------------------
    | Delta-method
    | dy/dx Std. Err. z P>|z| [95% Conf. Interval]
    ----------------+----------------------------------------------------------------
    1.female | . (not estimable)
    |
    agecat |
    3 | . (not estimable)
    4 | . (not estimable)
    5 | . (not estimable)
    |
    patloc |
    2 | . (not estimable)
    3 | . (not estimable)
    |
    pay1 |
    2 | . (not estimable)
    3 | . (not estimable)
    4 | . (not estimable)
    5 | . (not estimable)
    6 | . (not estimable)
    7 | . (not estimable)
    |
    zipinc_qrtl |
    2 | . (not estimable)
    3 | . (not estimable)
    4 | . (not estimable)
    5 | . (not estimable)
    |
    tot_unrel_comor |
    1 | . (not estimable)
    2 | . (not estimable)
    3 | . (not estimable)
    4 | . (not estimable)
    |
    1.hcup_ed2 | . (not estimable)
    |
    h_contrl |
    2 | . (not estimable)
    3 | . (not estimable)
    |
    hosp_urcat4 |
    2 | . (not estimable)
    3 | . (not estimable)
    4 | . (not estimable)
    |
    dmonth |
    2 | -128.4357 59.65185 -2.15 0.031 -245.3512 -11.52025
    3 | -184.5084 59.66988 -3.09 0.002 -301.4593 -67.55761
    4 | -129.2712 67.57373 -1.91 0.056 -261.7133 3.170888
    5 | -86.47192 66.31225 -1.30 0.192 -216.4415 43.49769
    6 | -58.55037 63.64463 -0.92 0.358 -183.2916 66.19082
    7 | 28.21226 60.41113 0.47 0.640 -90.19138 146.6159
    8 | -24.72032 62.83588 -0.39 0.694 -147.8764 98.43575
    9 | -141.1451 64.69266 -2.18 0.029 -267.9404 -14.34986
    10 | -231.7357 56.86605 -4.08 0.000 -343.1911 -120.2803
    11 | -391.36 63.8644 -6.13 0.000 -516.5319 -266.1881
    |
    los | . (not estimable)
    ---------------------------------------------------------------------------------
    Note: dy/dx for factor levels is the discrete change from the base level.

    .


  • #2
    Welcome to the Stata Forum/Statalis,

    Please prefer to use - dataex - or CODE delimiters to share data/command/output. You'll find advice on how to follow this procedure (plus many more tips) in the FAQ. Thanks.

    That said, I wonder whether using the - margins - command without the option "atmeans" wouldn't solve the issue.

    The examples from this article published in the Stata Journal don't use -atmeans - when dealing with categorical variables. Maybe this is the reason, but I cannot tell for sure, since I have not enough expericence with twopm.

    Hopefully that helps.
    Best regards,

    Marcos

    Comment


    • #3
      Thank you for your response. I see that the article did not use -atmeans- and so you I will take your suggestion and try running without it. I will keep you posted.

      Comment


      • #4
        Running margins without -atmeans- did not work either. I still see not ematimable results. Any other suggestions?

        Comment


        • #5
          I had the same problem. It is because you are not specifying the subpop command with the margins command. Make sure you specify the subpop command again after running the two part model.

          e.g.

          margins, dydx(*) atmeans subpop(indexevent_ard)
          or
          margins, dydx(*) subpop(indexevent_ard)

          Comment

          Working...
          X