# Difference between margeff and margins, dydx(*)?

#### Klem

##### New Member
Hello,

I am trying to compute the marginal effects of an xtlogit model. I tried several methods.

First of all, in order to compute the marginal effects at the mean, I used
- mfx compute
- margins, dydx(*) at mean
which both give me -0.33

Secondly, in order to compute the average marginal effects, I used
- margeff : which gives me a -0.05
- margins, dydx(*) : which gives me -0.33
I am confused because I thought that the two commands should give me similar results. What do you think explains this difference?

In addition, I am using this to estimate the marginal effects of a difference-in-difference coefficient. Is it correct to interpret the average marginal effect as: "the probability of outcome variable=1 is on average 5% (or 33%?) lower for individuals in the treatment group" using a logit model?

Thank you very much in advance

#### eyesack_kn

##### New Member
Lots of good questions.

First, what I don't know:
I've never used - margeff -. Had to look it up when you mentioned it.

Here's what I know:

- mfx - is deprecated; there's only one or two specialized limited dependent models that still use it, and I don't think - xtlogit - is one of them.

I also know that - margins - is a black box. I recommend that you obtain the marginal effect you want by hand, first, so that you know what it should be. Then its a matter of really digging around with - margins - to reproduce it, because it can often be some combination of the at() and predict() options that actually produces what you really want, and it's not always clear form the help file how to get at your specific marginal effect. This is especially true when explanatory variables are discrete. Anyway, once you know exactly how to obtain the effect you want and what it is, and you can get margins to reproduce it, then you have that knowledge and can apply it to all the different iterations of your model. This is what I do, anyway.

Interactions in a logit and probit models are a tricky business. -margins- thinks its smart and will spit out a number for you, but it doesn't calculate either the true margin or the standard error correctly. It would probably be in your best interest to use to obtain the true formula for the interaction you want by hand, then write some stata code that generates that margins and standard erros on your own using the e(b) and e(V) matrices after xtlogit.