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: Test for significance of the difference between knee locations?


From   Joerg Luedicke <[email protected]>
To   [email protected]
Subject   Re: st: Test for significance of the difference between knee locations?
Date   Thu, 18 Oct 2012 17:12:00 -0500

I was just putting together some example code, similar in principle to
Austin's code, but encountered difficulties with the -test- command.
If we use Austin's code:

*--Austin Nichols' code--
sysuse nlsw88, clear
*compare extremum positions for quadratics, e.g. for
*tw qfit wage age if union==0||qfit wage age if union==1
reg wage c.age##c.age##i.union, nohe
loc 1 (k1:-_b[age]/_b[c.age#c.age]/2)
loc 2 (k2:-(_b[age]+_b[1.union#c.age])/
loc 2 `2'(_b[c.age#c.age]+_b[1.union#c.age#c.age])/2)
nlcom `1' `2', post
test k1==k2
*-------------------------------

I get an error message after -test k1==k2-:

. test k1==k2
k1 not found
r(111);

However, I can do:

. test k1

 ( 1)  k1 = 0

       F(  1,  1872) =  433.55
            Prob > F =    0.0000

and

. test k2

 ( 1)  k2 = 0

       F(  1,  1872) =   54.22
            Prob > F =    0.0000

Anybody else experiencing this? (I am using Stata 11.2)

Joerg


On Thu, Oct 18, 2012 at 4:10 PM, Austin Nichols <[email protected]> wrote:
> Jordan Silberman <[email protected]>:
> Do not test all coefs' equality if you want to test whether maxima or
> minima are in the same position on the x axis. Rather solve for maxima
> or minima by setting the first derivative to zero to find that the
> extremum is where x equals the negative of the linear term's coef
> divided by twice the quadratic term's coef (-b/2a in the usual
> parlance, for y=ax^2+bx+c).
>
> sysuse nlsw88, clear
> *compare extremum positions for quadratics, e.g. for
> *tw qfit wage age if union==0||qfit wage age if union==1
> reg wage c.age##c.age##i.union, nohe
> loc 1 (k1:-_b[age]/_b[c.age#c.age]/2)
> loc 2 (k2:-(_b[age]+_b[1.union#c.age])/
> loc 2 `2'(_b[c.age#c.age]+_b[1.union#c.age#c.age])/2)
> nlcom `1' `2', post
> test k1==k2
> * or keep your command shorter
> g a2=age^2
> g ua=union*age
> g ua2=union*a2
> g na=(union==0)*age
> g na2=(union==0)*a2
> g nu=(union==0)
> reg wage union ua ua2 nu na na2, hascons
> test ua=na
> nlcom (k1:-_b[na]/_b[na2]/2) (k2:-_b[ua]/_b[ua2]/2), post
> test k1==k2
>
> *do not test all 3 param like so:
> reg wage union ua ua2 nu na na2, hascons
> test ua=na
> test ua2=na2, accum
> test union=nu, accum
>
>
> On Thu, Oct 18, 2012 at 4:25 PM, Jordan Silberman
> <[email protected]> wrote:
>> Hi Stata folks,
>>
>> I'm searching for a method I can run in Stata that will allow me to
>> test whether the location of the knee for one quadratic model
>> significantly differs from that of another quadratic model.
>>
>> I have 2 quadratic models, each modeling a different category of
>> healthcare costs as a function of age. Let's say, for illustrative
>> purposes, that the knee of the first quadratic model occurs at age 45,
>> and the knee for the second model occurs at age 55.
>>
>> Can anybody suggest a method for testing whether the former "knee age"
>> differs significantly from the latter "knee age?" The idea is to test
>> the hypothesis that there is a difference across the 2 models in the
>> age at which the costs growth rate begins to increase.
>>
>> Any suggestions would be greatly appreciated.
>>
>> Thanks,
>> Jordan
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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