Re: AW: AW: st: Re: graph question

 From Nikolaos Pandis To statalist@hsphsun2.harvard.edu Subject Re: AW: AW: st: Re: graph question Date Mon, 20 Apr 2009 03:59:14 -0700 (PDT)

```Dear Martin,

Great help, thank you!

Would it be possible on the connected line graph, in the same panel, to place the vertical lines  (representing means and cis) one next to the other per interval so they are not overlapping, like in the example you showed me?

Many thanks,

Nick
--- On Mon, 4/20/09, Martin Weiss <martin.weiss1@gmx.de> wrote:

From: Martin Weiss <martin.weiss1@gmx.de>
Subject: AW: AW: st: Re: graph question
To: statalist@hsphsun2.harvard.edu
Date: Monday, April 20, 2009, 11:31 AM

<>

Not sure whether it is possible with a bar chart, and I cannot find an
example of what you want in the Mitchell book cited earlier, but here is a

*************
clear*

qui{
//create data
set obs 600

gen arm= cond(_n<301,0,1)
lab def arms 0 "control" 1 "experimental"
la val arm arms

egen float interval = fill(0 1 3 6 9 12 0 1 3 6 9 12)
egen float measurement = seq(), from(1) to(50) block(6)

//fictional value of measurement (no systematic diff btw control and
experimental group)
gen mymeasurement=rnormal()
}

//check
mean mymeasurement, over(arm interval)

//collapse
collapse (mean) mean=mymeasurement (semean) semean=mymeasurement, by(arm
interval)
gen lb= mean-invnormal(0.975)*semean
gen ub= mean+invnormal(0.975)*semean

//graph
graph dot (asis) mean lb ub, over(arm) over(interval) ///
marker(2, mcolor(dkorange)) marker(3, mcolor(dkorange)) ///
note(95 % Confidence Intervals) legend(order(1 "Mean of Measurement")
rows(1))
*************

HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nikolaos Pandis
Gesendet: Montag, 20. April 2009 10:03
An: statalist@hsphsun2.harvard.edu
Betreff: Re: AW: st: Re: graph question

Dear martin,

Thank you for the super fast response.
I see what you mean about question2
Regarding the bars I was thinking that the ci vertical line would be
extended above and below the horizontal  edge of the bar representing the
mean. I think we see those kind of plots in excel, using the sd.

Best wishes,

Nick
--- On Mon, 4/20/09, Martin Weiss <martin.weiss1@gmx.de> wrote:

From: Martin Weiss <martin.weiss1@gmx.de>
Subject: AW: st: Re: graph question
To: statalist@hsphsun2.harvard.edu
Date: Monday, April 20, 2009, 10:30 AM

<>

For the second question, change the last line to

*************
//graph
twoway (rcap lb ub interval, sort) (connected mean interval), ///
xlabel(0 1 3 6 9 12)  by(arm, note("") legend(off))
*************

What do you imagine for the first question? The range bars would overlap,
and it would be hard to distinguish between them. Just try

*******
//graph
twoway (rcap lb ub interval, sort) (scatter mean interval), ///
xlabel(0 1 3 6 9 12)
*******

Sometimes you can -jitter- data points on a graph to make them more
readable, but I cannot find this option for -rcap-. Mitchell
http://www.stata-press.com/books/vgsg.html describes the same graph type but
is apparently not bothered by the overlap.

As for the bar chart, what do you want it to look like? How can you
represent the CI on a bar chart?

HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nikolaos Pandis
Gesendet: Montag, 20. April 2009 08:39
An: statalist@hsphsun2.harvard.edu
Betreff: Re: st: Re: graph question

Dear Martin,

This was more complicated to follow, and I just have to go over the details
to see the exact sequence.

I was wondering if you would comment on the following:

- Would it be possible to have only one graph instead of two separate panels
of the same graph? This way the two interventions would be next to each
other within the same interval
-How could I connect the means with a line?
-Would it be possible to draw one bar chart with the same information?

Thank you very much.

Best wishes,

Nick
--- On Sun, 4/19/09, Martin Weiss <martin.weiss1@gmx.de> wrote:

From: Martin Weiss <martin.weiss1@gmx.de>
Subject: st: Re: graph question
To: statalist@hsphsun2.harvard.edu
Date: Sunday, April 19, 2009, 8:35 PM

<>

With CIs :-)

***
clear*

qui{
//create data
set obs 600

gen arm= cond(_n<301,0,1)
lab def arms 0 "control" 1 "experimental"
la val arm arms

egen float interval = fill(0 1 3 6 9 12 0 1 3 6 9 12)
egen float measurement = seq(), from(1) to(50) block(6)

//fictional value of measurement (no systematic diff btw control and
experimental group)
gen mymeasurement=rnormal()
}

//check
mean mymeasurement, over(arm interval)

//collapse
collapse (mean) mean=mymeasurement (semean) semean=mymeasurement, by(arm
interval)
gen lb= mean-invnormal(0.975)*semean
gen ub= mean+invnormal(0.975)*semean

//graph
twoway (rcap lb ub interval, sort) (scatter mean interval), ///
xlabel(0 1 3 6 9 12) by(, legend(off)) by(arm, note(""))
****

HTH
Martin
_______________________
----- Original Message ----- From: "Nikolaos Pandis" <npandis@yahoo.com>
To: <statalist@hsphsun2.harvard.edu>
Cc: <npandis@yahoo.com>
Sent: Sunday, April 19, 2009 6:19 PM
Subject: st: graph question

> Hi to all.
>
> I would like to ask the following:
>
> I have continuous data for two trial arms (control and experiment).
> There are 50 measurements per arm.
> Data is collected at 6 time intervals.
>
> I would like to plot a bar chart with the x axis showing the intervals (0,
1, 3, 6, 9, 12 months). Within each interval I would like to have one bar
for the control and one for the experimental group.
> The y axis shows the mean of the measurement of interest.
>
> Additionally, I would like to show the confidence intervals at each
interval per treatment group.
>
> Alternatively, I would like to draw  a line plot with the same y and x
axis information, except that the two lines  would represent the control and
the experimental groups.
>
> Thank you very much,
>
> Nick
>
>
>
> *
> *   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/

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