0

Originally asked on StackOverflow and now brought over here upon recommendation from another commenter.

I'm an undergrad writing a very simple lab report in which I'm analysing some data on observed numbers of birds at two different study sites. I'm using R 4.2.2 to create the code to run the analysis. The exact data frame I'm using was imported off an Excel spreadsheet but I'll replicate the data frame here.

Location <- c(rep("Leighton Moss",6),rep("Eaves Wood",6)
Period<-c(rep(c(rep("Midday",3),rep("Afternoon",3)),2))
Activity<-c(rep(c("Resting","Foraging","Travelling"),4))
Count<-c(88,68,54,30,41,33,13,28,13,55,47,46)

df<-data.frame(Location,Period,Activity,Count)

I want to know if there's an equivalent of Chi-squared test of association for three categorical variables (in this case Location, Period and Activity) as opposed to two. In this instance, Location and Period are acting as predictor variables, and the Activity acted as the Outcome variable, and at each combination of Location and Period I counted the number of birds engaged in each of the three activities.

I ideally want to avoid just doing separate three separate Chi-squared tests for Location vs Activity, Period vs Activity and Location vs Period, but I can do that if push comes to shove.

I think I can build a three-way contingency table like this to help:

[enter image description here

A commenter on StackOverflow (@qdread) suggested using a multinomial model, which does make sense, but I'm not entirely sure how to construct the model to best fit my data and implement said construction in R.

Any help you can offer would be great. Thanks in advance!

  • Welcome to CV, Stejnegers. Your original post was automatically migrated here by an [SO] moderator. This is the preferred way of handling the situation because it reduces duplicates throughout the system and brings along any existing comments (and answers), thereby recognizing the efforts of all who have contributed to your thread and making that information available to future readers. Please take a few minutes with our [help] to learn some of the ins and outs of this site (and other SE sites). – whuber Apr 20 '23 at 21:15

0 Answers0