I'm conducting a hypothesis test for the difference between two groups. The file dat1
contains all observations of measure
for the first group; dat2
contains all observations of measure
for the second group. Measures of both groups are normally distributed, so a parametric test is appropriate. The code for a student's t-test would look like this:
ttest1 <- t.test(x = dat1$measure, y = dat2$measure, alternative
= "two.sided", var.equal = TRUE)
But a Levene test indicates that the groups have differing variances, so the t-statistic needs to be adjusted. So the code looks like this:
ttest2 <- t.test(x = dat1$measure, y = dat2$measure, alternative
= "two.sided", var.equal = FALSE)
But I need to weight each observation. I can produce a weighted student's t-test using the wtd.t.test()
function in the weights
package:
ttest3 <- wtd.t.test(x = dat1$measure, y = dat2$measure,
weight = dat1$weight, weighty =
dat2$weight, alternative = "two.tailed")
But there is no var.equal
argument that would allow me to use the Welch adjustment to correct for concerns about different variances. I have not been able to find another package that facilitates such a test.
Is there a package that allows for this? If not, I need to figure out how to write a function that has this feature.