Announcement

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

  • -mimrgns- updated on SSC

    Thanks as always to Kit Baum, an updated version of mimrgns is now available from the SSC.

    mimrgns runs margins after mi estimate.

    In Stata use the ssc or adoupdate command to install the latest version.


    Though weeks turned into months, as announced here, the update finally adds support for margins' pwcompare option*. Also the remarks section in the help file has been extended.

    I hope some will find the command useful.

    Best
    Daniel

    * Contrary to my earlier statement the pwcompare option was already introduced in Stata 12, but not documented in margins' help file.
    Last edited by daniel klein; 11 Oct 2014, 03:42.

  • #2
    Thanks Daniel. This seems like a very helpful program. I am somewhat surprised that something like it isn't part of official Stata. Are there reasons for being concerned about its use, or situations where the results might be incorrect?
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    Stata Version: 17.0 MP (2 processor)

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

    Comment


    • #3
      Richard, the marginsplot after ''mimargns'' produces wrong CI. Could that be an explanation?
      Roman

      Comment


      • #4
        Richard,

        let me start by giving credit, where it is due.

        The basic concept that mimrgns impements is suggested by the the UCLA Statistical Consulting Group. The key idea here is to treat margins as an estimation command. Rather than applying margins to the final mi estimates once only, margins is run together with the respective estimation command on each imputed dateset. Its results are then combined using Rubin's rules.

        I discuss some potential caveats in the help file.

        First, the general discussion of "Using the command-specific postestimation tools" in [MI] mi estimate postestimation applies. Among the post estimation commands that you may not use after mi estimate, the manual lists the predict command (this is why there is an mi predict). Since margins relies on predict internally, so does mimrgns. Whether this is a problem, I cannot tell for sure. As stated above mimrgns runs margins on each imputed dataset, so it does not apply (or rely on) predict based on the final mi estimates. On the other hand, it might be argued that marginal effects for multiply imputed datasets should be obtained based on the final estimates. This could be achieved by running mi predict, combining predicted values across the imputed datasets on the observational level (see White, Royston and Wood 2011). The latter approach would probably need some major changes to the code of margins, maybe an mi margins similar to mi predict.

        Second, if we stay with the approach implemented in mimrgns, we need to think about combining margins' results. It is well known that Rubin's rules assume (asymptotic) normality for the parameters. Whether marginal effects are normality distributed, I cannot tell. I guess if they are based on predictions other than xb, this might well be questionable. This is why mimrgns defaults to linear predictions regardless of the default prediction for the estimation command.

        The last point discussed in the help file is more a technical than statistical issue and concerns the use of marginsplot. The way marginsplot is implemented, there is no way (better yet: I could not find a way) to pass the appropriate degrees of freedom to the command. Therefore it will plot CIs that are based on the wrong/inapproproate df. I can go into detail should anyone really be interested in this.

        In summary, I cannot tell you that mimrgns implements the widely accepted standard of obtaining marginal effects in multiply imputed datasets, as I do not believe there is such standrad yet. My guess is that this is the main reason Stata Corp. did not (yet) implement it. However, the authoroities to speak on this topic are probably Jeff Pitblado, Isabel Cañette and Yulia Marchenko.

        I hope others will join the discussion.

        Best
        Daniel



        White, I. R., Royston, P., Wood, M. A. 2011. Multiple imputation using chained equations: Issues and guidance for practice. Statistics in Medicine 30:377-399
        Last edited by daniel klein; 11 Oct 2014, 09:26. Reason: formating issues

        Comment


        • #5
          Thanks Daniel. For the moment, it sounds like your program is as good as it gets, but anyone using it in published work should toss in a few caveats. There are so many things you might like to use together -- svy, mi, xt -- maybe by Stata 20 that will all be worked out.
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          Stata Version: 17.0 MP (2 processor)

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

          Comment


          • #6
            Thanks once again to Kit Baum, a minor update to mimrgns is now available from the SSC.

            The update adds support for contrast operators and now reports the at legend if at() options are specified. The help file has also been extended.

            In Stata use the ssc or adoupdate command to install the update.

            Best
            Daniel
            Last edited by daniel klein; 18 Jan 2015, 11:18.

            Comment


            • #7
              Hello,

              I am having difficulty with this mimrgns command. It might be because I am running multiple imputed Slogit models. Here is a sample of my regress code. Maybe you could explain what I am doing wrong?

              mi estimate, esampvaryok post cmdok: slogit v1 v2 v3 v4 if v5==0

              thank you

              -Sean

              Comment


              • #8
                Hi everybody
                I'm having trouble setting my data with the command xtset in panel.

                Comment


                • #9
                  Originally posted by pgr451 View Post
                  Hello,

                  I am having difficulty with this mimrgns command. It might be because I am running multiple imputed Slogit models. Here is a sample of my regress code. Maybe you could explain what I am doing wrong?

                  mi estimate, esampvaryok post cmdok: slogit v1 v2 v3 v4 if v5==0

                  thank you

                  -Sean

                  It is hard to say without seeing your commands and output. You haven't even said exactly what the problem is. Are you getting an error or do you think the results are wrong? Use code tags (see pt. 12 of the FAQ) and show us the code and output, including the mimrgns command.
                  -------------------------------------------
                  Richard Williams, Notre Dame Dept of Sociology
                  Stata Version: 17.0 MP (2 processor)

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

                  Comment


                  • #10
                    Originally posted by muhammad kashif View Post
                    Hi everybody
                    I'm having trouble setting my data with the command xtset in panel.
                    Welcome to Statalist. You want to put this in a new thread, rather than tagging it on to a thread that deals witrh a different topic. We also need to see your code and output. As it is we have no way of knowing what your problem is. Try reading the help first and then repost if still not clear.
                    -------------------------------------------
                    Richard Williams, Notre Dame Dept of Sociology
                    Stata Version: 17.0 MP (2 processor)

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

                    Comment


                    • #11
                      Thanks for the reply Richard Williams

                      Here is the code

                      mi estimate, esampvaryok post cmdok: slogit relat ptsd comex i.sah age sex i.mar2 i.cohab3 i.cursep child i.racenew2 edu rank i.serv2 i.deploy i.tbi relsal prayst if racenew2 == 0

                      mimrgns, over(ptsd) atmeans predict(pr)


                      I keep getting the following error

                      prediction is a function of possibly stochastic quantities other than e(b)
                      an error occurred when mi estimate executed mimrgns_estimate on m=1

                      Comment


                      • #12
                        Sean,

                        please re-register with your full name and review the FAQ on asking for private replies. You may naturally contact me personally, however, I prefer you use the mail address given in the help file for mimrgns, not posting to the list and writing a private message simultaneously.

                        The problem you report occurs when margins cannot estimate what it is supposed to in the first imputed dataset. It is, in so far, not specific to mimrgns. I suggest you manually* run your model on this dataset and determine what is going (wr)on(g).

                        Also, you seem to have a lot of options specified with your mi estimate call, that should not be specified casually, and this might have to do with the problem. Finally, note that it seems suspicious to have i.racenew2 in your model as a predictor, but yet restrict the estimation to the subsample for which racenew2 == 0.

                        Sorry, I cannot say much more.

                        Best
                        Daniel

                        [edit]
                        * You might want to try something along the lines

                        Code:
                        mi xeq : slogit ... ; margins , over(ptsd) atmeans
                        [/edit]
                        Last edited by daniel klein; 13 Oct 2015, 04:30.

                        Comment


                        • #13
                          It's not part of the FAQ but http://www.statalist.org/forums/foru...ivate-messages gives advice on private messages. Private messages can work well as chat with people you feel you know already, but usually not otherwise.

                          I support here the request to use full real names, as has been our policy since the start. This request was made already to "pgr451" in

                          http://www.statalist.org/forums/foru...estimate-logit

                          and

                          http://www.statalist.org/forums/foru...e-interactions

                          Comment


                          • #14
                            Hello, I am having trouble with MIMRGNS. I'm running it and I keep getting predicted probabilities over 1. It doesn't happen when I run margins on the unimputed file.

                            Here is the commands I am using and the output.

                            mi estimate, post cmdok: probit milch comhigh sexmil tbi ptsd i.racenew2 age sex i.mar2 i.cohab3 i.cursep child edu rank i.serv2 i.deploy relat relsal prayst

                            mimrgns racenew2, at (ptsd=1)

                            Multiple-imputation estimates Imputations = 25
                            Predictive margins Number of obs = 39,877
                            Average RVI = 0.1265
                            Largest FMI = 0.0780
                            DF adjustment: Large sample DF: min = 3,995.42
                            avg = 8,346.93
                            Within VCE type: Delta-method max = 19,116.44

                            Expression : Linear prediction, predict(xb)
                            at : ptsd = 1

                            ------------------------------------------------------------------------------
                            | Margin Std. Err. t P>|t| [95% Conf. Interval]
                            -------------+----------------------------------------------------------------
                            racenew2 |
                            white | -1.139877 .0436035 -26.14 0.000 -1.225344 -1.054411
                            black | -1.293689 .0546365 -23.68 0.000 -1.400802 -1.186575
                            latino | -1.212131 .0520638 -23.28 0.000 -1.314205 -1.110057
                            other | -1.143599 .0529186 -21.61 0.000 -1.24734 -1.039859
                            ------------------------------------------------------------------------------

                            Comment


                            • #15
                              Answered here.

                              Comment

                              Working...
                              X