Bookmark and Share

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

[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" <>
To   <>, <>
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 <> 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 "";, 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
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]
getmata edme, double
l ed edme in 1/50
su ed edme

Kit Baum   |   Boston College Economics & DIW Berlin   |
                              An Introduction to Stata Programming  |
   An Introduction to Modern Econometrics Using Stata  |

*   For searches and help try:

*   For searches and help try:

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