![]() | Content Disclaimer Copyright @2020. All Rights Reserved. |
Links : Home Index (Subjects) Contact StatsToDo
|
Explanations and References
Studies to detect rare events are usually carried out after the introduction
of a new drug or treatment into general use, to exclude the occurrence of unusual adverse events.
These are sometimes called post marketing studies, or Phase IV Trials.
Sample Size Table
The idea is to require all users to report side effects or complications, so that rare adverse outcomes are recorded and dealt with. The sample size represents a count of the number of negative cases that accompany a nominated number of positive cases, assuming the data has a negative binomial distribution, which is very similar to the Poisson distribution. It is calculated with the following parameters.
ReferenceMachin D, Campbell M, Fayers, P, Pinol A (1997) Sample Size Tables for Clinical Studies. Second Ed. Blackwell Science IBSN 0-86542-870-0 p. 144-145
R codess for sample size to detect rare events
fuctions for calculation
FindB <- function(lambda,n,a) # Poisson coefficient
{
b = 0
for(y in 1:a)
{
x = y - 1
b = b + (n * lambda)^x * exp(-n * lambda) / factorial(x)
}
return (b)
}
# interative approximation for the correct sample size nm
SSizAInc <- function(lambda,beta,r)
{
if(r==1)
{
return (-log(beta) / lambda)
}
nL = 2
nR = r * -log(beta) / lambda;
nM = (nL + nR) / 2
bL = FindB(lambda, nL, r) - beta
bR = FindB(lambda, nR, r) - beta
bM = FindB(lambda, nM, r) - beta
if(bL*bR>0)
{
return (0)
}
if(bL*bM>0) { nL = nM } else { nR = nM }
j=0;
while(j<100 & abs(bM)>0.00001)
{
nM = (nL + nR) / 2
bL = FindB(lambda,nL,r) - beta
bM = FindB(lambda,nM,r) - beta
if(bL*bM>0) { nL = nM } else { nR = nM }
j = j + 1
}
return (nM)
}
Main program
# Data entry as a table
myDat = ("
pow lambda r # power, expected proportion, critical tolerance limit
0.90 0.001 1
0.90 0.001 2
0.99 0.002 1
0.99 0.002 3
")
df <- read.table(textConnection(myDat),header=TRUE) # conversion to data frame
df # display input data
# Calculations
ssiz <- vector() # vector (array) to contain sample sizes
for(i in 1:nrow(df))
{
beta = 1 - df$pow[i]
lambda = df$lambda[i]
r = df$r[i]
ssiz <- append(ssiz,ceiling(SSizAInc(lambda,beta,r)))
}
df$SSiz <- ssiz # add sample size column to data frame
df # display input data + sample size calculated
The results are
> df # display input data pow lambda r 1 0.90 0.001 1 2 0.90 0.001 2 3 0.99 0.002 1 4 0.99 0.002 3 > df # display input data + sample size calculated pow lambda r SSiz 1 0.90 0.001 1 2303 2 0.90 0.001 2 3890 3 0.99 0.002 1 2303 4 0.99 0.002 3 4204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
