Announcement

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

  • Graphing interaction effect on multiple imputed negative binomial models

    Hi. I have problems graphing the interaction effect I get after the following "main" commands.

    gen selfeff_interact = selfeff * eer_done
    gen att_sum_interact = att_sum * eer_done

    mi set wide
    mi register impute posloansqrt incomesqrt loansqrt
    mi register regular perswinc persincome age edu EIER sizelog dinFylke sex work boligstatus REH_done_tot_score eer_done eer_do eer_plan
    mi impute chained (regress) posloansqrt incomesqrt loansqrt = perswinc persincome age i.edu i.EIER sizelog i.dinFylke i.sex i.work i.boligstatus REH_done_tot_score eer_done eer_do eer_plan [pweight = Vekt], force add(50) rseed(1775)

    mi estimate: nbreg eer_do eer_done i.sex age incomesqrt loansqrt posloansqrt sizelog houseagelog att_sum selfeff att_sum_interact selfeff_interact [pweight = Vekt]


    This gives the following nbreg result:
    Multiple-imputation estimates Imputations = 50
    Negative binomial regression Number of obs = 3,683
    Average RVI = 0.1196
    Largest FMI = 0.3972
    DF adjustment: Large sample DF: min = 316.66
    avg = 323,980.99
    max = 3021015.22
    Model F test: Equal FMI F( 12,41724.8) = 16.13
    Within VCE type: Robust Prob > F = 0.0000
    eer_do Coef. t/p/CI
    eer_done .3.069688 4.31 0.000 1.673205 4.466171
    sex
    Woman - -.0581222 -0.25 0.800 -.5077421 .3914978
    age - -.0281726 -3.22 0.001 -.0453214 -.0110238
    incomesqrt .-.0011577 -1.89 0.059 -.0023617 .0000462
    loansqrt -.0000611 -0.19 0.849 -.000692 .0005697
    posloansqrt .0012359 3.60 0.000 .0005609 .0019108
    sizelog .338653 1.41 0.159 -.132942 .810248
    houseagelog .1178251 0.57 0.566 -.2843169 .5199671
    att_sum .2010771 6.56 0.000 .1409689 .2611852
    selfeff .1324729 3.71 0.000 .062564 .2023817
    att_sum_interact -.0811456 -3.34 0.001 -.1288207 -.0334705
    selfeff_interact -.0204442 -0.61 0.539 -.085654 .0447656
    _cons -10.11229 -6.68 0.000 -13.0773 -7.147279
    /lnalpha .9221427 .361236 .2140639 1.630222
    alpha 2.514673 .9083903 1.238702 5.105005
    It is worth mentioning that both eer_do and eer_done is count data from 0-4 with large amounts of 0's, and very few 4's. I tried graphing the significant interaction effect between att_sum and eer_done (in bold) using the mimrgns command, but I can't seem to follow through with a marginsplot. If anyone has a solution for this, I would be extremely grateful.


    I tried graphing the interaction effect myself in a spreadsheet, but have to admit that this is somewhat over my head in statistics, which means I am in no way sure about my results.

    Following this post (https://stats.idre.ucla.edu/stata/da...al-regression/), I tried converting the coef. to IRR using "=exp(coef)", and then creating a graph with different values of eer_done and att_sum, with the equation:
    Y IRR = exp(cons + (eer_done * 3.069688) + (att_sum * 0.2010771) + (eer_done * att_sum * -0.0811456))

    But as the eer_done variable includes zero, I'm not sure the calculations are correct. Admittedly, you could even say I am more certain they are wrong than I am certain they are correct. The calculations, with an accompanying graph, can be found here in sheet 5 (https://docs.google.com/spreadsheets...it?usp=sharing).


    If anyone has solutions for visualizing the significant interaction effect, preferably in IRR, I would be very grateful.

    Lars Egner

  • #2
    I do not have a full solution but some remarks.

    1. Why do you create the interaction terms manually? Since you register neither those interactions terms nor their components as imputed, you could probably simply use factor variables notations in the estimation, which would make using mimrgns (SSC, I suppose) at least an option.

    2. Why do you specify the force option? There are few, if any, situations where you want this. Never ever casually specify force just to prevent error messages that you do not fully understand; specify force when you fully understand the error message and are sure that you really want to ignore them.

    You show code and output, which is good. However, please review the FAQ on how to do this properly, which is using code-delimteres (that hash-button in menu bar). Also, you say that

    I tried graphing the significant interaction effect between att_sum and eer_done (in bold) using the mimrgns command, but I can't seem to follow through with a marginsplot.
    but do not show the mimrgns call, the call to marginsplot, or what Stata did in response. As mentioned above, mimrgns would only work properly with factor variable notation begin used before.

    Comment


    • #3
      Thank you very much for your reply Daniel. Sorry about the formatting and missing information. To address each concern:

      1) It would indeed be better to just use the # notation. If I can't produce a graphical presentation of the interaction, creating a table based on mimrgns should be a reasonably solid secondary option, but as shown below, I realized graphing can be done.

      2) I specify the force option because very few of the variables used to impute the data have no missing data at all. Unfortunately, I have very few income-related variables that have completely full datasets. As far as I understand, you can only impute based on full data, so I was forced to either impute based on very few, and often only loosely related variables (such as county) resulting in very inaccurate imputations, or impute most of the data based on more variables. Using the misstable pattern I narrowed it down to how to lose the least amount of respondents while maintaining a reasonable amount of variables for the imputation.

      In short, it seems I was not able to use the marginsplot because I did not read the help-file well enough. The following code provides a perfectly reasonable plot:

      Code:
      mi estimate, dots: nbreg eer_do eer_done i.sex age incomesqrt loansqrt posloansqrt sizelog houseagelog att_sum selfeff c.att_sum#c.eer_done c.selfeff#c.eer_done [pweight = Vekt]
      
      //Investigating interaction effect
      mimrgns, at(att_sum=(5(1)25) eer_done=(0(1)3)) atmeans cmdmargins
      marginsplot, xdimension(att_sum)
      Thank you for your answers, and thank you for creating the mimrgns command, it is very useful. As a final question, is it possible to converter the coefficients to incidence rate ratios (IRR) at some point before plotting? The transformation is exp(coef), and could be said to be much easier to interpret than the coefficient of negative binomial regressions.

      Click image for larger version

Name:	Graph.png
Views:	1
Size:	69.5 KB
ID:	1556648

      Comment


      • #4
        Originally posted by Lars Egner View Post
        2) I specify the force option because [... a]s far as I understand, you can only impute based on full data
        That is partly true. I would, however, just register all variables with missing values as imputed and impute missing values for all variables, regardless of which of them are later used in the analysis. Note that all variables with missing values go before, i.e., to the left-hand side of the equals sign in mi impute.

        Originally posted by Lars Egner View Post
        In short, it seems I was not able to use the marginsplot because I did not read the help-file well enough.
        There is more in the help-file. mimrgns uses linear predictions, which might or might not be what you want. You can change that by specifying the predict() option.


        Originally posted by Lars Egner View Post
        As a final question, is it possible to converter the coefficients to incidence rate ratios (IRR) at some point before plotting?
        I do not fully follow this. You are not plotting coefficients here. You are plotting predicted values. You can use the predict() or expression() option to modify what is being predicted.

        Comment


        • #5
          Yes sorry, I missed the fact that I was plotting coefficients. Specifying predict() solved my problems. Thank you again for you help

          Comment

          Working...
          X