Data and Code for "Climate impacts and adaptation in US dairy systems 1981-2018"

From MaRDI portal
Dataset:6684539



DOI10.5281/zenodo.11509447Zenodo11509447MaRDI QIDQ6684539FDOQ6684539

Dataset published at Zenodo repository.

Bo Markussen, Arne Henningsen, Meredith T. Niles, Ermias Kebreab, Nathaniel D. Mueller, Maria Gisbert-Queral, Angela J. Rigden

Publication date: 9 September 2021

Copyright license: Creative Commons Attribution 4.0 International



This data and code archive provides all the filesthat are necessary to replicate the empirical analyses that are presented inthe paper Climate impacts and adaptation in US dairy systems 1981-2018authored by Maria Gisbert-Queral, Arne Henningsen, Bo Markussen,Meredith T. Niles, Ermias Kebreab, Angela J. Rigden, and Nathaniel D. Muellerand published in Nature Food (2021, DOI: 10.1038/s43016-021-00372-z).The empirical analyses are entirely conducted with the R statistical softwareusing the add-on packages car, data.table, dplyr, ggplot2, grid,gridExtra, lmtest, lubridate, magrittr, nlme, OneR, plyr,pracma, quadprog, readxl, sandwich, tidyr, usfertilizer, and usmap.The R code was written by Maria Gisbert-Queral and Arne Henningsen withassistance from Bo Markussen.Some parts of the data preparation and the analyses require substantialamounts of memory (RAM) and computational power (CPU).Running the entire analysis (all R scripts consecutively) on a laptop computerwith 32 GB physical memory (RAM), 16 GB swap memory, an 8-core Intel Xeon CPUE3-1505M @ 3.00 GHz, and a GNU/Linux/Ubuntu operating system takes around 11 hours.Running some parts in parallel can speed up the computations but bears the riskthat the computations terminate when two or more memory-demanding computationsare executed at the same time. This data and code archive contains the following files and folders: * README Description: text file with this description * flowchart.pdf Description: a PDF file with a flow chart that illustrates how R scripts transformthe raw data files to files that contain generated data sets and intermediate resultsand, finally, to the tables and figures that are presented in the paper. * runAll.sh Description: a (bash) shell script that runs all R scripts in this data andcode archive sequentially and in a suitable order (on computers with a bashshell such as most computers with MacOS, GNU/Linux, or Unix operating systems) * Folder DataRaw Description: folder for raw data files This folder contains the following files: - DataRaw/COWS.xlsx Description: MS-Excel file with the number of cows per county Source: USDA NASS Quickstats Observations: All available counties and years from 2002 to 2012 - DataRaw/milk_state.xlsx Description: MS-Excel file with average monthly milk yields per cow Source: USDA NASS Quickstats Observations: All available states from 1981 to 2018 - DataRaw/TMAX.csv Description: CSV file with daily maximum temperatures Source: PRISM Climate Group (spatially averaged) Observations: All counties from 1981 to 2018 - DataRaw/VPD.csv Description: CSV file with daily maximum vapor pressure deficits Source: PRISM Climate Group (spatially averaged) Observations: All counties from 1981 to 2018 - DataRaw/countynamesandID.csv Description: CSV file with county names, state FIPS codes, and county FIPS codes Source: US Census Bureau Observations: All counties - DataRaw/statecentroids.csv Descriptions: CSV file with latitudes and longitudes of state centroids Source: Generated by Nathan Mueller from Matlab state shapefiles using theMatlab centroid function Observations: All states * Folder DataGenerated Description: folder for data sets that are generated by the R scripts in thisdata and code archive. In order to reproduce our entire analysis from scratch,the files in this folder should be deleted. We provide these generated datafiles so that parts of the analysis can be replicated (e.g., on computers withinsufficient memory to run all parts of the analysis). * Folder Results Description: folder for intermediate results that are generated by the R scriptsin this data and code archive. In order to reproduce our entire analysis fromscratch, the files in this folder should be deleted. We provide theseintermediate results so that parts of the analysis can be replicated (e.g., oncomputers with insufficient memory to run all parts of the analysis). * Folder Figures Description: folder for the figures that are generated by the R scripts in thisdata and code archive and that are presented in our paper. In order to reproduceour entire analysis from scratch, the files in this folder should be deleted.We provide these figures so that people who replicate our analysis can moreeasily compare the figures that they get with the figures that are presentedin our paper.Additionally, this folder contains CSV files with the datathat are required to reproduce the figures. * Folder Tables Description: folder for the tables that are generated by the R scripts in thisdata and code archive and that are presented in our paper. In order to reproduceour entire analysis from scratch, the files in this folder should be deleted.We provide these tables so that people who replicate our analysis can moreeasily compare the tables that they get with the tables that are presentedin our paper. * Folder logFiles Description: the shell script runAll.sh writes the output of each R scriptthat it runs into this folder. We provide these log files so that people whoreplicate our analysis can more easily compare the R output that they get withthe R output that we got. * PrepareCowsData.R Description: R script that imports the raw data set COWS.xlsx and prepares itfor the further analyses * PrepareWeatherData.R Description: R script that imports the raw data sets TMAX.csv, VPD.csv, andcountynamesandID.csv, merges these three data sets, and prepares the datafor the further analyses * PrepareMilkData.R Description: R script that imports the raw data set milk_state.xlsx andprepares it for the further analyses * CalcFrequenciesTHI_Temp.R Description: R script that calculates the frequencies of days with the differentTHI bins and the different temperature bins in each month for each state * CalcAvgTHI.R Description: R script that calculates the average THI in each state * PreparePanelTHI.R Description: R script that creates a state-month panel/longitudinal data setwith exposure to the different THI bins * PreparePanelTemp.R Description: R script that creates a state-month panel/longitudinal data setwith exposure to the different temperature bins * PreparePanelFinal.R Description: R script that creates the state-month panel/longitudinal data setwith all variables (e.g., THI bins, temperature bins, milk yield) that are usedin our statistical analyses * EstimateTrendsTHI.R Description: R script that estimates the trends of the frequencies of thedifferent THI bins within our sampling period for each state in our data set * EstimateModels.R Description: R script that estimates all model specifications that are used forgenerating results that are presented in the paper or for comparing or testingdifferent model specifications * CalcCoefStateYear.R Description: R script that calculates the effects of each THI bin on the milkyield for all combinations of states and years based on our final modelspecification * SearchWeightMonths.R Description: R script that estimates our final model specification withdifferent values of the weight of the temporal component relative to theweight of the spatial component in the temporally and spatially correlatederror term * TestModelSpec.R Description: R script that applies Wald tests and Likelihood-Ratio tests tocompare different model specifications and creates Table S10 * CreateFigure1a.R Description: R script that creates subfigure a of Figure 1 * CreateFigure1b.R Description: R script that creates subfigure b of Figure 1 * CreateFigure2a.R Description: R script that creates subfigure a of Figure 2 * CreateFigure2b.R Description: R script that creates subfigure b of Figure 2 * CreateFigure2c.R Description: R script that creates subfigure c of Figure 2 * CreateFigure3.R Description: R script that creates the subfigures of Figure 3 * CreateFigure4.R Description: R script that creates the subfigures of Figure 4 * CreateFigure5_TableS6.R Description: R script that creates the subfigures of Figure 5 and Table S6 * CreateFigureS1.R Description: R script that creates Figure S1 * CreateFigureS2.R Description: R script that creates Figure S2 * CreateTableS2_S3_S7.R Description: R script that creates Tables S2, S3, and S7 * CreateTableS4_S5.R Description: R script that creates Tables S4 and S5 * CreateTableS8.R Description: R script that creates Table S8 * CreateTableS9.R Description: R script that creates Table S9







This page was built for dataset: Data and Code for "Climate impacts and adaptation in US dairy systems 1981-2018"