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 on April 23, and its replacement, is already up and running.

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

Re: st: margins at every observation

From   Maarten buis <>
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 L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen


*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index