3
$\begingroup$

I am a complete novice in this but just trying to have a go. I have a dataset which has the number of birds in my garden each day for one month in June 2020 and June 2021. I would like to see if there is a significant difference in my total. As far as I can work out, a two-tailed t-test with equal variances would work for this (however, please correct me if I'm wrong).

H0: there is no significant difference between the number of birds visiting my garden in June 2020 and June 2021.

Please could someone help to write the code for this in R?

See photo for data

$\endgroup$
2
  • $\begingroup$ I'm think that that test in Excel is a test of equal variances, not a test of equal means (like what people usually think of two sample t-test). $\endgroup$ Commented Mar 3, 2023 at 16:31
  • $\begingroup$ But it sounds like you are looking for a test of means, or a test for another location measure. It's not clear what you have in mind when you say "difference in my total". $\endgroup$ Commented Mar 3, 2023 at 16:33

1 Answer 1

2
$\begingroup$

In R you can simply do (thanks @COOLSerdash for the remark!)

t.test(Jun20, Jun21, var.equal = TRUE)

but there is a fundamental problem with this approach. Your variables are counts and, for the worse, with quite small numbers. They surely violate the normality assumption behind the t.test.

I would suggest going with a two-sample Poisson (or even better, a negative binomial) test in which you assume the two variables are independently Poisson-distributed with different parameter values.

$\endgroup$
3
  • 1
    $\begingroup$ The default in t.test is to do an unequal (Welch) $t$-test though. The option var.equal = FALSE needs to be added to get the $t$-test with equal variances. $\endgroup$ Commented Mar 3, 2023 at 15:46
  • 2
    $\begingroup$ @COOLSerdash , that is, var.equal = TRUE for equal variances. $\endgroup$ Commented Mar 3, 2023 at 16:26
  • $\begingroup$ @SalMangiafico That's right, my bad. $\endgroup$ Commented Mar 3, 2023 at 17:15

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.