Dear Pradeep,
Calculating the marginal effect for a logistic regression when one of
the explanatory variables is also entered with an quadratic term can
be done by `hand' (well, by -nlcom- actually) but it gets a bit ugly,
see the example below.
Notice that the first couple of lines of the -nlcom- is the
probability density function of the logistic: exp(xb)/(1+exp(xb))^2.
The last lines of the -nlcom- command is the derivative of xb with
respect to x of interest, in this cas mpg: _b[mpg]+2*_b[mpg2]*(mean
mpg).
Maarten
#delim ;
sysuse auto;
gen mpg2=mpg^2;
logit foreign price weight mpg mpg2;
sum price, meanonly;
local price = r(mean);
sum weight, meanonly;
local weight = r(mean);
sum mpg, meanonly;
local mpg = r(mean);
nlcom(
exp(_b[_cons] + _b[price]*`price' + _b[weight]*`weight' + _b
[mpg]*`mpg' + _b[mpg2]*`mpg'^2)/
(1+exp(_b[_cons] + _b[price]*`price' + _b[weight]*`weight' + _b
[mpg]*`mpg' + _b[mpg2]*`mpg'^2))^2*
(_b[mpg]+2*_b[mpg2]*`mpg')
);
--- pradeep.kurukulasuriya@y...> wrote:
> I have a logit model with a linear and quadratic variable along
with some
> other variables (call it stuff). I am trying to estimate the
marginal
> effects for different sets variables in my model where each set is
comprised
> of a linear and quadratic term. Is there a ado file for this that
does not
> require the differentiation to be done manually (and then run a
proceedure
> like nlcom) or is that the best there is?
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/