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

st: RE: marginal effects for user defined programs

From   "Maarten Buis" <>
To   <>
Subject   st: RE: marginal effects for user defined programs
Date   Tue, 4 Oct 2005 17:51:08 +0200

Dear Paul:

You could probably use Scott long's -prchange- command as a template. It calculates marginal effects without sending predicted values to -mfx-, which makes it faster and more precise (-mfx- produces numerical approximations). Not that the precision really matters, imprecision introduced by the numerical approximation is likely to be completely drowned by the imprecision due to problems in our data. More important is that coding is easier if you have a working template to compare it with. You might also be interested in the thread on statalist started with .

Hope this helps,

-----Original Message-----
From: []On Behalf Of Paul James
Sent: dinsdag 4 oktober 2005 17:27
Subject: st: marginal effects for user defined programs


   I am using a user defined program (called reoprob) which runs a random
ordered probit model (the dependent variable, y, takes on 5 values).
Because the program is user defined, I need to write a function to get
the marginal effects that I want.  To do this, I wrote one do file
program that calls upon a predict option called mypredict.

program define myreoprob, eclass
reoprob wagecat inc female, i(id)
estimates local cmd='myreoprob'
estimates local predict='mypredict'

The next step is to define and run a program called mypredict.  From what
I understand, ultimately I want to use the mfx command, and it will
automatically go to mypredict to find the function it needs to take the
derivative of.  In my case, I want

prob(wagecat=0) = prob(xb + u < cut1) = prob(u < cut1 - xb)
                                = normprob(cut1 - xb)

Now the marginal effects for continuous regressors should be the
derivative of this with respect to that continuous regressor, while the
marginal effect for discrete regressors should be the difference:

prob(y=0 | discrete regressor = 1, all other regressors at their means)
- prob(y=0 | discrete regressor = 0, all other regressors at their means)

Can you help me with this mypredict program, as well as what to type in the
command box after the mypredict program is run, so that it will calculate
marginal effects after the reoprob estimation.


Express yourself instantly with MSN Messenger! Download today - it's FREE!

*   For searches and help try:

*   For searches and help try:

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