I've been struggling to find a description of an approach to a situation like mine or any R packages that seem capable of handling my needs. I have a large dataset (~80,000 rows) where my dependent variable is 1 or 0, describing the presence/absence of a feature of individual animals observed. There are two components to the non-independence of each observation: observations can come from the same location (a geographic random intercept, characterized by a label for which county the observation comes from) and the observations can come from the same species (nested within genus and family). This results in binomial data, since we often have multiple 1/0 observations for a given location and a given species. I need to model how independent (environmental) variables associated with location influence the probability of 1 vs 0 in the dependent variable, while accounting for the nonindependence of observations from the same location and observations from the same species - I expect species to differ in the proportion of 1 vs 0. Importantly, I cannot collapse observations from the same location into a single value for each location (e.g., 0.70 = proportion of 1's) because there is a critical independent variable (year) that is different for observations from the same location. In other words, I need to retain the individual observations so I can model the observation-level effect in addition to the location-level effect.
A simplified version of the data structure is below to help clarify the issue:
Y | Location | Species | Environmental X | Time |
---|---|---|---|---|
1 | County A | Species 1 | 7 | 1975 |
0 | County A | Species 1 | 7 | 1983 |
1 | County B | Species 1 | 4 | 1967 |
0 | County C | Species 1 | 5.8 | 1952 |
1 | County A | Species 2 | 7 | 1975 |
1 | County D | Species 2 | 9 | 1995 |
0 | County D | Species 2 | 9 | 1946 |
0 | County D | Species 2 | 9 | 1968 |
1 | County E | Species 3 | 2.7 | 1998 |
The independent variable Time should have effects on probability of 1 vs 0 for each observation, observations from the same location are non-independent, and observations for the same species are non-independent (and should be nested in a phylogenetic tree).
Every solution I can find doesn't seem to permit an analysis that contains all these features. I'd appreciate any advice on approaches I should look at that would best be suited for my situation.