The Analysis component contains the functions and scripts used to analyze both raw and intermediate data, as well as generate final results.
To access future updates of these analyses, as well as version history, please visit: [https://gitlab.com/wetlandscapes/mountain-vapor-isotopes](https://gitlab.com/wetlandscapes/mountain-vapor-isotopes). The version of code available in this compendium is a snapshot of the analysis when the article was accepted and may not be up-to-date.
@[toc]
## `Functions/`
The Functions directory contains both custom [R](https://cran.r-project.org/) and [Stan](https://mc-stan.org/) functions used in the analysis. Documentation of the functions is not always very good, but the hope is that by sharing the code, these functions might be useful to others trying to perform similar analysis. If there are questions, please contact the maintainer of this compendium, [Jason Mercer](mailto:jasonjmercer@gmail).
## `Scripts/`
The Scripts directory contains R scripts that provide the basic set of instructions for processing the data related to the study. Scripts are numbered to provide an approximate order in which they should be run, for reproducibility purposes, though the exact order is highlighted in a section below.
Scripts typically contain the following sections:
* __Header__: Basic information about the script (purpose, author, etc).
* __Libraries__: The R libraries used in the script.
* __Options__: Any global R options used in the script (e.g. number of cores).
* __Functions__: Code to load functions from the `Functions/` directory, as well as custom functions specific to that script.
* __Load__ (data): The data used in the script.
* __Data manipulation__ (Clean & tidy): Code for coercing data into a format that can then be more easily analyzed.
* __Analysis__ (Analyze): Analysis code.
* __Save__ (Export): Code for saving results from a script. Outputs from a script are given the same number as the script to help track the workflow.
* __Bibliography__: Some bibliographic information used in generating the code, where appropriate.
* __Archive__: Code that was developed, but then not used.
### Order in which scripts are intended to be run
1. 001_Import_Isotope.R
1. 002_Import_AtmosphereWaterIsotopes.R
1. 003_Import_Environmental.R
1. 004_Import_PrecipIsotope.R
1. 005_Analysis_ComparisonPrecipIsotopes.R
1. 0061_DataRetrieval_WISER.R
1. 0062_Import_Analysis_LMWLPriors.R
1. 0063_Import_Analysis_LVLPriors.R
1. 0064_Analysis_AtmosphericVaporError.R
1. 006_Analysis_LLs.R
1. 007_Analysis_PrecipTempAndPhase.R
1. 008_Analysis_VaporPermuting.R
1. 009_Analysis_ProcessingScenarioGeneration.R
1. 010_Analysis_EquilibriumPriors.R
1. 011_Analysis_ExpandedScenarios.R
1. 012_Analysis_ExpandedSelection.R
1. 013_Analysis_CoreBias.R
1. 0141_Analysis_CoreEnvironmentalCovariatesIntercept.R
1. 015_OutputGeneration.R
### Input and output data, by script
Note: References to the `Data/` directory indicate the Data component of this compendium, located in /Resources/Data.
1. 001_Import_Isotope.R
* Input:
* Data/Raw_Text/Isotopes/WaterIsotopes_WilliamsLab_PrecipOnly_2017-11-09.xlsx
* Output:
* Data/Edit_Script/001_precipIsotopes.RData
1. 002_Import_AtmosphereWaterIsotopes.R
* Input:
* Data/Raw_Text/Isotopes/ForestService/LGR.RData
* Data/Raw_Text/Isotopes/ForestService/LGR_2016B_v1_5v2.csv
* Data/Raw_Text/Isotopes/ForestService/LGR_2017A_v1_5v2.csv
* Output:
* Data/Edit_Script/002_AtmosphereWaterIsotopes.RData
* Data/Edit_Script/002_AtmosphereWaterConc.RData
1. 003_Import_Environmental.R
* Input:
* Data/Raw_Text/Environmental/ForestService/GLEES/Data/GLEES_AmeriFlux_WY2005to2014_v2.5.csv
* Data/Raw_Text/Environmental/ForestService/GLEES/Data/GLEES_AmeriFlux_WY2015to2016A_v2.5.csv
* Data/Raw_Text/Environmental/ForestService/GLEES/Data/GLEES_AmeriFlux_2016B_v2.5.csv
* Data/Raw_Text/Environmental/ForestService/GLEES/2017/
* Note: This is a folder of .dat files from Campbell Scientific loggers.
* Data/Raw_Text/Environmental/ForestService/WY95/NTN-WY95-d.csv
* Data/Raw_Text/Environmental/ForestService/WY00/WY00_2014-01-01_2017-01-31.csv
* Output:
* Data/Edit_Script/003_precipWY95.RData
* Data/Edit_Script/003_precipWY95All.RData
* Data/Edit_Script/003_precipWY00.RData
* Data/Edit_Script/003_summer2017GLEES.RData
1. 004_Import_PrecipIsotope.R
* Input:
* Data/Edit_Script/001_precipIsotopes.RData
* Data/Edit_Script/003_precipWY95.RData
* Output:
* Data/Edit_Script/004_IsoPrecipSummary.RData
1. 005_Analysis_ComparisonPrecipIsotopes.R
* Input:
* Data/Edit_Script/001_precipIsotopes.RData
* Output:
* Data/Edit_Script/005_BESTSiteComparison.RData
1. 0061_DataRetrieval_WISER.R
* Output:
* Data/Raw_Text/Isotopes/WISER/Precipitation/WISERDataList.R
* Data/Raw_Text/Isotopes/WISER/Precipitation/
* Note: This is a folder of .xlsx files containing isotope precipitation data from the WISER database.
1. 0062_Import_Analysis_LMWLPriors.R
* Input:
* Data/Raw_Text/Isotopes/WISER/Precipitation/
* Output:
* Data/Edit_Script/0062_WISERCoefs.RData
* Data/Edit_Script/0062_LMWLPriors.RData
1. 0063_Import_Analysis_LVLPriors.R
* Input:
* Data/Raw_Text/Isotopes/SWVID/
* Data/Raw_Text/Isotopes/WISER/Vapor/Wiser_BulkData.xlsx
* Output:
* Data/Edit_Script/0063_VaporCoefs.RData
* Data/Edit_Script/0063_LVLPriors.RData
1. 0064_Analysis_AtmosphericVaporError.R
* Input:
* Data/Edit_Script/002_AtmosphereWaterConc.RData
* Data/Raw_Text/Isotopes/LiteratureReview/measurement_calibration_uncertainty_priors.csv
* Data/Raw_Text/Isotopes/ForestService/GLEESTowerCalibration/CalibrationRMSE.CSV
* Output:
* Data/Edit_Script/0064_H2VaporPredictionPosteriors.Rdata
* Data/Edit_Script/0064_O18VaporPredictionPosteriors.Rdata
2. 006_Analysis_LLs.R
* Input:
* Data/Edit_Script/001_precipIsotopes.RData
* Data/Edit_Script/0062_LMWLPriors.RData
* Data/Edit_Script/008_AtmosphereWaterIsotopesDaily.RData
* Data/Edit_Script/0063_LVLPriors.RData
* Output:
* Data/Edit_Script/006_LMWL.RData
* Data/Edit_Script/006_LVL.RData
1. 007_Analysis_PrecipTempAndPhase.R
* Input:
* Data/Edit_Script/003_summer2017GLEES.RData
* Data/Edit_Script/003_precipWY95.Rdata
* Output:
* Data/Edit_Script/007_GLEESEnv.RData
1. 008_Analysis_VaporPermuting.R
* Input:
* Data/Edit_Script/002_AtmosphereWaterIsotopes.RData
* Data/Edit_Script/002_AtmosphereWaterConc.RData
* Data/Edit_Script/007_GLEESEnv.RData
* Output:
* Data/Edit_Script/008_AtmosphereWaterIsotopesDailyOnly.RData
* Data/Edit_Script/008_AtmosphereWaterIsotopesDaily.RData
* Data/Edit_Script/008_AtmosphereWaterIsotopesWeekly.RData
* Data/Edit_Script/008_AtmosphereWaterIsotopesMonthly.RData
1. 009_Analysis_ProcessingScenarioGeneration.R
* Input:
* Data/Edit_Script/004_IsoPrecipSummary.RData
* Data/Edit_Script/008_AtmosphereWaterIsotopesDaily.RData
* Data/Edit_Script/008_AtmosphereWaterIsotopesWeekly.RData
* Data/Edit_Script/008_AtmosphereWaterIsotopesMonthly.RData
* Output:
* Data/Edit_Script/009_AllIsotopeScenarios.RData
* Data/Edit_Script/009_AllScenarios.RData
1. 010_Analysis_EquilibriumPriors.R
* Input:
* Data/Raw_Text/Isotopes/LiteratureReview/EquilibriumPriors.xlsx
* Output:
* Data/Edit_Script/010_EquilibriumPriors.RData
1. 011_Analysis_ExpandedScenarios.R
* Input:
* Data/Edit_Script/009_AllIsotopeScenarios.RData
* Data/Edit_Script/009_AllScenarios.RData
* Data/Edit_Script/010_EquilibriumPriors.RData
* Output:
* Data/Edit_Script/011_nullExpandedList.RData
* Data/Edit_Script/011_ExpandedLOO.RData
* Data/Edit_Script/011_nullExpandedLOO.RData
* Data/Edit_Script/011_ExpandedRMSE.RData
* Data/Edit_Script/011_NullExpandedRMSE.RData
* Data/Edit_Script/ExpandedScenarios/
* Note: This is a folder of Stan outputs.
1. 012_Analysis_ExpandedSelection.R
* Input:
* Data/Edit_Script/011_ExpandedLOO.RData
* Data/Edit_Script/011_nullExpandedLOO.RData
* Data/Edit_Script/011_ExpandedRMSE.RData
* Data/Edit_Script/009_AllIsotopeScenarios.RData
* Data/Edit_Script/009_AllScenarios.RData
* Output:
* Data/Edit_Script/012_RandomForestParameters.RData
* Data/Edit_Script/012_RandomForestConfusionMatrix.RData
* Data/Edit_Script/012_LOOSummary.RData
* Data/Edit_Script/012_CoreIsotopeScenarios.RData
* Data/Edit_Script/012_CoreScenarios.RData
* Data/Edit_Script/012_CoreSummaryParameters.RData
1. 013_Analysis_CoreBias.R
* Input:
* Data/Edit_Script/012_CoreIsotopeScenarios.RData
* Data/Edit_Script/012_CoreScenarios.RData
* Data/Edit_Script/010_EquilibriumPriors.RData
* Output:
* Data/Edit_Script/013_coreList.RData
* Data/Edit_Script/013_coreParameters.RData
1. 0141_Analysis_CoreEnvironmentalCovariatesIntercept.R
* Input:
* Data/Edit_Script/009_AllIsotopeScenarios.RData
* Data/Edit_Script/009_AllScenarios.RData
* Data/Edit_Script/010_EquilibriumPriors.RData
* Data/Edit_Script/0064_H2VaporPredictionPosteriors.Rdata
* Data/Edit_Script/0064_O18VaporPredictionPosteriors.Rdata
* Output:
* Data/Edit_Script/0141_EnvCovariateModels.RData
* Data/Edit_Script/0141_EnvCovariateSelected.RData
* Data/Edit_Script/0141_EnvCovariateData.RData
* Data/Edit_Script/CrossValidation/
* Note: Folder of results.
1. 015_OutputGeneration.R
## Computing environment
Code was executed on a Windows 10 machine. Various versions of R were used during the analysis, though we tried to indicate which version was used. Unfortunately, library versions were not recorded. We also do not provide setup instructions for some more complicated libraries (e.g.,`Stan` and `rstan`).