Statalist


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

AW: st: test difference in quintiles


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: test difference in quintiles
Date   Wed, 10 Jun 2009 17:44:39 +0200

<> 

Try:

*************
clear*
set obs 10000
capt prog drop differ

gen x= rnormal()

/*no systematic difference btw
groups 
THIS IS equivalent to your
Y and Z conditions*/ 
gen condition=runiform()<0.5

pr differ, rclass
	vers 10.1
	qui su x if /* 
 */ condition==0,/* 
 */ det
 loc first=r(p5)
 qui su x if /* 
 */ condition==1,/* 
 */ det
 ret sca diff = r(p5)-`first'
end

bs diff=r(diff), /* 
 */ reps(200): differ

*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag von Susanne Neckermann
Gesendet: Mittwoch, 10. Juni 2009 17:38
An: [email protected]
Betreff: Re: st: test difference in quintiles

Dear T

thank you very much for the message!!
I am a real beginner with Stata and I have to admit that I do not  
quite understand how to transfer the code to my case.
I have a variable X that I observe under two conditions Y and Z. I  
want to see if the fifth percentile of variable X in condition Y is  
different from the fifth percentile of X in condition Z.

Thank you so much for your input!!
Best
Susanne

On 10-Jun-09, at 5:26 PM, Tirthankar Chakravarty wrote:

> <>
>
> This is a variation of previous advice:
> http://www.stata.com/statalist/archive/2009-05/msg00311.html
>
> I believe you want to test the significance of the difference of the
> 5th percentile for two variables using a bootstrap. If this is the
> case, then the code below applies:
>
> /* Bootstrap the difference of percentiles */
> clear
> webuse nlswork, clear
> keep idcode year ttl_exp
> reshape wide ttl_exp, i(idcode) j(year)
>
> cap prog drop pctile_bs
> program define pctile_bs, rclass
> 	version 10
> 	syntax varlist(max=2 min=2) [if] [in]
> 	marksample touse
> 	tokenize `varlist'
> 	local first `1'
> 	macro shift	
> 	local second `*'
> 	_pctile `first' if `touse', percentiles(5)
> 	scalar pc1 = r(r1)	
> 	_pctile `second' if `touse', percentiles(5)
> 	scalar pc2 = r(r1)
> 	return scalar dpc = pc1-pc2
> 	ereturn post, esample(`touse')
> end
> bootstrap  Dpc = r(dpc), reps(2000) dots: pctile_bs ttl_exp68  
> ttl_exp69
> /* End */
>
> Please also see the reference about pivotal statistics in a bootstrap
> from the previous message.
>
> T
>
>
> On Wed, Jun 10, 2009 at 3:57 PM, Susanne
> Neckermann<[email protected]> wrote:
>> Hi!
>>
>> I want to test whether the difference in the fifth percentile of two
>> distributions is significant.
>> In principle, this test should be similar to the "median" (thats  
>> the name of
>> the command) test already implemented in Stata, but unfortunately I  
>> cannot
>> program .ado files and I could not find a user-written procedure.
>> Any idea how to go about this?
>> P.S. the number of observations in the fifth percentile is pretty low
>> (around 6), so one might have to use something with bootstrap or
>> permutations.
>>
>> Thank you so much in advance
>> susanne
>>
>>
>>
>> *
>> *   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/
>>
>
>
>
> -- 
> To every ω-consistent recursive class κ of formulae there correspond
> recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
> belongs to Flg(κ) (where v is the free variable of r).
>
> *
> *   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/


*
*   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/


*
*   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