Announcement

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

  • Problem about the use of the command "margins" concerning interactive terms

    Hello everyone,
    I am looking at a problem about how the birth policy can affect female job opportunities, where the opportunity=0/1, therefore I am using a logit model, which looks like this:
    logit opportunity i.gender##i.policy (*)
    *represents a series of control variables which exist in this model but is not important in this question.
    The problem is, if I want t o know the marginal effect of this issue, I have seen two ways of achieving this:
    margins i.gender##i.policy, atmeans
    or
    margins, dydx (i.gender##i.policy)
    I am not sure what is the difference between these two commands, and the second one seems not able to work since the system does not accept interactive terms in the () after dydx which I don't know why.

    And another problem is that the marginal results can't seem to be exported by the estout command (or esttab), only the logit results can be exported, which is quite strange.

    Hope these can be solved. Thank you very much!

  • #2
    I am not sure what is the difference between these two commands, and the second one seems not able to work since the system does not accept interactive terms in the () after dydx which I don't know why.
    The reason that the -dydx()- option will not accept an interaction term is because there is no such thing as the marginal effect of an interaction. Let me assume that both of the variables here are dichotomous and coded 0/1. What would the marginal effect of gender#policy mean. By definition of marginal effect, it would be the expected difference in outcome associated with a unit difference in the value of gender#policy. But a unit difference in gender#policy can come about in three different ways: from gender = 0, policy = 0 to gender = 1, policy = 1; from gender = 1, policy = 0 to gender = 1, policy = 1; and from gender = 0, policy = 1 to gender = 1, policy = 1. But these three routes produce completely different effects on the outcome (except in the uninteresting circumstance where they produce no effect at all). So there is no way to define which of these is "the marginal effect."

    If you are interested in the treatment effect, you don't look at the -margins- output in the first place: you get that as the coefficient of 1.gender#1.policy in the regression output itself. If you want marginal effects of policy, there are two different ones: there is the marginal effect of policy affecting males and a different marginal effect of policy affecting females. You can get both of those with -margins gender, dydx(policy)-.

    If you are interested in the difference between genders in the presence and absence of the policy, that would be -margins policy, dydx(gender)-.

    Regarding the use of -estout- with -margins-, although I do not myself use -estout-, it is my understanding that it pulls its results from -e()-. But -margins- only leaves results in -e()- if you add the -post- option to your -margins- command. (Make sure you are done using the results of the regression before you do that, or -estimates store- them if you are not done with them, since -margins, post- will overwrite the regression results.)

    Comment


    • #3
      You might also take a look at Richard Williams's notes on the margins command.
      Last edited by Devra Golbe; 23 Feb 2024, 14:26.
      Devra Golbe
      Professor Emerita, Dept. of Economics
      Hunter College, CUNY

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        The reason that the -dydx()- option will not accept an interaction term is because there is no such thing as the marginal effect of an interaction. Let me assume that both of the variables here are dichotomous and coded 0/1. What would the marginal effect of gender#policy mean. By definition of marginal effect, it would be the expected difference in outcome associated with a unit difference in the value of gender#policy. But a unit difference in gender#policy can come about in three different ways: from gender = 0, policy = 0 to gender = 1, policy = 1; from gender = 1, policy = 0 to gender = 1, policy = 1; and from gender = 0, policy = 1 to gender = 1, policy = 1. But these three routes produce completely different effects on the outcome (except in the uninteresting circumstance where they produce no effect at all). So there is no way to define which of these is "the marginal effect."

        If you are interested in the treatment effect, you don't look at the -margins- output in the first place: you get that as the coefficient of 1.gender#1.policy in the regression output itself. If you want marginal effects of policy, there are two different ones: there is the marginal effect of policy affecting males and a different marginal effect of policy affecting females. You can get both of those with -margins gender, dydx(policy)-.

        If you are interested in the difference between genders in the presence and absence of the policy, that would be -margins policy, dydx(gender)-.

        Regarding the use of -estout- with -margins-, although I do not myself use -estout-, it is my understanding that it pulls its results from -e()-. But -margins- only leaves results in -e()- if you add the -post- option to your -margins- command. (Make sure you are done using the results of the regression before you do that, or -estimates store- them if you are not done with them, since -margins, post- will overwrite the regression results.)
        Thank you so much for the reply! That is very helpful! I have yet another question, which is what doest the command -margins i.policy##i.gender- or -margins i.policy#i.gender- do? The system seems to be able to run these. I thought these are marginal effects, too.
        Thank you!

        Comment


        • #5
          Originally posted by Clyde Schechter View Post
          The reason that the -dydx()- option will not accept an interaction term is because there is no such thing as the marginal effect of an interaction. Let me assume that both of the variables here are dichotomous and coded 0/1. What would the marginal effect of gender#policy mean. By definition of marginal effect, it would be the expected difference in outcome associated with a unit difference in the value of gender#policy. But a unit difference in gender#policy can come about in three different ways: from gender = 0, policy = 0 to gender = 1, policy = 1; from gender = 1, policy = 0 to gender = 1, policy = 1; and from gender = 0, policy = 1 to gender = 1, policy = 1. But these three routes produce completely different effects on the outcome (except in the uninteresting circumstance where they produce no effect at all). So there is no way to define which of these is "the marginal effect."

          If you are interested in the treatment effect, you don't look at the -margins- output in the first place: you get that as the coefficient of 1.gender#1.policy in the regression output itself. If you want marginal effects of policy, there are two different ones: there is the marginal effect of policy affecting males and a different marginal effect of policy affecting females. You can get both of those with -margins gender, dydx(policy)-.

          If you are interested in the difference between genders in the presence and absence of the policy, that would be -margins policy, dydx(gender)-.

          Regarding the use of -estout- with -margins-, although I do not myself use -estout-, it is my understanding that it pulls its results from -e()-. But -margins- only leaves results in -e()- if you add the -post- option to your -margins- command. (Make sure you are done using the results of the regression before you do that, or -estimates store- them if you are not done with them, since -margins, post- will overwrite the regression results.)
          Thank you so much for the reply! That is very helpful! I have yet another question, which is what doest the command -margins i.policy##i.gender- or -margins i.policy#i.gender- do? The system seems to be able to run these. I thought these are marginal effects, too.
          About estout problem, I have been looking a other websites, and there is this solution of using the estpost command which also works.
          Thank you!

          Comment


          • #6
            Originally posted by Devra Golbe View Post
            Thank you for the recommendation, I will take a look

            Comment


            • #7
              Re #5. Commands like -margins policy#gender- do not calculate marginal effects; they calculate predictive margins. That's just a fancy way to say that -margins policy#gender- will give you the expected value (according to your regression model) of the probability of opportunity in each of the four combinations of policy and gender.

              When you write -margins policy##gender-, you get the same as -margins policy#gender-, and, on top of that, you also get the expected probability of opportunity in each level of policy, adjusted for the distribution of gender, and the expected probability of opportunity in each gender adjusted for the distribution of policy.

              Comment


              • #8
                Originally posted by Clyde Schechter View Post
                Re #5. Commands like -margins policy#gender- do not calculate marginal effects; they calculate predictive margins. That's just a fancy way to say that -margins policy#gender- will give you the expected value (according to your regression model) of the probability of opportunity in each of the four combinations of policy and gender.

                When you write -margins policy##gender-, you get the same as -margins policy#gender-, and, on top of that, you also get the expected probability of opportunity in each level of policy, adjusted for the distribution of gender, and the expected probability of opportunity in each gender adjusted for the distribution of policy.
                Thank you very much! This is really helpful

                Comment

                Working...
                X