Stan code for a metapopulation model
The metapopulation model considers instream environmental conditions (i.e., for inferring habitat suitability) and landscape connectivity (i.e., via the river network and the terrestrial topography in terms of dispersal tendency among habitats in a long-term perspective), both of which can influence species occurrence at sampling sites (Chiu et al., 2020; DOI: 10.1016/j.scitotenv.2020.144045). Rather than actual measurements of species dispersal (e.g., by using drift and emergence trapping), spatial autocorrelation has been recognized as a robust component in the species distribution model and was adopted to model the dispersal tendency. Dispersal tendency is determined by spatial distance along inter-habitat pathway within the network. For determining the terrestrial connectivity, overland pathways across riverine habitats were created by least-cost path analysis.