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

Re: st: derivatives using _me_derb


From   [email protected] (Roberto G. Gutierrez, StataCorp.)
To   [email protected]
Subject   Re: st: derivatives using _me_derb
Date   Fri, 06 Sep 2002 06:48:11 -0500

Mike Will <[email protected]> asks:

> I am having trouble using _me_derb (dF/dB).  Here is my syntax:
> **************************************************************
> logit y x1 x2 x3
> matrix X=(1, 0.5, -0.9, 1.2)
> _me_derb X 4 predopt lny
> di r(dmdb)
> **************************************************************

> Here I am trying to take the derivative of (1/(1+(exp(XB))^(-1)), or
> predicted probability with respect to B with the X matrix of (1, 0.5, -0.9,
> 1.2).  As no help file is available for this ado file, I am getting error
> message whihc is of little informative value.  Any input? thanks in advance.

-_me_derb- is a subroutine of -mfx- residing in its own ado file, and is not
intended to be called directly by the user.  Hence, it is not documented, nor
guaranteed to always exist in its present form.

You can, however, get the derivatives you want using -testnl- (which is 
documented) with the -g()- option.  After running -logit-, try

	. testnl 1/(1 + exp(-(1*_b[_cons] + 0.5*_b[x1] -  /* 
	         */   0.9*_b[x2] + 1.2*_b[x3]))) = 0, g(D)
	. mat B = e(b)
	. local mname : colnames B
	. matrix colnames D = `mname'
	. mat list D

The matrix -D- will contain the derivatives you want.  The last bit of
programming merely sets the column labels of D so that you know which elements
of B the derivatives corresponds to.

--Bobby
[email protected]
*
*   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