2
$\begingroup$

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

$\endgroup$
5
  • 1
    $\begingroup$ With only three observations per period there is not much point in performing a test of normality. Either you can assume normality because of your knowledge of that kind of data or you cannot. The same is true for equal variances. You either have knowledge about the data generation process and can deduct that normality and equal variances are a given, or not. $\endgroup$
    – Bernhard
    Nov 30, 2023 at 13:34
  • $\begingroup$ On a more SO oriented side of things: you can use the t.test function without the Welch correction. Is has an argument var.equal = that you can set to TRUE if you think you can safely assume equal variances. $\endgroup$
    – Bernhard
    Nov 30, 2023 at 13:38
  • $\begingroup$ " is rel. close 2.4 vs 1.1" but you could as well argue, that one is more then twice the other. Your results will only be as true as the assumptions you make are. $\endgroup$
    – Bernhard
    Nov 30, 2023 at 13:40
  • $\begingroup$ What is N? It sounds like it is sample size. But then, what is rate? I think you are probably going to be able to use a much bigger sample size, but it's not clear. $\endgroup$
    – Peter Flom
    Nov 30, 2023 at 14:41
  • $\begingroup$ @PeterFlom N is the sample size for each year in the data. Rate is the percentage of that N that undertook an activity. So say for example for Period 1, Year 2, N=129 of which 11.3% undertook an activity. However I want to compare the mean rate between two period year groups (so testing if the mean rate of period 1 is significantly different from the mean rate of period 2, with each period containing 3 years). $\endgroup$
    – daisy
    Nov 30, 2023 at 18:20

2 Answers 2

2
$\begingroup$

In a comment you wrote

N is the sample size for each year in the data. Rate is the percentage of that N that undertook an activity.

This changes things a lot. Your sample size is not six (one for each year) but N (100 to 200 per year). I think the best approach is then logistic regression, with year as the predictor variable (and, probably, year kept as particular years).

$\endgroup$
1
  • $\begingroup$ But my goal in this analysis is to compare Rate for time period 1 to time period 2, not years individually. I want to know if there is a significant difference in the mean rate of time period 1 compared to the mean rate of time period 2. Would a test comparing their means not be best? $\endgroup$
    – daisy
    Nov 30, 2023 at 18:36
0
$\begingroup$

I would skip the normality tests, and the tests for equal variances, due to too few data points.

I recommend using the Welch Two Sample t-test.

Note that there may be too few data points in the example shown for the t-test as well.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.