Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[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" <ecosttx@langate.gsu.edu>
To   <baum@bc.edu>, <statalist@hsphsun2.harvard.edu>
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 <baum@bc.edu> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index