Announcement

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

  • Struggling in interpretation of continuous-by-continuous interaction terms

    Hello everybody,

    I hope my question is appropriate. I read other discussions on this matter here and the guide from prof. Williams on interaction of discrete-by-continuous variables but I am still struggling at making sense of my results.

    I am running a very simple pooled OLS regression from artificial data. I am regressing Y = the total fraction of infected individuals in the population at the end of the simulation (frac_infected) on X = the frequency of vaccine inoculation in the population (inoc_frequency) and Z = the removal speed of infected (measured in days from start of the simulation) from the population.

    As expected, the individual effect of X and Z on Y is negative and strongly significant. However, the joint effect is positive and significant. I truly struggle in understanding how is this possible. A draw of the

    I am running the following commands:


    Code:
    reg frac_infected rem_speed inoc_frequency c.rem_speed##c.inoc_frequency, robust
    
    margins, at(rem_speed=(0(0.5)10) r_inoc_frequency=(0(0.05)1)) vce(unconditional) saving(predictions, replace)
    
    marginsplot
    Code:
      
    Linear regression                               Number of obs     =        121
                                                    F(3, 117)         =      46.25
                                                    Prob > F          =     0.0000
                                                    R-squared         =     0.6617
                                                    Root MSE          =     .12903
    
    -----------------------------------------------------------------------------------------
                            |               Robust
    frac_infected | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    ------------------------+----------------------------------------------------------------
                    rem_speed |  -.0714626   .0073392    -9.74   0.000    -.0859976   -.0569276
                inoc_frequency |  -.7095715   .1104472    -6.42   0.000    -.9283063   -.4908367
                    rem_speed |          0  (omitted)
                inoc_frequency |          0  (omitted)
                            |
    c.rem_speed#c.inoc_frequency |   .0822156   .0137412     5.98   0.000     .0550018    .1094293
                            |
                      _cons |   .6270409   .0574339    10.92   0.000     .5132962    .7407857
    -----------------------------------------------------------------------------------------

    The margins returns the following figure: https://ibb.co/FzSxT56


    I fail to understand the positive interaction term also in light of the contour plot of the relationship between X, Y, Z:

    Code:
    twoway contour  frac_infected inoc_frequency  rem_speed
    The picture of the level curve plotting is enclose at the following link: https://ibb.co/kQG1Ww2


    Thank you for having read up to here
    Last edited by Paola Bertolini; 03 May 2024, 03:08.

  • #2
    If everyone is inoculated, then how much affect would removal have? Probably little.

    If no one is inoculated, then how big an effect would removal have? A big one.

    And same the other way.

    Excellence in either category makes the effect of the other less important, so the + term is taking you to zero.

    Comment


    • #3
      Just to add, the interpretation of main effects when they are in an interaction is conditional of the other variable being zero. So for this example, the -0.07114 for rem_speed is applicable when inoc_frequency = 0, and the -0.7095 for inoc_frequency is applicable when rem_speed = 0. If these zero values either do not exist in the data or are meaningless, then only interpret the main effects with caution. Instead, mean centering the data is often convenient as it yields interpretable main effects with interactions.

      Comment


      • #4
        Originally posted by George Ford View Post
        If everyone is inoculated, then how much affect would removal have? Probably little.
        If no one is inoculated, then how big an effect would removal have? A big one.
        And same the other way.
        Excellence in either category makes the effect of the other less important, so the + term is taking you to zero.
        Dear George, many thanks for the kind answer. It indeed makes perfect sense to me. As the population is of a given size, I standardized numbers from 0 (no infection) to 1 and run a simple fracreg:


        Code:
        fracreg logit efficiency_matrix_n_tot reg_rad r_inoc_freq c.reg_rad##c.r_inoc_freq if efficiency_matrix_n_tot < 1
        margins, at(reg_rad=(0(1)10) r_inoc_freq=(0(0.5)1)) vce(unconditional) saving(predictions, replace)
        marginsplot
        The result is as follows:


        Code:
        Fractional logistic regression                         Number of obs =     120
                                                               Wald chi2(3)  = 1050.34
                                                               Prob > chi2   =  0.0000
        Log pseudolikelihood = -30.338781                      Pseudo R2     =  0.3509
        
        -----------------------------------------------------------------------------------------
                                |               Robust
        efficiency_matrix_n_tot | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
        ------------------------+----------------------------------------------------------------
                        reg_rad |  -.8349899   .0436038   -19.15   0.000    -.9204518   -.7495279
                    r_inoc_freq |  -6.930451   1.103509    -6.28   0.000    -9.093289   -4.767612
                        reg_rad |          0  (omitted)
                    r_inoc_freq |          0  (omitted)
                                |
        c.reg_rad#c.r_inoc_freq |   .8329773   .1511586     5.51   0.000      .536712    1.129243
                                |
                          _cons |   2.389655    .263134     9.08   0.000     1.873922    2.905388
        -----------------------------------------------------------------------------------------

        Where the margin plot is available at this link: https://ibb.co/BL6R29N
        1. Following George Ford resolving comment and Prof. Williams pdf (located here: https://www3.nd.edu/~rwilliam/stats2/l53.pdf ) I interpret the result as follows: increasing the removal speed reduces the % of infected individuals, and this effect will be less pronounced as inoculation is introduced and increased. Higher levels of inoculation "eat out" the effect of removal, precisely because the population size is given. Please correct me if I am wrong.
        2. Relative to the kind interpretation of coefficients and wise advice from JJ Kovach , I confirm zeros are existent in this specific example so no recentering is needed (but I will keep this stored in my RAM for future endeavor).

        Please correct me if I am wrong, but coefficient interpretation in a fracreg environment is not straightforward. If this were an OLS regression (assuming coefficients don't change which is obviously wrong) I would claim that: "with no inoculation or removal, the expected fraction of infected is 2.38. Every additional increment of inoculation will reduce the infection fraction by ( -6.930451 + 0.832977 ).

        However, this is a nonlinear environment with a logit linker and to make a claim we would need to look at the average partial effects. Is that correct?

        With my greatest thanks and warmest regards
        Paola
        Last edited by Paola Bertolini; 06 May 2024, 22:24.

        Comment


        • #5
          You might find it productive to follow the links from -search ginteff-

          Comment


          • #6
            Originally posted by Stephen Jenkins View Post
            You might find it productive to follow the links from -search ginteff-
            Thanks Stephen for the advice, I was not aware of this command. It appears that I can not use it after a fracreg regression. The returned error is:
            Code:
            second- and third-order cross partial derivatives are allowed
             only with 'logistic', 'logit', and 'probit' models
            Which is strange as the link function of my fracreg is logit.

            Thank you,
            Paola

            Comment


            • #7
              Paola Bertolini : perhaps you could write to -ginteff-'s author?

              Comment


              • #8

                To get rid of the omitted variables (you've included them twice with the ##): fracreg logit efficiency_matrix_n_tot reg_rad r_inoc_freq c.reg_rad#c.r_inoc_freq if efficiency_matrix_n_tot < 1 or fracreg logit efficiency_matrix_n_tot c.reg_rad##c.r_inoc_freq if efficiency_matrix_n_tot < 1 The constant term is not the x = 0 outcome. Use the margins you requested to find the 0,0 prediction. Probably the first margin in the table.

                Comment


                • #9
                  Originally posted by Stephen Jenkins View Post
                  Paola Bertolini : perhaps you could write to -ginteff-'s author?
                  Thanks I will, and report back the outcome.

                  Originally posted by George Ford
                  To get rid of the omitted variables (you've included them twice with the ##): fracreg logit efficiency_matrix_n_tot reg_rad r_inoc_freq c.reg_rad#c.r_inoc_freq if efficiency_matrix_n_tot < 1 or fracreg logit efficiency_matrix_n_tot c.reg_rad##c.r_inoc_freq if efficiency_matrix_n_tot < 1 The constant term is not the x = 0 outcome. Use the margins you requested to find the 0,0 prediction. Probably the first margin in the table.
                  Thanks george. I found a very well-made presentation by Marcelo Perraillon about the computation of marginal effects in the context of logit models, with several examples. I was under the (wrong) impression that in a logit model the intercept gives the odds ratio of x=0 from which it is relatively straightforward to reconstruct the probability from 1/(1-p).

                  I am reading this excellent guide on marginal effects for non-linear model: https://clas.ucdenver.edu/marcelo-pe...effects-lisbon

                  Comment


                  • #10
                    it could be a log-odds ratio, but it's not the mean.

                    Comment


                    • #11
                      Thank you george

                      Comment


                      • #12
                        Dear all,

                        The author of -ginteff- command, Marius Radean, came back to my request with a generous answer he would be willing to share on the board (he is aware of the discussion)


                        'ginteff' with the default settings works with 'fracreg logit', as long as you compute the effect of your interacted variables using the first difference approach (eg, increase x1 and x2 by 1-unit) – ginteff, firstdiff(x1 x2). When you say that 'ginteff' does not connect with the 'fracreg logit' framework, I assume you mean that you cannot compute the interaction effect using the cross-partial derivative. Indeed, typing 'ginteff, dydxs(x1 x2)' issues an error message saying that cross-partial derivatives may be employed only with a logit or probit model. This is despite the fact that the link function is still logistic with the 'fracreg logit' command. The reason for this is that ginteff checks what estimation command was employed by looking at the e(cmd) macro. If you type "display e(cmd)" after 'fracreg logit', you will see that the estimation command listed is "fracreg" (not logit). This is why ginteff stops and issues that error message.

                        To circumvent that restriction, you need to manually change the value of the macro containing the estimation command (before running ginteff). To do that you need an 'eclass' program, which I exemplify below. Once the e(cmd) macro says "logit", ginteff will compute the interaction effect as the cross-partial derivative. Importantly, this workaround is appropriate only because both 'logit' and 'fracreg logit' employ the logistic link function. But it should not be used in any other contexts. Needless to say, I do not recommend people routinely changing the Stata estimation results, as this may lead to unintended consequences. For this reason, I suggest that you immediately reestimate the original fracreg model after running ginteff, to reset the estimation results.

                        The program is called 'mycmd' and changes the saved estimation command to "logit"

                        Code:
                        cap program drop mycmd
                        program mycmd, eclass
                              version 14
                              ereturn local cmd "logit"
                        end

                        This is a sidenote. For the reasons mentioned in the article, I prefer using the first difference approach to calculate the effect of a given change in the interacted variables. The main reason for this is that it makes the interpretation of the interaction effect more straightforward. After a logistic regression, the cross-partial derivative estimate does not necessarily correspond to the effect on y associated with a 1-unit increase in x1 and x2. That said, I know that the practice varies across disciplines. Lastly, the added benefit of using the first difference approach is that you do not need the additional 'mycmd' program.


                        PS

                        Here is an example that illustrates the points discussed above. I hope this helps.


                        Code:
                        . 
                        
                        . webuse 401k, clear
                        
                        . fracreg logit prate mrate c.ltotemp##c.age i.sole
                         
                        Iteration 0:   log pseudolikelihood = -1984.5201  
                        Iteration 1:   log pseudolikelihood =  -1688.691  
                        Iteration 2:   log pseudolikelihood = -1680.9105  
                        Iteration 3:   log pseudolikelihood = -1680.8401  
                        Iteration 4:   log pseudolikelihood = -1680.8401  
                        
                        
                        
                        Fractional logistic regression                  Number of obs     =      4,075
                                                                        Wald chi2(5)      =     704.30
                                                                        Prob > chi2       =     0.0000
                        Log pseudolikelihood = -1680.8401               Pseudo R2         =     0.0597
                        
                        ---------------------------------------------------------------------------------
                        
                                        |               Robust
                        
                                  prate |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                        
                        ----------------+----------------------------------------------------------------
                        
                                  mrate |   1.159178    .074813    15.49   0.000     1.012547    1.305809
                                ltotemp |   -.221204   .0187297   -11.81   0.000    -.2579135   -.1844945
                                    age |    .019377   .0103493     1.87   0.061    -.0009074    .0396613
                                        |
                        c.ltotemp#c.age |   .0019553   .0013235     1.48   0.140    -.0006387    .0045493
                                        |
                                   sole |
                             only plan  |   .1669855   .0506303     3.30   0.001      .067752    .2662191
                                  _cons |   2.495054   .1387581    17.98   0.000     2.223093    2.767015
                        -------------------------------------------------------------------------------
                        
                        
                        
                        . 
                        
                        . ginteff, firstdiff(ltotemp age) 
                        
                        
                        
                        Interaction Effects
                        
                            Statistic        :          Average interaction effect                           
                        
                            Standard error   :          Delta-method                                         
                        
                            ∆(x1)            :          (y|x1+n1)-(y|x1); x1 : ltotemp (asobserved), n1 = 1  
                        
                            ∆(x2)            :          (y|x2+n2)-(y|x2); x2 : age (asobserved), n2 = 1      
                        
                            Number of obs    =          4,075                                                
                        
                        
                        
                            Expression       :          Conditional mean of prate, predict()  
                        
                        
                        
                        ----------------------------------------------------------------------------
                        
                                       |     Statistic      Std. Err.     [95% Conf.      Interval]
                        
                        ----------------+-----------------------------------------------------------
                        
                        ∆(x1)#∆(x2)     |     .00081376      .00019077      .00043986      .00118766
                        
                        ----------------------------------------------------------------------------
                        
                        
                        
                        . capture noisily ginteff, dydxs(ltotemp age)
                        
                        second- and third-order cross partial derivatives are allowed
                        
                         only with 'logistic', 'logit', and 'probit' models
                        
                        
                        
                        . display e(cmd)
                        
                        fracreg
                        
                        
                        
                        . 
                        
                        . cap program drop mycmd
                        
                        
                        
                        . program mycmd, eclass
                        
                          1.         version 14
                        
                          2.         ereturn local cmd "logit"
                        
                          3. end
                        
                        
                        
                        . 
                        
                        . mycmd
                        
                        
                        
                        . display e(cmd)
                        
                        logit
                        
                        
                        
                        . ginteff, dydxs(ltotemp age)
                        
                        
                        
                        Interaction Effects
                        
                            Statistic        :          Average interaction effect                  
                        
                            Standard error   :          Delta-method                                
                        
                            ∆(x1)            :          dy/dx w.r.t. x1; x1 : age (asobserved)      
                        
                            ∆(x2)            :          dy/dx w.r.t. x2; x2 : ltotemp (asobserved)  
                        
                            Number of obs    =          4,075                                       
                        
                        
                        
                            Expression       :          Conditional mean of prate, predict()  
                        
                        
                        
                        ----------------------------------------------------------------------------
                        
                                       |     Statistic      Std. Err.     [95% Conf.      Interval]
                        
                        ----------------+-----------------------------------------------------------
                        
                        ∆(x1)#∆(x2)     |     .00078359      .00017443      .00044172      .00112546
                        
                        ----------------------------------------------------------------------------

                        Comment

                        Working...
                        X