Announcement

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

  • mimrgns & pwcompare with continuous # categorical interaction

    Hi all. I'm struggling with getting output when using mimrgns followed by pwcompare for a categorical by continuous interaction. This is my first post. My apologies for any unclear phrasing.

    Here is my setup:
    misstable patterns participate1 sense1 ruca_3cat walk10rec walk10utility male age_consent safecrime collegeplus white incomeunder50
    quietly misstable summarize participate1 sense1 ruca_3cat walk10rec walk10utility male age_consent safecrime collegeplus white incomeunder50, gen(miss_)
    describe miss_*
    mi set flong
    mi register imputed participate1 sense1 walk10rec walk10utility safecrime collegeplus white incomeunder50
    mi impute chained (logit) safecrime collegeplus white incomeunder50 (truncreg, ll(1) ul(5)) participate1 sense1 (truncreg, ll(0) ul(6))walk10rec (truncreg, ll(0) ul(12)) walk10utility = i.male i.ruca_3cat age_consent, add(20) rseed(2122) dots
    mi svyset [w= weight_saq], psu(psu) strata(strata_final) vce(linearized) singleunit(centered)


    I can regress and produce marginsplot graphs following mimrgins used with cmdmargin, but I'm struggling to get pwcompare to produce output.

    If I phrase the syntax as follows, Stata runs, but doesn't provide output (and no error message). Below is all that Stata produces:

    mimrgns ruca_3cat, dydx(walk10rec) pwcompare(effects)

    note: option predict() not specified; predict(xb) assumed

    Multiple-imputation estimates
    Pairwise comparisons of average marginal effects

    Imputations = 20
    Number of obs = 1,758
    Number of strata = 33 Population size = 4,473,551
    Number of PSUs = 73
    Average RVI = 0.1895
    Largest FMI = 0.1478
    Complete DF = 40
    DF adjustment: Small sample DF: min = 31.83
    avg = 35.36
    Within VCE type: Delta-method max = 37.26

    Expression : Linear prediction, predict(xb)
    dy/dx w.r.t. : walk10rec



    I've also tried the following syntax, but I get the subsequent error messages.

    . mimrgns ruca_3cat, at(walk10rec=(0(1)6)) pwcompare(effects)
    note: option predict() not specified; predict(xb) assumed
    _b_stat::fill_groups_wrk_unbal(): 3301 subscript invalid
    _b_stat::fill_groups(): - function returned error
    _b_stat::compute_groups(): - function returned error
    _b_stat::compute(): - function returned error
    _coef_table(): - function returned error
    <istmt>: - function returned error
    an error occurred when mi estimate executed mimrgns_estimate on m=1


    This way also failed:

    . mimrgns i.ruca_3cat c.walk10rec i.ruca_3cat#c.walk10rec, pwcompare(effects)

    note: option predict() not specified; predict(xb) assumed
    only factor variables and their interactions are allowed
    an error occurred when mi estimate executed mimrgns_estimate on m=1


    Any suggestions? Thank you for your time, insight, and patience.

  • #2
    Jessica,

    phrasing is perfectly clear; to me anyway. You should use CODE delimiters when posting syntax or results (see the # symbol in the toolbar). It usually also helps to post example data using dataex (do not post confidential data) but I see how that can get tricky with imputed datasets. Also, mimrgns is community-contributed and probably from SSC, as you are asked to explain; you might want to briefly review the FAQ advice on community-contributed software.

    Anyway, starting from the end of your post, the last error message that you receive is not specific to mimrgns. You cannot use continuous variables in marginlist; see

    Code:
    help margins
    The second error message you show does not seem to be specific to mimrgns either. I am not sure what is going on, but this series of Mata errors is probably not supposed to be encountered by users. If you can create a reproducible example, I am sure Stata tech-support is happy to look into it.

    The first problem that you report is a bug in how mimrgns parses the pwcompare(effects) option. Note that pwcompare, pwcomparee(cieffects), and pwcompare(pveffects) all produce results. Actually, pwcompare(effects) also produces results but it fails to report them.

    I have fixed the bug and sent an updated version mimrgns to Kit Baum for upload on the SSC server. Kit usually uploads files quickly, within a couple of days. If you cannot wait for so long, you can obtain the most recent version of mimrgns now from

    Code:
    net from https://raw.githubusercontent.com/kleindaniel81/mimrgns/master

    As an aside and without going into details (because I currently lack the time), I close with a few remarks:

    You probably want to account for the survey features of your data during the imputation process, i.e., when you mi impute the data.
    You probably want to account for the interactions that you are testing during the imputation process, i.e., when you mi impute the data.
    You might want to use pmm instead of truncreg if your variables are not really truncated and you merely want to restrict the imputed values to the range of observed values.
    You might want to use margins' vce(unconditional) option with mimrgns.

    Comment


    • #3
      Thank you for your detailed help---this is much appreciated. I attempted dataex to create a reproducible example, but wasn't successful. I tried pmm before truncreg, but wasn't successful at that either---I'll read more and see if I can figure out why pmm wouldn't run.

      Thanks, Daniel.

      Comment

      Working...
      X