One method for assessing the bioavailability of a drug is to note its concentration in blood and/or urine samples at certain periods of time after the drug is given. Suppose we want to compare the concentrations of two types of aspirin (types A and B) in urine specimens taken from the same person 1 hour after he/ she has taken the drug. In this study protocol, a specific dosage of either type A or type B aspirin is given and the urine concentration after 1-hour is measured. One week later, after the first aspirin has presumably been cleared from the system, the same dosage of the other aspirin is given to the same person and the urine concentration after 1-hour is noted. Because the order of giving the drugs may affect the results, a table of random numbers is used to decide which of the two types of aspirin to give first. The concentration will be measured as a percentage, and it is presumed that the standard deviation of the difference between subjects is approximately 3%. Suppose we would like to test whether the mean urine concentration for Aspirin B is less than Aspirin A at an alpha=0.05 level of significance. How many samples would we need to collect such that there would be a 75% chance of correctly rejecting the null hypothesis if the urine concentration of Aspirin B is 1.5% less than that of Aspirin A?
#number of samples for paired t-test, effect=.20 (difference in popluation means is 20% of st. dev.)
library(pwr)
power.t.test(n=NULL, delta = 0.015 , sd =0.03, sig.level=0.05 , power= 0.75, type="paired", alternative = c("one.sided"))
##
## Paired t test power calculation
##
## n = 22.92961
## delta = 0.015
## sd = 0.03
## sig.level = 0.05
## power = 0.75
## alternative = one.sided
##
## NOTE: n is number of *pairs*, sd is std.dev. of *differences* within pairs
We would need 22.9 which approximates to 23 samples
library(pwr)
pwr.t.test(n=NULL,d=-0.5,sig.level=0.01,power=0.85,type="two.sample", alternative ="less")
##
## Two-sample t test power calculation
##
## n = 91.83233
## d = -0.5
## sig.level = 0.01
## power = 0.85
## alternative = less
##
## NOTE: n is number in *each* group
We would need 91.832 in one group which approximates to 92 in each group and 184 samples all togehter