#### Stated preferences for the colours, smells and sounds of biodiversity ############### # Project: ERC Relate Project. Work Package 5 # Author: Dr Peter King (p.king1@leeds.ac.uk) # Function: To list all the replication files in one place # Notes: everything is prefixed 'winter' for a reason # Last Edited: 28/09/2024 # - double-checking post R2 # - updating sessioninfo() # ********************************************************************************** #### Section 0: Setting up #### ## NOTES: This is just importing packages. # ********************************************************************************** ## For laptop Rstudio NOT HPC ## sessionInfo()----------------------------------------------------------------- # R version 4.4.1 (2024-06-14 ucrt) # Platform: x86_64-w64-mingw32/x64 # Running under: Windows 11 x64 (build 22631) # Matrix products: default # locale: # [1] C # system code page: 65001 # time zone: Europe/London # tzcode source: internal # attached base packages: # [1] stats graphics grDevices utils datasets methods base # other attached packages: # [1] ggdist_3.3.2 stringi_1.8.4 sf_1.0-16 # [4] udunits2_0.13.2.1 PostcodesioR_0.3.1 geosphere_1.5-18 # [7] psych_2.4.3 readxl_1.4.3 coin_1.4-3 # [10] survival_3.7-0 Rfast_2.1.0 RcppParallel_5.1.7 # [13] RcppZiggurat_0.1.6 Rcpp_1.0.12 lubridate_1.9.3 # [16] forcats_1.0.0 stringr_1.5.1 purrr_1.0.2 # [19] readr_2.1.5 tidyr_1.3.1 tibble_3.2.1 # [22] tidyverse_2.0.0 RColorBrewer_1.1-3 data.table_1.15.4 # [25] here_1.0.1 mded_0.1-2 reshape2_1.4.4 # [28] ggridges_0.5.6 ggplot2_3.5.1 magrittr_2.0.3 # [31] dplyr_1.1.4 apollo_0.3.3 # loaded via a namespace (and not attached): # [1] DBI_1.2.3 mnormt_2.1.1 sandwich_3.1-0 # [4] rlang_1.1.4 multcomp_1.4-25 e1071_1.7-14 # [7] matrixStats_1.3.0 compiler_4.4.1 systemfonts_1.1.0 # [10] vctrs_0.6.5 quantreg_5.98 pkgconfig_2.0.3 # [13] backports_1.5.0 mcmc_0.9-8 utf8_1.2.4 # [16] tzdb_0.4.0 miscTools_0.6-28 ragg_1.3.2 # [19] MatrixModels_0.5-3 modeltools_0.2-23 Deriv_4.1.3 # [22] broom_1.0.6 parallel_4.4.1 R6_2.5.1 # [25] Rsolnp_1.16 car_3.1-2 cellranger_1.1.0 # [28] numDeriv_2016.8-1.1 zoo_1.8-12 rngWELL_0.10-9 # [31] Matrix_1.7-0 splines_4.4.1 timechange_0.3.0 # [34] tidyselect_1.2.1 rstudioapi_0.16.0 abind_1.4-5 # [37] maxLik_1.5-2.1 codetools_0.2-20 lattice_0.22-6 # [40] plyr_1.8.9 withr_3.0.0 coda_0.19-4.1 # [43] RSGHB_1.2.2 units_0.8-5 proxy_0.4-27 # [46] pillar_1.9.0 carData_3.0-5 KernSmooth_2.23-24 # [49] stats4_4.4.1 distributional_0.4.0 generics_0.1.3 # [52] rprojroot_2.0.4 sp_2.1-4 truncnorm_1.0-9 # [55] hms_1.1.3 munsell_0.5.1 scales_1.3.0 # [58] randtoolbox_2.0.4 class_7.3-22 glue_1.7.0 # [61] tools_4.4.1 SparseM_1.83 mvtnorm_1.2-5 # [64] grid_4.4.1 MCMCpack_1.7-0 libcoin_1.0-10 # [67] colorspace_2.1-0 nlme_3.1-165 cli_3.6.3 # [70] textshaping_0.4.0 fansi_1.0.6 gtable_0.3.5 # [73] rstatix_0.7.2 digest_0.6.35 classInt_0.4-10 # [76] bgw_0.1.3 TH.data_1.1-2 farver_2.1.2 # [79] lifecycle_1.0.4 httr_1.4.7 MASS_7.3-61 ## Libraries here: ----------------------------------------------------------------- ## I think this is all the libraries we actually use library(here) library(magrittr) library(data.table) library(tidyverse) library(readxl) library(psych) library(dplyr) library(geosphere) library(PostcodesioR) library(udunits2) library(sf) library(stringi) library(stringr) library(lubridate) library(reshape2) library(Rfast) library(apollo) library(ggplot2) library(ggridges) library(mded) library(stats) library(coin) library(RColorBrewer) library(tidyr) library(ggdist) # ********************************************************************************** #### Section One: Prepare Data For Analysis #### ## Here, we go from Winter_SurveyData.xlsx -> to Winter_dataframe_Step4.csv ## IMPORTANT: ## ### setup files for Winter_dataframe_Step2.csv and Winter_dataframe_Step3.csv ### are omitted. This is because they used confidential spatial data. ### To deal with this, I provide all the anonymised data in /OtherData/ ### and the ID of those excluded is provided in here("OtherData", "ExcludeList.csv") ### I know this is unusual but what can you do # ********************************************************************************** ## Start by converting raw "SurveyData.xlsx" to cleaned "Winter_dataframe_Step1.csv" here("OtherScripts/Setup", "01_Winter_CleanSurveyData.R") %>% source() ## If you would like to inspect changes from the subsequent cleaning, it is here: # Winter <- here("OtherData","Winter_dataframe_Step2.csv") %>% fread() %>% data.frame() # Winter <- here("OtherData","Winter_dataframe_Step3.csv") %>% fread() %>% data.frame() ## Add spatial data to make "Winter_dataframe_Step3.csv" # here("OtherScripts/Setup", "XX_Winter_AddSpatialData.R") %>% source() # ********************************************************************************** #### Section Two: Run all choice models #### ## Okay, confession time. I noticed post-acceptance so unchangeable. ## Originally, we had Model One and Model Two. ## Then in the first round of revisions, we decided to estimate a third model. ## So ModelThree is third in chronology. ## But it actually has fewer covariates than ModelTwo. ## There may, therefore, be a naming issue despite the results being replicable. ## Please be careful when estimating M2 or M3 as they may have the wrong names # ********************************************************************************** ## Estimate MNL for starting values ## Reported in Table B3 here("CEModelScripts/MNL", "02_Winter_MNL_ModelZero.R") %>% source() ## Table B4 here("CEModelScripts/ModelOne", "03_Winter_MXL_ModelOne_PrefSpace.R") %>% source() here("CEModelScripts/ModelTwo", "04_Winter_MXL_ModelTwo_PrefSpace.R") %>% source() here("CEModelScripts/ModelThree", "05_Winter_MXL_ModelThree_PrefSpace.R") %>% source() # Table B5 here("CEModelScripts/ModelOne", "06_Winter_MXL_ModelOne_WTPSpace.R") %>% source() here("CEModelScripts/ModelTwo", "07_Winter_MXL_ModelTwo_WTPSpace.R") %>% source() here("CEModelScripts/ModelThree", "08_Winter_MXL_ModelThree_WTPSpace.R") %>% source() ## Table B6 here("CEModelScripts/ModelOne", "09_Winter_MXL_ModelOne_WTPSpace_Correlated.R") %>% source() here("CEModelScripts/ModelTwo", "10_Winter_MXL_ModelTwo_WTPSpace_Correlated.R") %>% source() here("CEModelScripts/ModelThree", "11_Winter_MXL_ModelThree_WTPSpace_Correlated.R") %>% source() ## Table B7 here("CEModelScripts/ModelOne", "12_Winter_MXL_ModelOne_WTPSpace_Correlated_TableB7.R") %>% source() # ********************************************************************************** #### Section Two: Create all outputs from the choice models #### # ********************************************************************************** ## Create table 1 which breaks down and tests the sample versus population here("OtherScripts/Tables", "13_Winter_Table1_SampleTests.R") %>% source() ## Present the Choice Model outputs nicely here("OtherScripts/Tables", "14_Winter_Table1A_ModelOutputs.R") %>% source() here("OtherScripts/Tables", "15_Winter_Table2_ModelOutputs.R") %>% source() ## Misc appendices tables here("OtherScripts/Tables", "16_Winter_TableB8_ModelOutputs.R") %>% source() here("OtherScripts/Tables", "17_Winter_TableB9_WTPSummary.R") %>% source() here("OtherScripts/Tables", "18_Winter_TableB10_Sarrias.R") %>% source() here("OtherScripts", "19_Winter_ConsumerSurplus.R") %>% source() here("OtherScripts/Tables", "20_Winter_TableB11_MWTests_Impairments.R") %>% source() here("OtherScripts/Tables", "21_Winter_TableB12_MWTests_VisitFrequency.R") %>% source() here("OtherScripts/Figures", "22_Winter_FigureB1_Impairments.R") %>% source() here("OtherScripts/Figures", "23_Winter_FigureB2_VisitFrequency.R") %>% source() # XX_Winter_CollinearTests.R #### That's all! #### # **********************************************************************************