dlogit2, dprobit2, and dmlogit2
Updated: 8 Mar 96
------------------------------------------------------------------------------
Date: Wed, 20 Dec 1995 16:51:52 -0500
From: wsribney@stata.com (Bill Sribney, StataCorp)
To: statalist@dsg.harvard.edu
Subject: marginal effects for logit/probit/mlogit
Eric Jensen <erjensen@hawaii.edu> on Aug. 1 and Nov. 14 asked about an
intercept in -dprobit- output.
Stata's -dprobit- was written with the philosophy that marginal effects for
the intercept and for dummy variables don't make sense. So it doesn't report
results for the intercept, and, for dummies, it reports (by default) the
change as the dummy goes from 0 to 1.
Whether or not it makes sense, you can, however, compute marginal effects for
the intercept and dummies. You just compute dF/dx as if x (either the
constant term or dummies) were continuous. -dprobit- with the -classic-
option will do this for dummies.
Eric wasn't the only user to request marginal effects for the intercept.
Plus, we have had numerous requests for marginal effects for logit and mlogit.
So here they all are -- written by a biostatistician who isn't concerned about
whether or not they make sense!
The commands are called -dprobit2-, -dlogit2-, and -dmlogit2-.
The estimates and standard errors are produced according to the formulas in
Greene, Econometric Analysis, 2nd ed., p. 646 and 666. Note that -dprobit-
uses a different formula for the standard errors than does Greene; -dprobit-
takes the view that the marginal effects are computed at a specified
probability rather than a specified x. So -dprobit2- and -dprobit- give
slightly different standard errors. -dprobit2- and -dprobit- with the
-classic- option give the same estimates of the marginal effects.
Note that -dprobit2-, -dlogit2-, and -dmlogit2- are estimation commands. You
can use -test- afterwards and use _b[x] and matrix b = get(_b), etc.
These commands will appear in an upcoming STB. I don't have a good example
dataset to use with them. If someone has one, I'd be very grateful to get it.
Note that the example dataset will be distributed to everyone via the STB so
it should be something that you're willing to let everyone have -- and have
permission to make available for public use. Obviously, the dataset should
not be too big. It would be good to have a multinomial dependent variable
that could be used with mlogit as well as logit/probit (collapsing some of the
outcomes). Can anyone help?
Attached below are the following ado files:
dlogit2.ado
dprobit2.ado
dmlogit2.ado
dlog_dpr.ado
dlog_at.ado
And help files:
dlogit2.hlp
dprobit2.hlp
dmlogit2.hlp
See the help file for syntax and examples.
Please email me if you have any questions/comments/suggestions.
Bill Sribney
wsribney@stata.com
------------------------------------------------------------------------------
Date: Mon, 8 Jan 1996 12:48:37 -0500
From: wsribney@stata.com (Bill Sribney, StataCorp)
To: statalist@dsg.harvard.edu
Subject: marginal effects for mlogit
On 20 Dec 1995, I posted -dprobit2-, -dlogit2-, and -dmlogit2-,
commands that compute marginal effects for probit, logit, and mlogit.
In private email, Richard Upward (School of Economic Studies,
University of Manchester, UK) pointed out to me that -dmlogit2-
and LIMDEP v. 6.0 give different standard errors. I believe that LIMDEP
v. 6.0 is wrong. I think that Greene made an algebraic slip in deriving the
formula for the standard errors.
We don't have LIMDEP here. If someone has LIMDEP v. 7.0, would you kindly
look in the manual and see if the formula has been corrected and let the list
know.
Here are the details:
Greene and I are using the same method to compute standard errors. It's the
usual technique to compute the variance of a function g of beta.
Var[g(beta)] = J*Var(beta)*J'
where J is the Jacobian of g: J = dg/dbeta.
In this case, g(beta) = dP_j/dx, where P_j = Pr(y = j).
In the manual for LIMDEP v. 6.0, p. 478 (Section 40.4.1. Marginal Effects
in the Multinomial Logit Model) (kindly faxed to be by Richard Upward),
Greene gives the Jacobian as
V_jl = P_j[(j==1) - P_l]I +[(j==1) - 2P_l]*(dP_j/dx)*x'
(Note: For multinomial logit, beta = (beta_1,..., beta_J), where each beta_j
is a vector. So V_jl is a matrix that is one block of the Jacobian.)
My algebra gave (in Greene's notation)
V_jl = P_j[(j==1) - P_l]I + {[(j==1) - P_l]*(dP_j/dx) - P_j*(dP_l/dx)}*x'
I doublechecked my analytic Jacobian by computing numerical derivatives,
so I'm therefore inclined to think that Greene made an algebra slip in
deriving his formula. (Since I'm scared of making errors, this check
was the first thing I did after coding my analytic Jacobian.)
So if anyone has LIMDEP v. 7.0, would you please let us know if Greene has
corrected this formula.
Also if anyone feels like going through the algebra themselves, I'd
appreciate that, too. The algebra is straightforward and only takes a
couple of pages. (It's a good assignment for a graduate econometrics
class!)
Bill Sribney
wsribney@stata.com
-------------------------------------------------------------------------------
Date: Thu, 11 Jan 1996 11:50:00 -0500
From: espen.bratberg@econ.uib.no
To: statalist@dsg.harvard.edu
Subject: Re: marginal effects for mlogit
For what it's worth, I went through the calculations and arrived at the same
result as Bill Sribney.
I think that these commands for computing marginal effects are very useful,
but I also have a couple of suggestions for future revisions of -dmlogit2-.
1. The marginal effects of the base category are not reported in the current
version. One advantage of reporting marginal effects is that they (unlike the
coefficients) do not depend on the choice of base category a n d can be
computed for the base category, even if the according coefficient vector is
normalized to 0. Therefore, I suggest that a revised version of -dmlogit2-
reports the MEs for the base category, too. (I don't think that would require
many changes in the code.) Of course, one can obtain all the MEs with the
current version by running -dmlogit2- twice with different base categories.
2. -dmlogit2- reports the values of the variables where the MEs are evaluated.
It would be nice if the according estimated probabilities were reported, too.
Again, I suppose the necessary changes in the code would be minor.
3. When posting -dmlogit2- and -dprobit2- on 20 dec 1995, Bill Sribney
commented:
"Stata's -dprobit- was written with the philosophy that marginal
effects for the intercept and for dummy variables don't make sense."
I agree, and the same can be said for the multinomial logit. It would
facilitate interpretation if a future version reported probability changes for
dummy variables similarly to -dprobit-, either by default or as an option.
However, I realize that this featute probably would require more substantial
modifications of the code.
Espen Bratberg
Dept. of Economics, University of Bergen
-------------------------------------------------------------------------------
Date: Thu, 11 Jan 1996 13:49:18 -0500
From: wsribney@stata.com (Bill Sribney, StataCorp)
To: statalist@dsg.harvard.edu
Subject: marginal effects for mlogit
Thanks to all the persons who replied to my query about the differences
between -dmlogit2- and LIMDEP. It looks as if the formula LIMDEP is
using is wrong, and the error exists in both version 6 and 7.0 of LIMDEP.
Espen Bratberg <espen.bratberg@econ.uib.no> on 11 Jan 1996 suggested
some improvements for -dmlogit2-. Let me run down his suggestions and
give my response.
"1. The marginal effects of the base category are not reported in the current
version. One advantage of reporting marginal effects is that they (unlike the
coefficients) do not depend on the choice of base category a n d can be
computed for the base category, even if the according coefficient vector
is normalized to 0. Therefore, I suggest that a revised version of -dmlogit2-
reports the MEs for the base category, too."
Yes, this is easy. I'll do it.
"2. -dmlogit2- reports the values of the variables where the MEs are evaluated.
It would be nice if the according estimated probabilities were reported, too."
Yes, this is easy. I'll do it.
"3. When posting -dmlogit2- and -dprobit2- on 20 dec 1995, Bill Sribney
commented:
'Stata's -dprobit- was written with the philosophy that marginal
effects for the intercept and for dummy variables don't make sense.'
I agree, and the same can be said for the multinomial logit. It would
facilitate interpretation if a future version reported probability changes
for dummy variables similarly to -dprobit-, either by default or as an option.
However, I realize that this featute probably would require more substantial
modifications of the code."
Yes, this is hard. I wish I could say I won't do it, but it should be done.
What makes this such a pain is that the -d...2- commands (unlike the
current -dprobit-) compute a full covariance matrix and post the results.
Posting the results as an estimation command is real nice, since you can
use -test-, get coefficient vectors, etc.
So if -d...2- commands have an option for probability changes for dummy
variables, I'll have to use a different covariance formula for these
coefficient estimates and the others. Worse than working out the algebra
will be writing the code. Right now the code is a bunch of simple matrix
operations; it'll have to be a lot messier .... But, hey, this is my job
right? It will be fun to do, but will take more time.
Thanks again for everyone who replied. By the way, I'm sending a note
to Bill Greene of LIMDEP about its computation. I'll let the list know
what he says.
Bill Sribney
wsribney@stata.com
P.S. I'm still looking for a good example dataset to put in the STB with
these commands. If someone has one, I'd be very grateful to get it.
Note that the example dataset will be distributed to everyone via the
STB so it should be something that you're willing to let everyone have
-- and have permission to make available for public use. Obviously,
the dataset should not be too big. It would be good to have a
multinomial dependent variable that could be used with mlogit as well
as logit/probit.
-------------------------------------------------------------------------------
Note (12 Jan 1996):
Bill Greene responded to statalist confirming that the formula used by
LIMDEP was indeed incorrect.
-------------------------------------------------------------------------------
Date: Mon, 12 Feb 1996 10:41:29 -0500 (EST)
From: "Gerald C. Wright" <wright1@indiana.edu>
To: wsribney@stata.com
Subject: dlogit2
[Questions about installing help files for dlogit2 ...]
Incidentally, the program is terrific! I'll be getting a lot of use out
of it.
Thanks,
Jerry Wright
***********************************************
* Gerald Wright wright1@indiana.edu *
* Professor, Department of Political Science *
* Indiana University, Bloomington, IN 47405 *
* (812) 855-6306 or (812) 855-0518 (messages) *
***********************************************
Back to cool ado-files
|
|