The null hypothesis of no placebo effect corresponds to the expectation of the change equal to 0 (\(H_0: \Expec(X) = 0\)). The alternative hypothesis may be formulated as the expectation not being equal to 0 (\(H_1: \Expec(X) \not = 0\)). This corresponds to a two sided alternative. Observe that a negative expectation of the change still corresponds to the placebo having an effect.
The observations that can be used in order to test the hypothesis are those associated with patients that were treated with the inactive placebo, i.e. the last 21 observations. We extracts these values from the data frame using the expression βmagnets$change[30:50]".
In order to carry out the test we read the data from the file βmagnets.csv" into the data frame βmagnets". The function βt.test" is applied to the observations extracted from the data frame. Note that the default expectation value of tested by the function is βmu = 0":
##
## One Sample t-test
##
## data: magnets$change[30:50]
## t = 3.1804, df = 20, p-value = 0.004702
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 0.3768845 1.8135916
## sample estimates:
## mean of x
## 1.095238
The computed \(p\)-value is 0.004702, which is below 0.05. Consequently, we reject the null hypothesis and conclude that a placebo effect seems to be present.
We simulate the sampling distribution of the sample average and standard deviation. The sample is composed of \(n=20\) observations from the given Exponential distribution:
lam <- 1/4
n <- 20
X.bar <- rep(0,10^5)
S <- rep(0,10^5)
for(i in 1:10^5) {
X <- rexp(n,lam)
X.bar[i] <- mean(X)
S[i] <- sd(X)
}
T <- (X.bar - 4)/(S/sqrt(n))
mean(abs(T) > qt(0.975,n-1))
## [1] 0.0793
We compute the test statistic βT" from the sample average βX.bar" and the sample standard deviation βS". In the last expression we compute the probability that the absolute value of the test statistic is larger than βqt(0.975,19)", which is the threshold that should be used in order to obtain a significance level of 5% for Normal measurements.
A possible explanation for the difference between the two cases is that the Uniform distribution is symmetric like the Normal distribution, whereas the Exponential is skewed. In any case, for larger sample sizes one may expect the Central Limit Theorem to kick in and produce more satisfactory results, even for the Exponential case.
n <- 55
x.bar <- 22.7
s <- 5.4
t <- (x.bar - 20)/(s/sqrt(n))
abs(t)
qt(0.975,n-1)
## [1] 3.708099
## [1] 2.004879
Observe that the absolute value of the statistic (3.708099) is larger than the threshold for rejection (2.004879). Consequently, we reject the null hypothesis.
Again, the absolute value of the statistic (3.708099) is larger than the threshold for rejection (2.669985). Consequently, we reject the null hypothesis.
The absolute value of the new statistic (1.785381) is smaller than the threshold for rejection (2.004879). Consequently, we do not reject the null hypothesis.