Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]

clear mata
sysuse auto, clear
g mpgsq = mpg^2

// probit log-likelihood
void fnProbitLL(todo,b,crit,g,H)
	external vY,mX
	crit= vY'*log(normal(mX*b'))+(1:-vY)'*log(1:-normal(mX*b'))

// create data
vY = st_data(., ("foreign"))
mX = st_data(., ("mpg", "price", "mpgsq")), cons
stata("qui: logit foreign mpg price  mpgsq ")
init = st_matrix("e(b)")

// optimize
optimize_init_valueid(S, "log-likelihood")
optimize_init_which(S, "max")
optimize_init_evaluator(S, &fnProbitLL())
optimize_init_params(S, init)
optimize_init_technique(S, "nr")
optimize_init_trace_value(S, "on")
optimize_init_trace_params(S, "on")

// retrieve results
vB = optimize_result_params(S)
mVarCovar = optimize_result_V_oim(S)

// construct marginal effects (Ai & Norton, EL, 2003)
dB12 = vB[1, 3]  // coeff. on 2nd-order term
dB1 = vB[1, 1]  // coeff. on main term
// vector of individual marginal effects
vPE = normalden(mX*vB'):*(dB1:+2*dB12:*mX[.,1])
// average partial effect
printf("The average marginal effect of age= %g.\n", colsum(vPE)/rows(vPE))

// probit foreign c.mpg##c.mpg price
probit foreign mpg c.mpg#c.mpg price
margins, dydx(mpg)

And you see that the marginal effects computed directly from the
formula coincides exactly with what Stata gives you using -margins-.

The standard reference for this sort of thing is Ai & Norton,
"Interaction terms in logit and probit models", Economics Letters,
80(1), 2003, and the accompanying Stata Journal article, which can be
found here:


On Thu, Dec 30, 2010 at 1:08 AM, Justina Fischer <> wrote:
> thanks for these insights ans sorry for bothering you a last time:
> estimating
> logistic outcome treatment##group c.age##c.age
> what marginal effect does
> margins, dydx(age)
> estimate ? is it dy/dx = a + 2bx ?
> Justina

To every Ï?-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).

*   For searches and help try:

© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index