authors: S.R. Supp, T.A. Cormier, and C.H. Graham, modified from P.A. Beck
R Code to run the analyses for the hummingbird extreme limits paper.
The code creates the models that investigate how Molt stage (
Molt_model.Rmd), Weight (
arrival in Arizona (
Arrival_model.Rmd) are affected by resource availability (NDVI) and physiological demand
- .Rmd (Rmarkdown) files describe each of the analyses and .html files generated from them.
- The data sets (.rdata files) are kept on a personal computer, for questions, contact C.H. Graham.
- Functions (.r files) called by the code described in the different .Rmd files.
Mexico_CFSR_level1.rdata- stored in shared Dropbox
Mexico_CFSR_level2.rdata- stored in shared Dropbox
Mexico_SOT_level1.rdata- stored in shared Dropbox
Mexico_SOT_level2.rdata- stored in shared Dropbox
Mexico_SOT_level3.rdata- stored in shared Dropbox
NDVI_df.rdata- stored in shared Dropbox
Torpor_df.rdata- stored in shared Dropbox
annual.anom.df.rdata- Winter range (Nov-Mar) climate data from the hummingbird site points
site.dat.rdata- Summarized site data
yearly.catch.stat.rdata- Summarized hummingbird catch data from Arizona, arrival dates as quantiles
yearly.climate.rdata- Summarized climate data, as quantiles, for precip, NDVI, and operative temperature
R Scripts (functions and data preparation)
Calculate_SOT_from_Met.r- contains standard operative temperature calculations
calculate_diffuse_fraction.r- contains diffuse fraction of radiation calculations
Calculate_SOT_from_CFSR_Met.r- makes the dataframe allmet, makes
Mexico_SOT_level3.rdata, uses functions from the above two files (
calculate_diffuse_fraction.r) to calculate Te and Tes, makes some plots of the met and temperature data.
NCEP_CFSR_data_extract_v5.r- a function to summarize extracted data (netcdf files) per day, sum/mean/max/min
compare_years_extracted_CFSR_data.r- uses Mexico CFSR_level2.rdata and makes annual.anom.df.rdata (which is later used to make yearly.climate.rdata)
Make_yearly_enviro_dat.r- code to make yearly.climate.rdata file from the summarized raw data (annual.anom.df.rdata), to be used in the models for the manuscript results
Plot_conditional_effects_interaction_models.r- Used for the models in the Rmd files: code for plotting conditional effects of the interaction models, to plot the effect of x1 on y, in a 2-level regeression model that includes an interaction between x1 and x2, and random varying intercept
plot_yearly_NDVI_cumprecip_series.r- code to plot NDVI and cumulative precipitation over the time series. Figure 3: NDVI, cumulative precipitation, and ENSO
Model_evaluation_v4.r- code for evaluating mixed models and quantile regresstion for the models in the .Rmd files.
- defunct code
Rmd Scripts (generate the main results)
Arrival_model.Rmd- model of Arrival/catch observed in Arizona and how it covaries with energetic demand and resource availability in Mexican wintering grounds
Molt_model.Rmd- model of Molt observed in Arizona and how it covaries with energetic demand and resource availability in Mexican wintering grounds
Weight_model.Rmd- model of Weight observed in Arizona and how it covaries with energetic demand and resource availability in Mexican wintering grounds
Replicating the results from the raw data
To run, check the pathnames in each of the files, make sure you have the required libraries installed, and a copy of the .Rdata files.
- Convert temperature variable in the raw data (
Mexico_CFSR_level2.rdata) into Operative Temperature (
Calculate_SOT_from_CFSR_Met.r). This refers to the scripts
calculate_diffuse_fraction.R. Save as allmet within
Make_yearly_enviro_dat.r. This will create
yearly.climate.rdata, which is summarized from Te.
plot_yearly_NDVI_cumprecip_series.ron the main datafiles to regenerate the main figures, tables, and results for the manuscript.
Contact T.A.C., S.G., or P.S.A.B. for questions related to the code that summarizes the remote sensing data.
contact S.R. Supp