BCB744 BioStats 2025 Example 1
Please download the data files required for this exercise from Google Drive (link provided by email). The files include:
tmax.2016.nc
– NetCDF file containing daily maximum temperature data for the year 2016.tmin.2016.nc
– NetCDF file containing daily minimum temperature data for the year 2016.precip.2016.nc
– NetCDF file containing daily precipitation data for the year 2016.- All files in the subdirectory
Studyarea
– shapefiles of the study area.
Instructions
- Load the precipitation data and calculate the mean monthly precipitation from the daily precipitation values, as well as the mean monthly value from the daily
. - Load the temperature data and calculate the mean monthly temperature from the daily
, as well as the mean monthly value from the daily . - Merge temperature and precipitation data into a single data frame.
- Trim (crop) the rainfall and temperature data to the study area as per the shapefile. You are welcome to use NaturalEarth to create a shapefile of the study area, or you can use the shapefile provided in the data files. The shapefile is in the
Studyarea
subdirectory and is calledStudyarea.shp
. - Create a panelled series of plots showing the mean monthly rainfall (Figure 1) and temperature (Figure 2) for each month of the year.
- Use the square rooted mean monthly surfaces for least square linear regression analysis (i.e.
) per grid cell, where represents the square root mean monthly temperature and represents the square root mean monthly rainfall. - Create a new map of the slopes of the per-pixel regressions and indicate which pixels show a trend significantly different from zero based on the the per-pixel p-values (Figure 3).
Hints: The temperature and precipitation data are in NetCDF format. You can use the tidync, terra, stars, or ncdf4 package to read the data. The sf package can be used to manipulate the raster data and shapefiles. I used ddply
in the plyr package to fit the linear model to each grid cell. You can also use the purrr and broom packages to do this the tidy way.
In the end, you should aim to recreate the following figures:
Reuse
Citation
@online{smit,_a._j.,
author = {Smit, A. J.,},
title = {BCB744 {BioStats} 2025 {Example} 1},
url = {http://tangledbank.netlify.app/assessments/examples/BCB744_BioStats_Example_1.html},
langid = {en}
}