Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: RE: RE: generate graph (try 2)

From   Nikolaos Pandis <>
To   "" <>
Subject   Re: st: RE: RE: generate graph (try 2)
Date   Thu, 3 Nov 2011 08:01:23 -0700 (PDT)

Looks great!
I just had to change increments to better serve my needs.
Many thanks.

From: Philip Ryan <>
Sent: Thursday, November 3, 2011 2:05 PM
Subject: RE: st: RE: RE: generate graph (try 2)



Apologies, my mind was on sample size estimation and alphas, whereas it
should have been on testing and p values.

Using the same approach (-post-ing repeated results to produce a new data
set) but with -ttesti- rather than -sampsi-, try this (apologies in advance
if some carriage returns appear missing in what you receive): 

tempname temp_p
local init 8
local incr 2
local final 20
local sd 10
local m1 20
local m2 10

quietly {

postfile `temp_p'  sample_size  pval  using  my_p, replace

forvalues ssiz = `=`init''(`=`incr'')`=`final'' {

ttesti `ssiz' `m1' `sd' `ssiz' `m2' `sd'

post `temp_p ' (r(N_1)) (r(p)) 


postclose `temp_p'


/* now make use of our new data set */

use my_p

list, clean abbrev(16)

graph twoway line  sample_size pval,  ///  
ytitle("sample size in each group")  ///
ylabel(`=`init''(`=`incr'')`=`final'', ang(hor) ) ///
lwidth(medthick) lcolor(red)

*=== end code ===

Philip Ryan
Professor and Director
Data Management & Analysis Centre
School of Population Health & Clinical Practice
University of Adelaide

-----Original Message-----
[] On Behalf Of Nikolaos Pandis
Sent: Thursday, 3 November 2011 9:21 PM
Subject: Re: st: RE: RE: generate graph (try 2)

Dear Phil,

The first piece of code worked well, the second had a minor issue on
the twoway part  probably from copy/paste etc-I fixed it no problem

On a more careful reading of the code, although the graphs have a similar
look to what want, I am wondering if this is not the graph I need.

On the x-axis I would like to show the p-value and how the p-value decreases
for a given effect/sd (effect/sd remain constant) as we increase the sample
size. The idea is to show how interpreting trial results from p-values may
be misleading as you may have an uniportant clinical effect which may be
statistically significant or nonsignificant depending on the sample size
If I unerstood correctly the code you supplied indicates how the sample size
requirements decrease as the a-level changes?

Please advise.

Many thanks,


-----Original Message-----
[] On Behalf Of Nikolaos Pandis
Sent: Thursday, 3 November 2011 5:34 PM
Subject: st: generate graph

Hi to all.
I was wondering if someone could help me generate the following graph:
twoway line graph showing on the y-axis: sample size and on the x-axis:
The objective is to show how the p-value decreases (increases) as the sample
size increases (decreases) given the same effect size and sd
Many thanks,

*  For searches and help try:

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index