Statistical analyses
We first compared total density and rarefied species diversity, separately for beetles and spiders, between the six predefined flooding categories (wet-wet, wet-dry, wet-wet/dry, dry-dry, dry-wet, dry-wet/dry) using a GLM with negative binomial error distribution for density and with an ANOVA for species diversity. We then modelled total density and diversity in the same way as a function of the local inundation frequency (within the 2x2 m2 pixel) and the proportion of dry pixels at the different scales (6x6 m2 … 26x26 m2) as explanatory variables. For models at each scale, we thereafter calculated pseudo-R2 (density) and R2(diversity) and related these to the scale. The spatial scale with the highest R2 was thereafter selected for further analyses. In the third step, we again modelled total density and rarefied species diversity as a function of the proportion of dry pixels at the optimal scale but in these models, we also included the inundation heterogeneity (at the optimal spatial scale) and environmental factors (vegetation height and soil carbon content) as explanatory variables. These models were simplified by excluding non-significant variables. Finally, we used manyglm from the mvabund (Wang, et al. 2012) to examine community responses (at a family level) as a function of environmental variables and the optimal flooding scale. These analyses were performed separately for beetles and spiders, and we excluded families with few (<20) specimens. Finally, we repeated the analyses using habitat preferences and species traits respectively as response variables. All analyses were performed in R 4.2.2 (R Core Team 2023).