Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: re: Adding the marginal effects at individual values of


From   "Solomon Tesfu" <[email protected]>
To   <[email protected]>, <[email protected]>
Subject   Re: st: re: Adding the marginal effects at individual values of
Date   Sat, 20 Feb 2010 21:49:56 -0500

Thanks a lot for your suggestion. The variable I'm dealing with is age-standardized height (age-for-height) that can take any value for each child and my sample contains about 2400 observations. Your suggestion would certainly work if I were to round off all the decimals to the nearest integers and calculate the marginal effects at integer points. But that will not tell the whole story.

Solomon T.

>>> Kit Baum <[email protected]> 02/20/10 9:01 PM >>>
<>
Solomon said
>I have a bivariate probit model where the key variable of interest 
>is continuous. The 'margeff' program in stata gives me the average 
>of the marginal effects at each value of of this variable. But I 
>want to look at how the marginal effects vary with changing values 
>of the variable. Therefore,  I would like to add the marginal 
>effects at each value of this continuous variable to the data and 
>'margeff' doesn't help me to do that. I would appreciate if anyone 
>has a suggestion as to how to proceed with this.

It is hard to imagine doing this if the variable of interest is really continuous (conceptually taking on a different value for each observation), but if there is a number of discrete values of the variable of interest (e.g, years of education in Rich Williams' example dataset), then you can save the marginal effects computed at each value and attach them to their respective observation:

set more off
clear all
use "http://www.indiana.edu/~jslsoc/stata/spex_data/ordwarm2.dta";, clear
logit  warmlt2 age ed prst
// for a continuous variable that takes on discrete values,
// evaluate the average marginal effect at each such value 
margins, dydx(ed) at(ed=(0/20))
mat ated = r(at)
mat ame = r(b)
putmata ed
mata:
meff = st_matrix("ated")[.,2], st_matrix("ame")'
meff = (1::rows(meff)), meff
// create a new vector that will hold the marginal effect for
// each observation in the original data
edme = J(rows(ed),1,.)
for(i=1;i<=rows(ed);i++) {
	edme[i,1] = meff[select(meff[.,1], meff[.,2] :== ed[i]), 3]
}
end
getmata edme, double
l ed edme in 1/50
su ed edme


Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
                              An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
   An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index