DOI: 10.5061/dryad.rr4xgxdnq
title: Data and code from: Spatial heterogeneity in density dependence across life-history stages drives the dynamics of a bird metapopulation

description: Density-dependent effects on individual vital rates play a critical role
 in determining a population's equilibrium size and rate of return
 following stochastic disturbances. In fragmented landscapes, spatial
 variation in density dependence across life-history stages causes
 heterogeneity in limitations of population growth, which influences
 extinction-persistence dynamics. As habitat loss leads to increased
 landscape fragmentation, understanding the factors driving variation in
 the strength of density dependence across life-history stages is necessary
 to assess population viability and guide conservation strategies. We
 quantified spatial variation in the strength of density dependence across
 life-history stages in a house sparrow metapopulation encompassing 11
 islands in northern Norway, collected from 1994 to 2022. Our findings
 reveal that increased density negatively affects the demographic
 contributions of individuals to population growth. We found a pronounced
 negative effect of density, especially on survival, which was stronger in
 juveniles than in adults. In contrast, there was no clear impact on
 nestling production. We recorded stronger density dependence on islands
 further from the mainland, likely due to harsher environmental conditions
 during winter. Furthermore, the density dependence of survival was
 stronger in juveniles relative to adults on islands where adult survival
 contributed more to population growth than on islands where juvenile
 survival was more important. This indicates that the strength of density
 dependence at different life-history stages was related to each
 island's average pace-of-life. Thus, this study demonstrates
 potential links between spatial variation in density dependence across
 life-history stages, population dynamics, and life-history evolution.
description: # Data and code from: Spatial heterogeneity in density dependence across
 life-history stages drives the dynamics of a bird metapopulation Dataset
 DOI: [10.5061/dryad.rr4xgxdnq](https://doi.org/10.5061/dryad.rr4xgxdnq) ##
 Description of the data and file structure This field data was collected
 from a metapopulation of house sparrows (*Passer domesticus*) inhabiting
 11 islands off the Helgeland coast in northern Norway. The
 presence-absence data, paired with a genomic pedigree, were used to
 estimate survival and reproduction using generalised linear mixed models
 in a capture-mark-recapture framework. ### Files and variables #### File:
 presence_data_1994_2022_ECY25-1341.txt **Description:**  ##### Variables *
 Year: year of observation * date: date of observation * scriptsex: the sex
 of an individual. For juveniles, this may have been inferred from
 subsequent recapture in the adult stage. NA is "not available".
 NA cells are filled with values from the dataset
 sex_genetically_corrected_ECY25-1341.txt, or are given a random sex, in
 the script "Main model of metapopulation dynamics.R" * Island:
 Observation island, numeric code * Location: Observation island, name *
 stage: Type of observation; nestling inside the nest (at ringing or
 resighting) = "nest". Adult or fledged juvenile identified by
 capture outside the nest (at ringing or resighting) = "capt".
 Adult or fledged juvenile identified by colour rings using visual
 resigthing outside the nest = "obs".  * Least_age: The least
 possible age of an individual. Individuals first ringed as adults were
 assumed to be in their second calendar year. * Least_hatchyear: The least
 possible hatch year of an individual. Individuals first ringed as adults
 were assumed to be in their second calendar year. * ID: The ID of an
 individual bird, specific to this data set and
 "sex_genetically_corrected_ECY25-1341.txt". #### File:
 sex_genetically_corrected_ECY25-1341.txt **Description:**  ##### Variables
 * sex: Genetically estimated sex * ID: The ID of an individual bird,
 specific to this data set and
 "presence_data_1994_2022_ECY25-1341.txt". #### File:
 estimated_pop_sizes_nestling_to_adult_model_with_lurøy_onøy_ECY25-1341.txt
 **Description:**  ##### Variables * Location: Observation island, name *
 Island: Observation island, numeric code * Year: year of observation *
 N_corr: The observed number of adult individuals in a given island and
 year (N_obs), corrected by recapture probability. See main text for
 explanation of methods. * .lower: 90% credible interval of N_corr. Lower
 limit * .upper: 90% credible interval of N_corr. Upper limit * .width: The
 credible interval (90 %) * N_obs: The observed number of adult individuals
 in a given island and year #### File:
 cleaned_density_dependence_data_ECY25-1341.txt **Description:**  #####
 Variables * Year_ID_Location: year of observation, ID of individual bird
 (specific to this dataset) and observation island name * Year_ID: year of
 observation, ID of individual bird (specific to this dataset) * ID: ID of
 individual bird (specific to this dataset) * Year_Location: year of
 observation and observation island name * Year: year of observation *
 Location: observation island name * Island: observation island numeric
 code * Least_age: The least possible age of an individual. Individuals
 first ringed as adults were assumed to be in their second calendar year. *
 Least_hatchyear: The least possible hatch year of an individual.
 Individuals first ringed as adults were assumed to be in their second
 calendar year * filled: Indicates if presence has been inferred from
 subsequent recapture in a following year, or from genetic presence (the
 individual was registered with offspring but not seen) = 1. The individual
 was physically observed/capture = 0. * obs: Type of observation; Adult or
 fledged juvenile identified by colour rings using visual resigthing
 outside the nest = "obs". NA is not available. Each row has at
 least one cell with non-NA for the columns obs, capt or gene_new. *
 capt: Type of observation; Adult or fledged juvenile identified by capture
 outside the nest (at ringing or resighting) = "capt". NA is not
 available. Each row has at least one cell with non-NA for the columns obs,
 capt or gene_new. * gene_new: Indicates if presence has been inferred from
 genetic presence (the individual was registered with offspring but not
 seen) = 1. The individual was physically observed/captured = 0. NA is not
 available. Each row has at least one cell with non-NA for the columns obs,
 capt or gene_new. * sex: The sex of an individual. Estimated by plumage or
 genetically. * Own_survival: Indicates if an individual survived (was
 registered) in the following year = 1. Not registered in the following
 year = 0. * N_Recruits: The number of offspring produced by an individual
 in the present year that survived to recruitment in the following year. *
 r2s: The individual demographic contribution = N_Recruits +
 2*Own_survival. * in_out: Indicates if an island belongs to the
 "outer system" = 0 or "inner system" = 1. #### File:
 nestling_producers_2007_2014_ECY25-1341.txt **Description:**  #####
 Variables * Year_ID_Location: year of observation, ID of individual bird
 (specific to this dataset) and observation island name * Year_ID: year of
 observation, ID of individual bird (specific to this dataset) * ID: ID of
 individual bird (specific to this dataset) * Year_Location: year of
 observation and observation island name * Year: year of observation *
 Location: observation island name * Island: observation island numeric
 code * Least_age: The least possible age of an individual. Individuals
 first ringed as adults were assumed to be in their second calendar year. *
 Least_age_sq: Least_age squared * Least_hatchyear: The least possible
 hatch year of an individual. Individuals first ringed as adults were
 assumed to be in their second calendar year. * filled: Indicates if
 presence has been inferred from subsequent recapture in a following year,
 or from genetic presence (the individual was registered with offspring but
 not seen) = 1. The individual was physically observed/capture = 0. *
 obs: Type of observation; Adult or fledged juvenile identified by colour
 rings using visual resigthing outside the nest = "obs". NA is
 not available. Each row has at least one cell with non-NA for the columns
 obs, capt or gene_new. * capt: Type of observation; Adult or fledged
 juvenile identified by capture outside the nest (at ringing or resighting)
 = "capt". NA is not available. Each row has at least one cell
 with non-NA for the columns obs, capt or gene_new. * gene_new: Indicates
 if presence has been inferred from genetic presence (the individual was
 registered with offspring but not seen) = 1. The individual was physically
 observed/captured = 0. NA is not available. Each row has at least one cell
 with non-NA for the columns obs, capt or gene_new. * Own_survival:
 Indicates if an individual survived (was registered) in the following year
 = 1. Not registered in the following year = 0. * in_out: Indicates if an
 island belongs to the "outer system" = 0 or "inner
 system" = 1. * sex: The sex of an individual. Estimated by plumage or
 genetically. * N_nestlings: The number of nesltings produced by an
 individual in the present year. * N_Recruits: The number of offspring
 produced by an individual in the present year that survived to recruitment
 in the following year. * r2s: The individual demographic contribution
 = N_Recruits + 2*Own_survival. #### File:
 juvenile_to_ad_surival_histories_long_ECY25-1341.txt **Description:** 
 ##### Variables * ID: ID of individual bird (specific to this dataset) *
 lifestage: The life-history stage of a bird at observation:
 "nest" = nestling. "fledge" = fledged juvenile.
 "recruit" = second calendar year adult. "adult" =
 third calendare year adult or older. * Year: year of observation *
 Location: observation island name * Island: observation island numeric
 code ## Code/software R (version 4.0.5 ) and Stan (version 2.32.2) were
 used to analyse this data.  R packages needed: library(Matrix)
 library(tidyverse) library(brms) library(lme4) library(rstan) library(arm)
 library(parallel) library(shinystan) library(writexl) library(arm)
 library(tidybayes) library(tables) library(knitr) library(kableExtra)
 library(xtable) 
 
 Scripts should be run in this order: *
 Main_model_of_metapopulation_dynamics_ECY25-1341.R -
 Juvenile_mark-recapture_ECY25-1341.R - Analyses_in_brms_ECY25-1341.R *
 Tables_and_figures_submission_2_ECY25-1341.R * **Stan scripts - called by
 the two first R scripts:** *
 CMR_nest_to_ad_dispersers_ELASTICITY_gen_quant_block_ECY25-1341.stan -
 CMR_juvenile_to_adult_one_ind_per_isl_full_model_ECY25-1341.stan * **The
 below scripts are functions called
 by Tables_and_figures_submission_2_ECY25-1341.R to produce tables and
 figures:** * brm2table_short_ECY25-1341.R * CMR2table_adults_ECY25-1341.R
 * CMR2table_juveniles_ECY25-1341.R *
 Functions_to_generate_tables_and_figures_from_stan_and_brms_outputs_ECY25-1341.R * Parameter_to_latex_ECY25-1341.csv: translates model parameter names to names that appear in tables. Scripts are also located at:  [https://github.com/torhanssonfrank/DensityRegulationHouseSparrows/tree/main/R%20scripts](https://github.com/torhanssonfrank/DensityRegulationHouseSparrows/tree/main/R%20scripts) 
 
 ## Access information Other publicly accessible locations of the data: *
 [https://github.com/torhanssonfrank/DensityRegulationHouseSparrows/tree/main/Data](https://github.com/torhanssonfrank/DensityRegulationHouseSparrows/tree/main/Data)