Skip to content

Instantly share code, notes, and snippets.

@bbdaniels
Last active February 11, 2020 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbdaniels/5780138528db323233c456c9a03d7c9e to your computer and use it in GitHub Desktop.
Save bbdaniels/5780138528db323233c456c9a03d7c9e to your computer and use it in GitHub Desktop.
Make simple power curves for binary variables
tempname a b c
tw (function 1.4*sqrt((2/x)+(2/x)) , range(300 600) lc(red)) ///
(function 1.4*sqrt((3/x)+(3/(2*x))) , range(300 600) lc(red) lp(dash)) ///
(function sqrt(1/x) , range(300 600) lc(black) ) ///
, yscale(r(0)) ytit(" ") xtit("Number of Providers") ///
title("Within Case") ///
ylab(0 .05 "5p.p." .1 "10p.p." .15 "15p.p." .2 "20p.p.") ///
legend(on c(1) pos(9) ///
order( ///
2 "Minimum Detectable Effect, 2/3 vs 1/3 Sample Split" ///
1 "Minimum Detectable Effect, 50-50 Sample Split" ///
3 "Confidence Interval (+/-) , per Subsample") ///
)
graph save `a' , replace
tw (function 1.4*sqrt((2/x)+(2/x)) , range(600 1200) lc(red)) ///
(function 1.4*sqrt((3/x)+(3/(2*x))) , range(600 1200) lc(red) lp(dash)) ///
(function sqrt(1/x) , range(600 1200) lc(black) ) ///
, yscale(r(0)) ytit(" ") xtit("Number of Providers") ///
title("Between Cases") ///
ylab(0 .05 "5p.p." .1 "10p.p." .15 "15p.p." .2 "20p.p.") ///
xlab(600 "300" 800 "400" 1000 "500" 1200 "600") ///
legend(on c(1) pos(9) ///
order( ///
2 "Minimum Detectable Effect, 2/3 vs 1/3 Sample Split" ///
1 "Minimum Detectable Effect, 50-50 Sample Split" ///
3 "Confidence Interval (+/-) , per Subsample") ///
)
graph save `b' , replace
tw (function 1.4*sqrt((2/x)+(2/x)) , range(1000 2500) lc(red)) ///
(function 1.4*sqrt((3/x)+(3/(2*x))) , range(1000 2500) lc(red) lp(dash)) ///
(function sqrt(1/x) , range(1000 2500) lc(black) ) ///
, yscale(r(0)) ytit(" ") xtit("Number of Interactions") ///
title("Pooled Sample") ///
ylab(0 .05 "5p.p." .1 "10p.p." .15 "15p.p." .2 "20p.p.") ///
legend(on c(1) pos(9) ///
order( ///
2 "Minimum Detectable Effect, 2/3 vs 1/3 Sample Split" ///
1 "Minimum Detectable Effect, 50-50 Sample Split" ///
3 "Confidence Interval (+/-) , per Subsample") ///
)
graph save `c' , replace
grc1leg `a'.gph `b'.gph `c'.gph , r(1)
!rm `a'.gph `b'.gph `c'.gph
// End of power calcs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment