[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Estimate marginal effects with interaction terms in non-linnear models.
Here are some general remarks about your question (which do not
explain your syntax error) and than some code that works on Stata 8.2
(I do not have version 9 yet) but the -version 8.2- command on top of
the code should ensure that it also works on your version.
First, are you sure you want marginal effects? When using interaction
terms you think that the effect of a variables is different for males
and females, or foreign and domestic cars, or ... But with marginal
effects you summarize these different effects with one number, and
thus loose this information.
Second, as you already saw the code you used will give you the
marginal effect for the probit model instead of the logit model you
want to estimate. You can either continue to use the logit and use the
example code below, or switch to probit and use the example code
provided by the FAQ. Conclusions drawn form either model are usually
the same, so the choice can be entirely guided by what is practical
Third, -predictnl- will create a new variable in your dataset with the
marginal effect as its value. You can see the result with -list xxx,
in 1-. -nlcom- is easier: it immediately shows the result, does not do
things to your data, and gives you standard errors and confidence
Fourth, there are people who do not like means of dummy variables:
have you ever seen someone who is .504 female? They would suggest that
you use the modal category. My position is that the modal category is
also a good summary measure and using it saves you some whining from
Fifth, if you want easier code than the logit allows you to calculate
odds ratios, which is just if the continuous variable is xxx and the
interactionterm with the dummy is yyy than the odds ratios are
exp(_b[xxx]) when the dummy is zero and exp(_b[xxx]+_b[yyy]) when the
dummy is one. See the thread on statalist started by:
*-----------begin example code------------
sysuse auto, clear
gen good = rep78>=4 if rep78~=.
gen forXturn = foreign * turn
logit good turn foreign forXturn
local meanfor = r(mean)
local meanturn = r(mean)
local xb = _b[_cons] + _b[turn]*`meanturn' + /*
*/ _b[forXturn]*`meanturn'*`meanfor' + /*
nlcom exp(`xb')/(1+`xb')^2 * _b[turn] + _b[forXturn]*`meanfor'
*--------------end example code-------------
For an explanation of why this code works see the thread started by:
Hope this helps,
---"Dozet Alexander" <Alexander.Dozet@s...> wrote:
> Currently I'm trying to estimate marginal effects with a logit model
> with 10 interaction terms (one continuous and one dummy).
> Furthermore one of the interaction terms is age sqr*male. Hence the
> use of -inteff- is not possible. I'm trying to learn how to use the
> -predictnl- command but have run into some difficulties. I tried to
> re-estimate the probit model that is to be found in "FAQ:I am using
> a model with interactions. How can I obtain marginal effects and
> their standard errors?"
> However when I estimate
> local xb _b[turn]*`meantur' + /*
> */ _b[dum]*`meandum' + _b[td]*`meantur'*`meandum' +
> predictnl dydt = normden(`xb')*(_b[turn] + _b[td]*`meandum') in 1,
> just after -predictnl- i get the error message
> invalid syntax
> Does any one know where the misstake is?
* For searches and help try: