Announcement

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

  • margins: chart and dydx versus at()

    Imagine you have three indicator variables for height: short, medium, and tall; an indicator variable for whether the person has ever donated; and a continuous variable for their income. The goal is to regress the likelihood that a person has given to charity based on their height and income: "logit donation i.short i.medium c.income".

    First, how can you get the predictive margins to show the probability each height designation gives to charity controlling for income in a chart? (i.e., a chart that has the x-axis as short medium tall and the y-axis with probability).

    Second, what is the difference between "margins, dydx(race1 race2) atmeans" and "at(race1=(0 1) race2=(0 1) atmeans"?

  • #2
    Well, for your first question, you should create a new variable for height that takes on 1 for short, 2 for medium and 3 for tall. Then -logit donation i.height c.income- And -margins height- will then give you the probability of donation for each height, adjusted to the observed distribution of income. To graph it, -marginsplot- immediately after the -margins- command.

    For the second question, the first command you show will give you two results, the average marginal effects of race1 and race2 with all other model variables constrained to their sample means. The second will give you four results, the marginal of race1 and race2 under four different conditions: once with race1 and race2 both 0, once with race 1 = 1 and race2 = 0, once with race1 = 0 and race2 = 1, and once with both race1 and race2 = 1--and in each of those four conditions, all other model variables will be constrained to their sample means.

    Comment


    • #3
      Thanks .

      On first point, this works. Is there an easy way to make the x-axis label not be 1 2 3 and instead Short Medium Tall?

      On the second point, it is still unclear. Let's assume for simplicity that the variable was just median == 1 if person was median height or above. How would dydx(median) versus at(median=(0 1)). Maybe I am being dense, but I assumed that this would yield identical results but it is not.

      Comment


      • #4
        On first point, this works. Is there an easy way to make the x-axis label not be 1 2 3 and instead Short Medium Tall?
        I think if you attach a value label to the height variable before running the regression, the x-axis in the -marginsplot- graph will come out labeled accordingly.

        On the second point, it is still unclear. Let's assume for simplicity that the variable was just median == 1 if person was median height or above. How would dydx(median) versus at(median=(0 1)). Maybe I am being dense, but I assumed that this would yield identical results but it is not.
        Well if the variable is literally just 1 for median height or above, and takes on no other values, it will be omitted from the regression in any case and you will get nothing but error messages if you ask -margins- to work with it. Let me assume you meant 1 for median height or above and 0 for below median height.

        So if your variable is dichotomous, and if properly prefixed with i. in the regression command, then oly -margins, dydx(median)- gives the expected difference in outcome between those at or above median height and those below.

        I'm not sure exactly what Stata would do with -margins, dydx(median) at(median = (0 1))-, but whatever it is, it is meaningless because the "at 1" part would be some attempt to estimate the marginal effect of a change in the value of median from 1 to 2, which is just nonsense. Ideally, Stata should give some sort of error message in this situation, though I don't know if it actually does.

        I cannot over-emphasize that the calculation and interpretation of marginal effects depends critically on whether the variable is entered into the regression as a continuous or categorical variable. So your questions are not really well-posed without also showing the regression command you have in mind before the margins command.

        Comment

        Working...
        X