Making pointed comparisons between treatment levels in ANOVA
Recall the hypothesis testing recipe. We need, (a) a test statistic and (b) a reference distribution for that statistic. Our best guess at \(\mu_i\) is \(\bar{y}_i\), so a reasonable statistic is, \[ \hat{\Gamma}(c)=\sum_{i=1}^{a} c_{i} \bar{y}_{i} \]
How will we find its reference distribution? Under the null, this statistic is normally distributed with mean 0 and variance, \[ \begin{aligned} \operatorname{Var}(\hat{\Gamma}(c)) &=\sum_{i=1}^{a} c_{i}^{2} \operatorname{Var}\left(\bar{y}_{i}\right) \\ &=\frac{\sigma^{2}}{n} \sum_{i=1}^{a} c_{i}^{2} \end{aligned} \] Standardizing our original statistic, we obtain,
\[\begin{aligned} \frac{\hat{\Gamma}(c)}{\sqrt{\operatorname{Var}(\hat{\Gamma}(c))}} &=\frac{\sum_{i=1}^{a} c_{i} \bar{y}_{i}}{\sqrt{\frac{\sigma^{2}}{n} \sum_{i=1}^{a} c_{i}^{2}}} \\ & \approx \frac{\sum_{i=1}^{a} c_{i} \bar{y}_{i}}{\sqrt{\frac{\hat{\sigma}^{2}}{n} \sum_{i=1}^{a} c_{i}^{2}}} \end{aligned}\]To estimate \(\sigma^2\), we can use \(\hat{\sigma}^2 := MS_E\). This is a good choice, because it remains valid even when the null is untrue.
Since we plugged-in the estimate \(\hat{\sigma}^2\), we have divided our normal distribution by the square root of a chi-square. Therefore, the reference distribution is a t-distribution with \(N - a\) df.
If we make the same computations as above, but without assuming that the null is true, we would find that, \[ \mathbf{P}\left(\frac{\sum_{i=1}^{a} c_{i} \bar{y}_{i}-\sum_{i=1}^{a} c_{i} \mu_{i}}{\sqrt{\frac{\hat{\sigma}^{2}}{n} \sum_{i=1}^{a} c_{i}^{2}}} \in\left[t_{\text {left }}, t_{\text {right }}\right]\right)=0.95 \] where we choose \(t_{\text{left}}\) and \(t_{\text{right}}\) to be the 0.025 and 0.975 quantiles of a \(t\)-distribution with \(N - a\) df.
The resulting confidence interval is, \[ \left[\sum_{i=1}^{a} c_{i} \bar{y}_{i}-t_{\text {right }} \sqrt{\frac{\hat{\sigma}^{2}}{n} \sum_{i=1}^{a} c_{i}^{2}}, \sum_{i=1}^{a} c_{i} \bar{y}_{i}+t_{\text {right }} \sqrt{\left.\frac{\hat{\sigma}^{2}}{n} \sum_{i=1}^{a} c_{i}^{2}\right]}\right. \] This is an explicit formula that you can use in your computations, but don’t let the complexity of the symbols here confuse you. Returning to our original definitions, this is just, \[ \left[\hat{\Gamma}(c)-t_{\mathrm{left}} \sqrt{\widehat{\operatorname{Var}}(\hat{\Gamma}(c))}, \hat{\Gamma}(c)+t_{\mathrm{left}} \sqrt{\widehat{\operatorname{Var}}(\hat{\Gamma}(c))}\right] \] which is our point estimate plus and minus \(t_{\text{left}}\) standard deviations (we’re writing \(\hat{\text{Var}}\) instead of \(\text{Var}\) because we don’t know the true variance and have plugged in the estimate \(\hat{\sigma}^2)\).
fit.contrast
function. The choice c(1, -1, 0, 0)
comes from the fact that we want the difference between the first two power levels (160 and 180) and are ignoring all the rest (the two 0’s at the end).library(gmodels)
contrast <- c(1, -1, 0, 0)
fit.contrast(fit, "power", contrast)
Estimate Std. Error t value Pr(>|t|)
power c=( 1 -1 0 0 ) -36.2 11.55335 -3.133289 0.006416224
attr(,"class")
[1] "fit_contrast"
conf.int
parameter.fit.contrast(fit, "power", contrast, conf.int = 0.95)
Estimate Std. Error t value Pr(>|t|)
power c=( 1 -1 0 0 ) -36.2 11.55335 -3.133289 0.006416224
lower CI upper CI
power c=( 1 -1 0 0 ) -60.69202 -11.70798
attr(,"class")
[1] "fit_contrast"