Statlisisters,
I'm unsuccessful at applying axis title to a SECOND Yaxis on a plot.. Here's what I'm trying: twoway line y1 X, sort by(group) line y2 X, xtitle("Time") ytitle("Predicted y1") yaxis(2) ytitle("Predicted y2",axis(2)) sort I can get the second Y axis to show up, and can manipulate options with it (ex. can change labels), but I cannot get the second axis TITLE to appear?? What am I doing wrong?? Thanks! ******************************************************************************************** Rob * * 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/ 
<> Does work, though... ************* sysuse uslifeexp, clear twoway (line le_wmale year) /* */ (line le_bmale year, yaxis(2)),/* */ ytitle(Left Side)/* */ ytitle(Right Side, axis(2)) ************* HTH Martin Ursprüngliche Nachricht Von: [hidden email] [mailto:[hidden email]] Im Auftrag von PloutzSnyder, Robert (JSCSK)[USRA] Gesendet: Mittwoch, 10. Juni 2009 15:32 An: [hidden email] Betreff: st: Need to Title a Second YAxis... Statlisisters, I'm unsuccessful at applying axis title to a SECOND Yaxis on a plot.. Here's what I'm trying: twoway line y1 X, sort by(group) line y2 X, xtitle("Time") ytitle("Predicted y1") yaxis(2) ytitle("Predicted y2",axis(2)) sort I can get the second Y axis to show up, and can manipulate options with it (ex. can change labels), but I cannot get the second axis TITLE to appear?? What am I doing wrong?? Thanks! **************************************************************************** **************** Rob * * 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/ 
In reply to this post by PloutzSnyder, Robert (JSCSK)[USRA]
 On Wed, 10/6/09, PloutzSnyder, Robert wrote: > I'm unsuccessful at applying axis title to a SECOND Yaxis > on a plot.. Here's what I'm trying: > > twoway line y1 X, sort by(group) line y2 X, > xtitle("Time") ytitle("Predicted y1") yaxis(2) > ytitle("Predicted y2",axis(2)) sort  On Wed, 10/6/09, Martin Weiss wrote: > Does work, though... > > ************* > sysuse uslifeexp, clear > > twoway (line le_wmale year) /* > */ (line le_bmale year, yaxis(2)),/* > */ ytitle(Left Side)/* > */ ytitle(Right Side, axis(2)) > ************* The problem is the by() option: * begin example  sysuse auto, clear twoway scatter price mpg  /// scatter turn mpg, /// by(foreign) yaxis(2) /// ytitle("turn", axis(2)) * end example  Don't see an immediate solution though (have to leave now for a seminar).  Maarten  Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany 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/ 
In reply to this post by Martin Weiss5
Hmmm.. I'm using a few more options (scale, legend, etc) and I can't make that work either Martin. I tried to simplify my code earlier, but here's my full code including the other options I'm throwing at Stata:
twoway (line y1 x if followup==0, sort by(tmt) xlabel(0 1(1)12) xtitle("Treatment Weeks")) (line y2 x if followup==0, yaxis(2) sort by(tmt) ytitle("LEFT axis title ") ytitle("RIGHT axis title", axis(2)) ylabel(0 1(1)3) ylabel(0(.1)1,axis(2)) legend(label(1 "left legend title ") label(2 "right legend title)"))) I'm guessing there's something about the order of these options?? I tried moving the xlabel and xtitle at the END with all of the other options (my usual method), but that doesn't seem to work. I moved things all around hoping to "bump into" the right order, but I'm stumped.. Thanks! Rob Original Message From: [hidden email] [mailto:[hidden email]] On Behalf Of Martin Weiss Sent: Wednesday, June 10, 2009 8:51 AM To: [hidden email] Subject: st: AW: Need to Title a Second YAxis... <> Does work, though... ************* sysuse uslifeexp, clear twoway (line le_wmale year) /* */ (line le_bmale year, yaxis(2)),/* */ ytitle(Left Side)/* */ ytitle(Right Side, axis(2)) ************* HTH Martin Ursprüngliche Nachricht Von: [hidden email] [mailto:[hidden email]] Im Auftrag von PloutzSnyder, Robert (JSCSK)[USRA] Gesendet: Mittwoch, 10. Juni 2009 15:32 An: [hidden email] Betreff: st: Need to Title a Second YAxis... Statlisisters, I'm unsuccessful at applying axis title to a SECOND Yaxis on a plot.. Here's what I'm trying: twoway line y1 X, sort by(group) line y2 X, xtitle("Time") ytitle("Predicted y1") yaxis(2) ytitle("Predicted y2",axis(2)) sort I can get the second Y axis to show up, and can manipulate options with it (ex. can change labels), but I cannot get the second axis TITLE to appear?? What am I doing wrong?? Thanks! **************************************************************************** **************** Rob * * 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/ 
In reply to this post by Maarten buis
<> Maarten and Robert do have a case. I cannot make the title appear on a by graph, either, even with the help of the dialog box. ************* sysuse uslifeexp, clear gen byte dummy=_n>`=_N/2' twoway (line le_male year)/* */ (line le_female year, yaxis(2)), /* */ ytitle(Left Side) ytitle(Right Side, axis(2))/* */ by(dummy) ************* HTH Martin Ursprüngliche Nachricht Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Maarten buis Gesendet: Mittwoch, 10. Juni 2009 16:11 An: [hidden email] Betreff: Re: st: Need to Title a Second YAxis...  On Wed, 10/6/09, PloutzSnyder, Robert wrote: > I'm unsuccessful at applying axis title to a SECOND Yaxis > on a plot.. Here's what I'm trying: > > twoway line y1 X, sort by(group) line y2 X, > xtitle("Time") ytitle("Predicted y1") yaxis(2) > ytitle("Predicted y2",axis(2)) sort  On Wed, 10/6/09, Martin Weiss wrote: > Does work, though... > > ************* > sysuse uslifeexp, clear > > twoway (line le_wmale year) /* > */ (line le_bmale year, yaxis(2)),/* > */ ytitle(Left Side)/* > */ ytitle(Right Side, axis(2)) > ************* The problem is the by() option: * begin example  sysuse auto, clear twoway scatter price mpg  /// scatter turn mpg, /// by(foreign) yaxis(2) /// ytitle("turn", axis(2)) * end example  Don't see an immediate solution though (have to leave now for a seminar).  Maarten  Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany 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/ * * 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/ 
Ok.. so I'm not going crazy then.
I did discover that if you go into the chart editor tool, double click on the right axis, then click the "Title" button, then select the "Advanced" Tab and UNCHECK the box for "hide text box," the title from my code magically appears. So if someone can figure out how to turn off the default function of hiding the text box on the second Yaxis title, that should do it?? Thanks for solidifying my sanity on this one! Rob Original Message From: [hidden email] [mailto:[hidden email]] On Behalf Of Martin Weiss Sent: Wednesday, June 10, 2009 9:31 AM To: [hidden email] Subject: AW: st: Need to Title a Second YAxis... <> Maarten and Robert do have a case. I cannot make the title appear on a by graph, either, even with the help of the dialog box. ************* sysuse uslifeexp, clear gen byte dummy=_n>`=_N/2' twoway (line le_male year)/* */ (line le_female year, yaxis(2)), /* */ ytitle(Left Side) ytitle(Right Side, axis(2))/* */ by(dummy) ************* HTH Martin Ursprüngliche Nachricht Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Maarten buis Gesendet: Mittwoch, 10. Juni 2009 16:11 An: [hidden email] Betreff: Re: st: Need to Title a Second YAxis...  On Wed, 10/6/09, PloutzSnyder, Robert wrote: > I'm unsuccessful at applying axis title to a SECOND Yaxis > on a plot.. Here's what I'm trying: > > twoway line y1 X, sort by(group) line y2 X, > xtitle("Time") ytitle("Predicted y1") yaxis(2) > ytitle("Predicted y2",axis(2)) sort  On Wed, 10/6/09, Martin Weiss wrote: > Does work, though... > > ************* > sysuse uslifeexp, clear > > twoway (line le_wmale year) /* > */ (line le_bmale year, yaxis(2)),/* > */ ytitle(Left Side)/* > */ ytitle(Right Side, axis(2)) > ************* The problem is the by() option: * begin example  sysuse auto, clear twoway scatter price mpg  /// scatter turn mpg, /// by(foreign) yaxis(2) /// ytitle("turn", axis(2)) * end example  Don't see an immediate solution though (have to leave now for a seminar).  Maarten  Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany 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/ * * 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/ 
<> This takes you halfway there: ************* sysuse uslifeexp, clear gen dummy=_n>`=_N/2' tw (line le_male year)/* */ (line le_female year, yaxis(2)),/* */ by(dummy, iytitle) ************* HTH Martin Ursprüngliche Nachricht Von: [hidden email] [mailto:[hidden email]] Im Auftrag von PloutzSnyder, Robert (JSCSK)[USRA] Gesendet: Mittwoch, 10. Juni 2009 16:39 An: [hidden email] Betreff: RE: st: Need to Title a Second YAxis... Ok.. so I'm not going crazy then. I did discover that if you go into the chart editor tool, double click on the right axis, then click the "Title" button, then select the "Advanced" Tab and UNCHECK the box for "hide text box," the title from my code magically appears. So if someone can figure out how to turn off the default function of hiding the text box on the second Yaxis title, that should do it?? Thanks for solidifying my sanity on this one! Rob Original Message From: [hidden email] [mailto:[hidden email]] On Behalf Of Martin Weiss Sent: Wednesday, June 10, 2009 9:31 AM To: [hidden email] Subject: AW: st: Need to Title a Second YAxis... <> Maarten and Robert do have a case. I cannot make the title appear on a by graph, either, even with the help of the dialog box. ************* sysuse uslifeexp, clear gen byte dummy=_n>`=_N/2' twoway (line le_male year)/* */ (line le_female year, yaxis(2)), /* */ ytitle(Left Side) ytitle(Right Side, axis(2))/* */ by(dummy) ************* HTH Martin Ursprüngliche Nachricht Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Maarten buis Gesendet: Mittwoch, 10. Juni 2009 16:11 An: [hidden email] Betreff: Re: st: Need to Title a Second YAxis...  On Wed, 10/6/09, PloutzSnyder, Robert wrote: > I'm unsuccessful at applying axis title to a SECOND Yaxis > on a plot.. Here's what I'm trying: > > twoway line y1 X, sort by(group) line y2 X, > xtitle("Time") ytitle("Predicted y1") yaxis(2) > ytitle("Predicted y2",axis(2)) sort  On Wed, 10/6/09, Martin Weiss wrote: > Does work, though... > > ************* > sysuse uslifeexp, clear > > twoway (line le_wmale year) /* > */ (line le_bmale year, yaxis(2)),/* > */ ytitle(Left Side)/* > */ ytitle(Right Side, axis(2)) > ************* The problem is the by() option: * begin example  sysuse auto, clear twoway scatter price mpg  /// scatter turn mpg, /// by(foreign) yaxis(2) /// ytitle("turn", axis(2)) * end example  Don't see an immediate solution though (have to leave now for a seminar).  Maarten  Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany 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/ * * 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/ 
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/ 
<>
This is a variation of previous advice: http://www.stata.com/statalist/archive/200905/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 = pc1pc2 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<[hidden email]> 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 userwritten 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/ 
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 10Jun09, at 5:26 PM, Tirthankar Chakravarty wrote: > <> > > This is a variation of previous advice: > http://www.stata.com/statalist/archive/200905/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 = pc1pc2 > 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<[hidden email]> 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 userwritten 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/ 
<> 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: [hidden email] [mailto:[hidden email]] Im Auftrag von Susanne Neckermann Gesendet: Mittwoch, 10. Juni 2009 17:38 An: [hidden email] 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 10Jun09, at 5:26 PM, Tirthankar Chakravarty wrote: > <> > > This is a variation of previous advice: > http://www.stata.com/statalist/archive/200905/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 = pc1pc2 > 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<[hidden email]> 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 userwritten 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/ 
In reply to this post by Susanne Neckermann
<>
I will assume your conditioning variables Y & Z are binary. In the auto dataset, consider that you want to test the difference in the 5th percentile of the variable "mpg" if price is greater than $6000 (condition1, variable "pricedummy") or if the car is of foreign origin (condition 2, variable "foreign"). Then the code below should do what you want. Also, it might be a good idea to plot the kernel density estimates when considering tailbehaviour of distributions. Else if you only have one conditioning variable (case1, cond_var==1; case 2, cond_var==0), then Martin's code is probably more useful. /* More on bootstrapping percentiles */ sysuse auto, clear g pricedummy=(price>6000) tab pricedummy cap prog drop pctile_bs program define pctile_bs, rclass version 10 syntax varlist(max=3 min=3) [if] [in] marksample touse tokenize `varlist' local first `1' macro shift local second `1' macro shift local third `1' _pctile `first' if (`touse' & `second'==1), percentiles(5) scalar pc1 = r(r1) _pctile `first' if (`touse' & `third'==1), percentiles(5) scalar pc2 = r(r1) return scalar dpc = pc1pc2 ereturn post, esample(`touse') end bootstrap Dpc = r(dpc), reps(2000) dots: pctile_bs mpg foreign pricedummy twoway (kdensity mpg if foreign==1) (kdensity mpg if pricedummy==1, legend(order(1 "foreign" 2 "pricedummy"))) /* end */ Simply substitute your variables in the line as follows: bootstrap Dpc = r(dpc), reps(2000) dots: pctile_bs X Y Z T  References  Statalist discussion: http://www.stata.com/statalist/archive/200402/msg00618.html On Wed, Jun 10, 2009 at 4:44 PM, Martin Weiss<[hidden email]> wrote: > > <> > > 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: [hidden email] [mailto:[hidden email]] Im Auftrag von Susanne Neckermann > Gesendet: Mittwoch, 10. Juni 2009 17:38 > An: [hidden email] > 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 10Jun09, at 5:26 PM, Tirthankar Chakravarty wrote: > >> <> >> >> This is a variation of previous advice: >> http://www.stata.com/statalist/archive/200905/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 = pc1pc2 >> 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<[hidden email]> 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 userwritten 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/ >  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/ 
This post was updated on .
In reply to this post by Susanne Neckermann
CONTENTS DELETED
The author has deleted this message.

Thanks to Samuel for the promotion. However, cendif computes confidence intervals, not for differences between percentiles, but for percentile differences. These are not exactly the same thing. For a counterexample, see Newson (2008).
If Suzanne wants confidence intervals for the differences between 2 5th percentiles for 2 subpopulations, then Suzanne should probably use the centile command to get confidence intervals for the 2 5th percentiles, and then use the invcise package and the metaparm module of the parmest package, downloadable from SSC, to get a confidence interval for the difference between the 2 5th percentiles. The invcise package calculates standard errors using the inverse confidence interval method. I hope this helps. Best wishes Roger References Newson, R. B. HodgesLehmann median differences between exponential subpopulations. Downloadable from http://www.imperial.ac.uk/nhli/r.newson/papers.htm#miscellaneous_documents as from 12 October 2008. Roger B Newson BSc MSc DPhil Lecturer in Medical Statistics Respiratory Epidemiology and Public Health Group National Heart and Lung Institute Imperial College London Royal Brompton Campus Room 33, Emmanuel Kaye Building 1B Manresa Road London SW3 6LR UNITED KINGDOM Tel: +44 (0)20 7352 8121 ext 3381 Fax: +44 (0)20 7351 8322 Email: [hidden email] Web page: http://www.imperial.ac.uk/nhli/r.newson/ Departmental Web page: http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/ Opinions expressed are those of the author, not of the institution. Original Message From: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email] Sent: 10 June 2009 22:42 To: [hidden email] Subject: Re: st: test difference in quintiles cendif by Roger Newson, is part of the somersd package, downloadable from SSC (type "ssc install somersd". It computes CI's for, and tests, differences between medians. You will need large sample sizes to test the difference between 5th percentiles with reasonable power. What do you mean by "number of observations in the 5th percentile"? You should not group data prior to the analysis. Steve On Wed, Jun 10, 2009 at 10:57 AM, Susanne Neckermann<[hidden email]> 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 userwritten 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/ > * * 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/ 
<> Susanne asked me privately for further advice and also mentioned that she could not figure out the implementation of Roger`s post. From what I understand, the solution proposed by Roger should look like: ************* clear* set obs 10000 capt ssc inst invcise capt ssc inst parmest gen x= rnormal() /* no systematic difference btw groups */ gen byte condition=/* */ runiform()<0.5 /*just to check plausibility of results */ by con, sort : /* */ summarize x, detail statsby N=r(N) p5=r(c_1) /* */ p5min=r(lb_1) p5max=r(ub_1),/* */ by(condition)/* */ clear: centile x, c(5) invcise p5min p5max, /* */ stderr(icse) metaparm [iweight=(cond==1)(cond==0)],/* */ norestore sumvar(N)/* */ estimate(p5) stderr(icse) list, noobs ************* HTH Martin Ursprüngliche Nachricht Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Newson, Roger B Gesendet: Donnerstag, 11. Juni 2009 10:45 An: '[hidden email]' Betreff: RE: st: test difference in quintiles Thanks to Samuel for the promotion. However, cendif computes confidence intervals, not for differences between percentiles, but for percentile differences. These are not exactly the same thing. For a counterexample, see Newson (2008). If Suzanne wants confidence intervals for the differences between 2 5th percentiles for 2 subpopulations, then Suzanne should probably use the centile command to get confidence intervals for the 2 5th percentiles, and then use the invcise package and the metaparm module of the parmest package, downloadable from SSC, to get a confidence interval for the difference between the 2 5th percentiles. The invcise package calculates standard errors using the inverse confidence interval method. I hope this helps. Best wishes Roger References Newson, R. B. HodgesLehmann median differences between exponential subpopulations. Downloadable from http://www.imperial.ac.uk/nhli/r.newson/papers.htm#miscellaneous_documents as from 12 October 2008. Roger B Newson BSc MSc DPhil Lecturer in Medical Statistics Respiratory Epidemiology and Public Health Group National Heart and Lung Institute Imperial College London Royal Brompton Campus Room 33, Emmanuel Kaye Building 1B Manresa Road London SW3 6LR UNITED KINGDOM Tel: +44 (0)20 7352 8121 ext 3381 Fax: +44 (0)20 7351 8322 Email: [hidden email] Web page: http://www.imperial.ac.uk/nhli/r.newson/ Departmental Web page: http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgene tics/reph/ Opinions expressed are those of the author, not of the institution. Original Message From: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email] Sent: 10 June 2009 22:42 To: [hidden email] Subject: Re: st: test difference in quintiles cendif by Roger Newson, is part of the somersd package, downloadable from SSC (type "ssc install somersd". It computes CI's for, and tests, differences between medians. You will need large sample sizes to test the difference between 5th percentiles with reasonable power. What do you mean by "number of observations in the 5th percentile"? You should not group data prior to the analysis. Steve On Wed, Jun 10, 2009 at 10:57 AM, Susanne Neckermann<[hidden email]> 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 userwritten 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/ > * * 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/ 
Thanks to Martin for helpfully spelling out what Suzanne needed to do. This was essentially what I had in mind.
Best wishes Roger Roger B Newson BSc MSc DPhil Lecturer in Medical Statistics Respiratory Epidemiology and Public Health Group National Heart and Lung Institute Imperial College London Royal Brompton Campus Room 33, Emmanuel Kaye Building 1B Manresa Road London SW3 6LR UNITED KINGDOM Tel: +44 (0)20 7352 8121 ext 3381 Fax: +44 (0)20 7351 8322 Email: [hidden email] Web page: http://www.imperial.ac.uk/nhli/r.newson/ Departmental Web page: http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/ Opinions expressed are those of the author, not of the institution. Original Message From: [hidden email] [mailto:[hidden email]] On Behalf Of Martin Weiss Sent: 11 June 2009 15:59 To: [hidden email] Subject: AW: st: test difference in quintiles <> Susanne asked me privately for further advice and also mentioned that she could not figure out the implementation of Roger`s post. From what I understand, the solution proposed by Roger should look like: ************* clear* set obs 10000 capt ssc inst invcise capt ssc inst parmest gen x= rnormal() /* no systematic difference btw groups */ gen byte condition=/* */ runiform()<0.5 /*just to check plausibility of results */ by con, sort : /* */ summarize x, detail statsby N=r(N) p5=r(c_1) /* */ p5min=r(lb_1) p5max=r(ub_1),/* */ by(condition)/* */ clear: centile x, c(5) invcise p5min p5max, /* */ stderr(icse) metaparm [iweight=(cond==1)(cond==0)],/* */ norestore sumvar(N)/* */ estimate(p5) stderr(icse) list, noobs ************* HTH Martin Ursprüngliche Nachricht Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Newson, Roger B Gesendet: Donnerstag, 11. Juni 2009 10:45 An: '[hidden email]' Betreff: RE: st: test difference in quintiles Thanks to Samuel for the promotion. However, cendif computes confidence intervals, not for differences between percentiles, but for percentile differences. These are not exactly the same thing. For a counterexample, see Newson (2008). If Suzanne wants confidence intervals for the differences between 2 5th percentiles for 2 subpopulations, then Suzanne should probably use the centile command to get confidence intervals for the 2 5th percentiles, and then use the invcise package and the metaparm module of the parmest package, downloadable from SSC, to get a confidence interval for the difference between the 2 5th percentiles. The invcise package calculates standard errors using the inverse confidence interval method. I hope this helps. Best wishes Roger References Newson, R. B. HodgesLehmann median differences between exponential subpopulations. Downloadable from http://www.imperial.ac.uk/nhli/r.newson/papers.htm#miscellaneous_documents as from 12 October 2008. Roger B Newson BSc MSc DPhil Lecturer in Medical Statistics Respiratory Epidemiology and Public Health Group National Heart and Lung Institute Imperial College London Royal Brompton Campus Room 33, Emmanuel Kaye Building 1B Manresa Road London SW3 6LR UNITED KINGDOM Tel: +44 (0)20 7352 8121 ext 3381 Fax: +44 (0)20 7351 8322 Email: [hidden email] Web page: http://www.imperial.ac.uk/nhli/r.newson/ Departmental Web page: http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgene tics/reph/ Opinions expressed are those of the author, not of the institution. Original Message From: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email] Sent: 10 June 2009 22:42 To: [hidden email] Subject: Re: st: test difference in quintiles cendif by Roger Newson, is part of the somersd package, downloadable from SSC (type "ssc install somersd". It computes CI's for, and tests, differences between medians. You will need large sample sizes to test the difference between 5th percentiles with reasonable power. What do you mean by "number of observations in the 5th percentile"? You should not group data prior to the analysis. Steve On Wed, Jun 10, 2009 at 10:57 AM, Susanne Neckermann<[hidden email]> 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 userwritten 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/ > * * 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/ * * 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/ 
Powered by Nabble  Edit this page 