Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Estimating marginal effects of linear and quadratic term from a logit regression


From   "maartenbuis" <[email protected]>
To   [email protected]
Subject   Re: st: Estimating marginal effects of linear and quadratic term from a logit regression
Date   Mon, 08 Nov 2004 11:28:20 -0000

Dear Pradeep,

The example I have given can also serve as warning about summerizing 
a nonlinear effect with one parameter. Look at the graph: early on 
mpg has a very strong effect but it has flattened out when it has 
reached its mean, so the marginal effect at its mean is very small. 
If you do not plot the probability against the x of interest you 
might miss these aspects.

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);

gen gr_mpg = 11 + _n;
gen pr=. ;

forvalues i= 12/41 { ;
replace pr= invlogit(_b[_cons] + _b[weight]*`weight' + 
_b[price]*`price' + _b[mpg]*`i' + _b[mpg2]*`i'^2) if gr_mpg==`i' ;
};

line pr gr_mpg if gr_mpg <=41, xline(`mpg');


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')
);




*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index