0
$\begingroup$

I have a dataframe in R where each row is an sf-formatted geospatial grid. For each grid, I have the number of venomous snakes and the number of non-venomous snakes seen in that area. I also have data on the diets of birds in each grid area. Specifically, I know how many non-venomous snakes birds ate, and how many venomous snakes birds ate. My goal is to evaluate whether birds are eating fewer venomous snakes than would be expected given their abundance in a given area. That is, are birds avoiding potentially dangerous prey.

See below for an example dataframe (though without the column describing each spatial polygon; I'm not sure how to recreate that for this example).

 df <- data.frame(grid_id = c(1,2,3,4,5),
                  n_venomous = c(50,50,50,50,50),
                  n_non_venomous = c(50,50,50,50,50),
                  n_eat_venomous = c(10, 10, 10, 10, 10),
                  n_eat_non_venomous = c(40, 40, 40, 40, 40))
> df
  grid_id n_venomous n_non_venomous n_eat_venomous n_eat_non_venomous
1       1         50             50             10                 40
2       2         50             50             10                 40
3       3         50             50             10                 40
4       4         50             50             10                 40
5       5         50             50             10                 40

This seems like a relatively simply case of calculating differences between observed and expected values (i.e., if birds weren't choosy, we would expect them to eat 25 venomous and 25 non-venomous snakes in each area). But I imagine I shouldn't just run dozens of individual chi-square tests (I have 50+ different spatial grids). There is also the issue of spatial autocorrelation.

Given my research goal, how should I approach this analysis in R?

$\endgroup$
4
  • $\begingroup$ "...if birds weren't choosy, we would expect them to eat 25 venomous and 25 non-venomous snakes in each area:" Doesn't that assume there are equal numbers of each type of snake? And why would expecting them "not to be choosy" be relevant? -- That's not what your question about "fewer than expected" actually says. It sounds like you first need to think through how to model this situation before you consider whether to test anything. $\endgroup$
    – whuber
    Commented Aug 16, 2023 at 17:20
  • $\begingroup$ I was just referring to the sample data, in which there are indeed equal numbers of each type of snake in each area. Obviously, you are correct that in the real dataset this is not the case! To the latter question, the birds eating fewer venomous snakes than expected is (if my hypothesis holds) a consequence of them being choosy (avoiding dangerous prey). $\endgroup$ Commented Aug 16, 2023 at 18:22
  • $\begingroup$ What do you mean by 50+ different spatial grids - are there 50+ grid polygons (rows in the data frame) or do you have 50+ such data frames that you want to analyze jointly? $\endgroup$
    – Ute
    Commented Aug 17, 2023 at 5:49
  • $\begingroup$ 50+ grid polygons (i.e. rows in the dataframe). $\endgroup$ Commented Aug 17, 2023 at 17:08

0

Your Answer

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