I'm trying to graph predicted values based on a model estimated on a multiply imputated dataset. I'm using the excellent -mimrgns- command to calculate predictive margins. Take the following example:

Now this actually works fine, except that marginsplot does not display the correct confdence intervals, as explained in the manual:
So I am trying to use coefplot. I would like to obtain a similar graph as the one made by marginsplot, but I'm having troubles in specifying this. For the two discrete factor variables, rep needs to go on the x asix and foreign needs to be grouped visually using a line in the foreign and the non-foreign cars. I tried several options, but unsuccesful. A main difficulty is that for such subplot-like data usually separate estimation results are stored in the examples in coefplot's manual. This is as far as I got:
I would be grateful to any coefplot expert who knows the solution.
Code:
sysuse auto, clear quietly replace mpg = . in 3 mi set wide mi register imputed mpg mi impute poisson mpg weight price foreign, add(2) mi estimate: reg mpg rep#foreign mimrgns rep#foreign, cmdmargins post marginsplot
Now this actually works fine, except that marginsplot does not display the correct confdence intervals, as explained in the manual:
Note that while in principle marginsplot works after mimrgns, the plotted confidence intervals are based on inappropiate degrees of freedom (more). The appropriate degrees of freedom are saved in r(df) (or r(df_vs) if option pwcompare is specified) by mimrgns. With the post option the degrees of freedom are also saved in e(df_mi) (or e(df_vs)). Although the differences will typically be too small to notice in a graph, you may want to use an alternative to marginsplot that allows specifying the degrees of freedom used to calculate confidence intervals (e.g. Jann's (2013) coefplot).
Code:
coefplot , recast(line) vertical xtitle(Repair Record 1978) xlabel(#5) baselevels
Comment