Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: detectable alternative/effect size;


From   Steven Samuels <[email protected]>
To   [email protected]
Subject   Re: st: detectable alternative/effect size;
Date   Wed, 17 Sep 2008 08:47:26 -0400

On Sep 16, 2008, at 4:18 PM, Elliott Dasenbrook wrote:
I am trying to calculate the detectable alternative for a dichotomous outcome expressed as a relative risk given my sample size and a power of 0.90; Is there a command/package in STATA that does this? [i saw that this can be calculated for Cox proportions] The sampsi command only allows calculation of power or sample size as far as I can tell;

Here is a do file which will calculate minimum detectable RR for a series of baseline values for the smaller probability for power =90% and 2-sided alpha =.05. The code uses the angular transformation to stabilize the variance. I added a purely ad-hoc continuity correction to bring the actual power to detect the "minimum detectable" differences closer to the 90%, so use at your own risk. (Use -sampsi- to see the actual power to detect the listed "minimum- detectable" alternatives. Be sure to zap gremlins before inserting the code into Stata.


*******************Code Starts******************************
/* File minimum detectable risks for test of proportion:
H0: P= P0 H1: P=P1>P02 2-sided 0.05 test Power =90%
Uses the angular (arcsine) transformation to stabilize variances.
A purely ad-hoc continuity correction is added to make the power
closer to the nominal value of 90%*/
clear
capture drop _all

set obs 1
// Set up initial values
local n1 = 200 //Set sample sizes per group
local n2 = 200
local base_val .05 .1 .15 .2 .3 // list of values for smaller proportion P0

local power = 0.90
local alpha=.05

local zz = (invnorm(1-`alpha'/2) + invnorm(`power'))
local se = 0.5*(1/`n1' + 1/`n2')^.5
local delta= `zz'*`se' //Detectable difference on Z scale


foreach x of numlist 1 {
di _newline(1) _col(12) " N1 = " `n1' _col(25) "N2 = " `n2' ///
_newline _col(5) "P0" _col(15) "Min P1" _col(30) "Min Detec RR"
foreach p0 of numlist `base_val'{
local h0 = asin(sqrt(`p0')) // angular transformation
local cc = .75*(1/`n1' +1/`n2') //continuity correction
local h1 = `delta' + `h0' + `cc' // detectable alternative
local p1 = (sin(`h1'))^2 //back transform to proportion
local rr = `p1'/`p0'
di _col(5) round(`p0',.01) _col(15) round(`p1',.001) _col(30) round (`rr',.01)
}
}
***********************Code Ends*****************************


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




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index