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: plotting median and its confidence interval


From   "Roger B. Newson" <[email protected]>
To   [email protected]
Subject   Re: st: plotting median and its confidence interval
Date   Tue, 21 Jan 2014 18:49:12 +0000

Hi Alfonso

For -rcentile- to work, you also need to download the packages -somersd-, -expgen- and -scsomersd-, which are also on SSC. The -sccendif- command is part of the -scsomersd- package.

I hope this helps. Let me know if you have any further queries.

Best wishes

Roger

Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology, Occupational Medicine
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: [email protected]
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.

On 21/01/2014 15:13, Alfonso Sánchez-Peñalver wrote:
Hi Roger,

I just followed your suggestion, and when using -rcentile- in the way you described on the auto data, I get the following message:

unrecognized command:  sccendif

I am using Stata 13.1 January 15 2014 revision for Mac.

Best,

Alfonso

On Jan 21, 2014, at 8:10 AM, Roger B. Newson <[email protected]> wrote:

A possible alternative might be to use -rcentile- followed by -xsvmat-, instead of -bpmedian- followed by -parmest-. The -rcentile- and -xsvmat- packages can be downloaded from SSC. -rcentile- has the advantage that the confidence intervals are asymmetric, unlike the ones from -bpmedian- and -parmest-, which are symmetric. I would expect the asymmetric confidence intervals from -rcentile- to have a coverage probability closer to the advertized level than the symmetric confidence intervals produced by -bpmedian-. And the -rcentile- package can have -cluster()- options and weights, which are not implemented for -bpmedian-.

An example in the -auto- data might be:

rcentile weight, tdist
xsvmat, from(r(cimat)) name(col) norestore

which will create a dataset with 1 observation and variables Percent, Centile, Minimum and Maximum, containing a percent (defaulting to 50), a median, and its lower and upper confidence limits. You can append several datasets like this and then use -eclplot- (also downloadable from SSC) to plot the confidence intervals against any variable you like.

I hope this helps.

Best wishes

Roger

Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology, Occupational Medicine
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: [email protected]
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.

On 21/01/2014 12:33, XU XIAO wrote:
Hi,

I am treating the data which have 3 time points, say 1965, 1985, 1995. Also, I have a bunch of vars on each time point.


var1 | var2 | var3———var8 | characteristic_vars | year
1
2
3
4
.
.
.

Now, since there is some skewness in the data, I want to plot the medians and their confidence intervals for different groups(based on the characteristic) in each year, and connect the median with a line. Basically, I want to see how the medians of these vars of different groups changed as time went by (going through the 3 time points).

What I have tried was:
1. use .bpmedian to find median and ci for one var of one group
2. use .parmest to save it into a dataset
3. do it for each year
4. append the 3 datasets i got from the previous steps
5. use serrbar to plot it
After 5 steps, I got the plot for 1 var of 1 group, but I have 30 groups.

Is there any easier way to do it? I mean, is there something like ciplot but plotting median and ci of the median instead? Also, how can I show several vars in one plot like what we can do in ciplot?

I am looking forward to your reply,
Respectfully yours,

Xu

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


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