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" <[email protected]>
To   <[email protected]>
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 http://www.stata.com/statalist/archive/2004-11/msg00128.html .

Hope this helps,
Maarten

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

Statalist,

   I am using a user defined program (called reoprob) which runs a random
effects
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'
end

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.

Yours,
Paul

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

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

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