Statalist


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

Re: st: Estimating peak points from regressions


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Estimating peak points from regressions
Date   Fri, 2 Jan 2009 11:51:57 +0000 (GMT)

--- "Pavlos C. Symeou" <[email protected]> wrote:
> I am estimating a regression model where the dependent variable is
> the number of fixed telephony lines (fixed) regressed on (among
> others) the number of mobile subscribers (mobile), the square of this
> variable (mobile_sq), a variable that measures economy size (size),
> and its square (size_sq). I would like to know how I can estimate
> the peaks for mobile and size. <snip> If the estimation of these two
> peak points is possible algebraically, is there a way to illustrate
> this graphically?

Remember that you can find the minimum or maximum by setting the first
derivative equal to zero. If you have a function:

y = ax^2 + bx + c + f(z)

where f(z) is some generic function of your other variables.

Then the first derivative with respect to x is:

dy/dx = 2ax + b

(Notice that f(z) drops out.) Setting that to zero leads to the
conclusion that the maximum/minimum occurs at:

x = -b/2a

You can compute that quantity with a confidence interval using -nlcom-.

For graphing I recommend preparing a dataset using -adjust-, like in
the example below.

Hope this helps,
Maarten

*----------------- begin example ----------------------
sysuse nlsw88, clear
gen ttl_exp2 = ttl_exp^2
gen tenure2 = tenure^2

reg wage ttl_exp ttl_exp2 tenure tenure2 grade

// compute the location of the maximum (tenure)
// and the minimum (ttl_exp)
nlcom (- _b[ttl_exp]/(2*_b[ttl_exp2])) ///
      (- _b[tenure]/(2*_b[tenure2]))

// graph the expected wage against ttl_exp for
// someone with mean grade and mean tenure
sum tenure, meanonly
local m_ten = r(mean)
local m_ten2 = r(mean)^2

qui adjust tenure=`m_ten'   ///
           tenure2=`m_ten2' ///
           grade,           ///
           by(ttl_exp) ci replace

twoway rarea lb ub ttl_exp || ///
       line xb ttl_exp, legend(off) ///
       name(exp, replace) 

// graph the expected wage against tenure for
// someone with mean grade and mean ttl_exp
sysuse nlsw88, clear
gen ttl_exp2 = ttl_exp^2
gen tenure2 = tenure^2

reg wage ttl_exp ttl_exp2 tenure tenure2 grade

sum ttl_exp, meanonly
local m_exp = r(mean)
local m_exp2 = r(mean)^2

qui adjust ttl_exp=`m_exp'   ///
           ttl_exp2=`m_exp2' ///
           grade,           ///
           by(tenure) ci replace

twoway rarea lb ub tenure || ///
       line xb tenure, legend(off) ///
       name(tenure, replace)
*---------------- end example --------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room N515

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index