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: margins at every observation


From   Tim Wade <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: margins at every observation
Date   Wed, 13 Oct 2010 05:55:37 -0400

Maybe use levelsof to store values in a macro

levelsof mpg, local(x)

reg price c.mpg##c.mpg
margins dydx(mpg) at(mpg=('x'))

Something like that may work, but I did not test this.

Tim

Sent from my iPod

On Oct 13, 2010, at 5:15 AM, Thomas <[email protected]> wrote:

>> --- On Tue, 12/10/10, Thomas wrote:
>>> I want to calculate the marginal effects for all
>>> observations:
>>>
>>> sysuse auto, clear
>>> reg price c.mpg##c.mpg
>>>
>>> gen dydx = _b[mpg]+2*_b[ c.mpg#c.mpg]*mpg
>>>
>>> I thought I would get the same using:
>>>
>>> margins, dydx(mpg) at((asobserved) mpg)
>>>
>>> but I only get a single value at the mean of mpg.
>>>
>>> How can I get the marginal effect at each observation from
>>> -margins- (if at all)?
>> That marginal effect only depends on the value of mpg, so
>> you can get a complete list of all marginal effects by typing:
>>
>> margins, dydx(mpg) over(mpg)
>>
>> There is no -generate- or -replace- option in -margins, so there
>> is no easy way to turn this into a variable (it is possible, but
>> your manual computations are just easier).
>>
>> Hope this helps,
>> Maarten
>>
>> --------------------------
>> Maarten L. Buis
>> Institut fuer Soziologie
>> Universitaet Tuebingen
>> Wilhelmstrasse 36
>> 72074 Tuebingen
>> Germany
>>
>> http://www.maartenbuis.nl
>> --------------------------
>>
>>
>>
>>
>>
>>
>> *
>> *   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/
>>
> Thanks. But it does not seem to allow negative values for the variable that is included in -over-. Is there any way around this?
>
> Thomas
> *
> *   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