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   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: margins at every observation
Date   Wed, 13 Oct 2010 10:30:35 +0100 (BST)

--- On Wed, 13/10/10, Thomas  wrote:
> But it does not seem to allow negative values for
> the variable  that is included in -over-. Is there
> any way around this?

Yeah, but it all gets too complicated for my taste. 
I would just live with the fact that -margins- is not
inteded to do what you want it to do, and instead 
do it manually.

However, if you want to stick to the -margins- route,
here is a solution:

*--------- begin example --------
sysuse auto, clear

// create negative values
sum mpg , detail
replace mpg = mpg - r(p50)

// mpgid has a separate positive integers 
// value for each value of mpg
egen mpgid = group(mpg), label

reg price c.mpg##c.mpg
margins, dydx(mpg) over(mpgid)

// legend:
label list mpgid
*---------- end example ----------

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/


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