Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: How to use r(p)

From   "David Harrison" <>
To   <>
Subject   RE: st: How to use r(p)
Date   Mon, 12 Sep 2005 11:07:18 +0100

Almost... You will need to store the percentiles in local macros (as the return values r() get overwritten by regress):

_pctile d, p(33 66)
local p33=r(r1)
local p66=r(r2)
reg y a b c if d<=`p33'
reg y a b c if d>`p33' & d<`p66'
reg y a b c if d>=`p66'

Alternatively, you may find it easier by creating a new categorical variable for the 3 groups. e.g.

xtile byte pc=d, n(3)
bysort pc: reg y a b c

Hope this helps


-----Original Message-----
[]On Behalf Of FUKUGAWA, N.
Sent: 12 September 2005 10:03
Subject: Re: st: How to use r(p)

Dear all,
What if we want to run 3 regression models according to the classification of 
variable "d"?

centile d, centile(33)
centile d, centile(66)
reg y a b c if d<=r(c_1)
reg y a b c if d>r(c_1)&d<r(c_2)
reg y a b c if d>=r(c_2)

Thank you in advance.
FUKUGAWA Nobuya, Ph.D.

Jean-Benoit Hardouin wrote:
> You can try
> . centile d, centile(33)
> . reg y a b c if d>r(c_1)
> Best,
> Jean-Benoit Hardouin
> FUKUGAWA, N. a écrit :
>> Dear all,
>> Suppose we want to limit observations where one variable records a 
>> larger value
>> than its top quartile, we can write as follows.
>> sum d,detail
>> reg y a b c if d>r(p75)
>> However, this program allows only fixed thresholds such as 1, 10, and 
>> 75 percent.
>> How can I use other thresholds such as r(p33) in the program?
>> Or, is there any program to do the same?
>> Thanks in advance.
*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index