I'm looking for some guidance on which type of t-test is most suitable to use for my data.
I want to compare the means of the variable 'Rate' between two groups in my data. I have 6 years of data and I want to split them into two periods and then compare the means of the two periods. Each year has a different sample size (N) and a corresponding Rate measurement. Below is some code to that generates the sample data in R:
Period <- c(1,1,1,2,2,2)
Year <- c(1,2,3,4,5,6)
N <- c(110,129,105,189,168,194)
Rate <- c(12.8,11.3,9.7,10.2,8.3,8.4)
sample_data <- cbind(Period, Year, N, Rate)
sample_data <- as.data.frame(sample_data)
So I want to compare the means of 'Rate' between periods 1 and 2 in my data. Because there is 3 observations of Rate in each of my respective periods, the sample size is small so I thought a t-test would be most appropriate to compare the means between the two periods.
When I calculated the t-test by hand I used the formula for two independent means, two-sided. This resulted in a t-stat of 2.115 with a p-value of 0.102. However when i used the t.test() function in R on my data it uses a Welch Two Sample t-test and calculates the t-stat at 2.115 with a p-value of 0.1106.
t.test(sample_data$Rate[1:3],sample_data$Rate[4:6])
My question is, is a t-test the correct test to be using on my data and if so which form of the test is best?
I know there are assumptions to be satisfied for t-tests:
- Data are continuous (Check)
- Data are normally distributed (I conducted a Shapiro-Wilk test in R and the p-value was greater than 0.05 suggesting the distribution of Rate is normal)
- Data are independent (I think this is the case for the two different year periods being independent)
Then there is the case of homogeneity of variance. I know the two independent t-test requires equal variance but Welch's t-test does not make this assumption. So which is best for my data? The variance for the sample data for the two periods is rel. close 2.4 vs 1.1
Any help would be appreciated, Thanks
t.test
function without the Welch correction. Is has an argumentvar.equal =
that you can set toTRUE
if you think you can safely assume equal variances. $\endgroup$