Hopefully the formula for unequal variance case looks pretty familiar to you. It’s the difference in the means, plus or minus a \(t\) quantile times the standard error. The standard error is calculated assuming there’s a different variance in each of the two groups.
\[ \bar{Y} - \bar{X} \pm t_{df} \Bigg( \frac{s^2_x}{n_x} + \frac{s^2_y}{n_y} \Bigg)^{1/2} \]
It turns out that if the \(x\) observations and the \(y\) observations are \(iid\) normal, potentially with different means and potentially with different variances, the relevant normalized statistic does not follow a \(t\) distribution. Instead, it can be approximated by a \(t\) distribution, where we choose a rather elaborate formula for the degrees of freedom.
\[ df = \frac{(S^2_x/n_x + S^2_y/n_y)^2}{\Big( \frac{S^2_x}{n_x} \Big)^2 / (n_x - 1) + \Big( \frac{S^2_y}{n_y} \Big)^2 / (n_y - 1)} \]
Now no one remembers this degree of freedom calculation, and it’s a very odd calculation, because it just doesn’t involve the sample sizes, but actually the estimated standard deviations and variances from the two groups. Nonetheless, if you plug in this potentially fractional degrees of freedom, you get a \(t\) calculation that very closely approximate the relevant distribution, which is not actually a \(t\) distribution, and it turns out that it works well enough that I can give the statement that when you’re in doubt just use the unequal variance interval.
On this page, I simply show churning through the calculations for the oral contraceptive example from earlier. You might want to go through this calculation just so you can at once convince yourself that you can plug into the standard deviation formula.
Comparing Sistolic Blood Pressure
\(\bar X_{OC} = 132.86\) mmHg with \(S_OC = 15.34\) mmHg
\(\bar X_{C} = 127.44\) mmHg with \(S_C = 18.23\) mmHg
\(df = 15.04\), \(t_{15.04, .975} = 2.13\)
Interval
\[ 132.86 - 127.44 \pm 2.13 \Big( \frac{15.34^2}{8} + \frac{18.23^2}{21} \Big)^{1/2} = [-8.91, 19.75] \]
Typically when we want unequal variance \(t\) tests, we simply use the R command \(t.test\) with \(var.equal = FALSE\), and that will do the relevant \(t\) test with unequal variances and produce the relevant \(t\) quantile with unequal variances.
Let’s summarize what we talked about today. We talked about creating intervals using the \(t\) distribution, some of the handiest intervals in all of statistics. When we have single observations or paired observations for which we’ve taken the difference, we use the \(t\) interval to create intervals that are highly robust to the underlying assumptions regarding the distribution of the data. However, we have talked about a couple of cases where it’s probably preferable to use something other than the \(t\) distribution and \(t\) intervals. For example, we talked about when the data are highly skewed, you may either want to use the \(log\) scale, or look for different procedures. In addition, when your data is binary, you might consider something like looking at odds ratios, which we will cover in our generalized linear model component of the regression class.
For binomial data, there’s lots of way to compare two groups
Relative risk, risk difference, odds ratio.
Chi-squared tests, normal approximations, exact tests.
The same can be said for count data, where we’ll talk about Poisson models and generalized linear models for rates.
For count data, there’s also Chi-squared tests and exact tests.