#### AllSeasons: Execute all paper code #### ## Author: Dr Peter King (p.king1@leeds.ac.uk) ## Last change: 16/10/2025 ## Changes: # - Updating script numbers + descriptions # ****************************************************************** # Replication Information: #### # ****************************************************************** # ─ Session info ───────────────────────────────────────────────────── # setting value # version R version 4.5.0 (2025-04-11 ucrt) # os Windows 11 x64 (build 22631) # system x86_64, mingw32 # ui RStudio # language (EN) # collate English_United Kingdom.utf8 # ctype English_United Kingdom.utf8 # tz Europe/London # date 2025-10-16 # rstudio 2023.06.2+561 Mountain Hydrangea (desktop) # pandoc NA # quarto ERROR: Unknown command # "TMPDIR=C:/Users/[]/AppData/Local/Temp/Rtmpqi98xo/file68846200121c". # Did you mean command "create-project"? @ C:\\PROGRA~1\\RStudio\\RESOUR~1\\app\\bin\\quarto\\bin\\quarto.exe # # ─ Packages ───────────────────────────────────────────────────────── # ! package * version date (UTC) lib source # abind 1.4-8 2024-09-12 [1] CRAN (R 4.5.0) # AMR * 2.1.1 2023-10-21 [1] CRAN (R 4.5.0) # aod * 1.3.3 2023-12-13 [1] CRAN (R 4.5.0) # apollo * 0.3.5 2025-03-12 [1] CRAN (R 4.5.0) # backports 1.5.0 2024-05-23 [1] CRAN (R 4.5.0) # bgw 0.1.3 2024-03-29 [1] CRAN (R 4.5.0) # broom 1.0.8 2025-03-28 [1] CRAN (R 4.5.0) # car 3.1-3 2024-09-27 [1] CRAN (R 4.5.0) # carData 3.0-5 2022-01-06 [1] CRAN (R 4.5.0) # cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.5.0) # cli 3.6.5 2025-04-23 [1] CRAN (R 4.5.0) # cobalt * 4.6.0 2025-04-15 [1] CRAN (R 4.5.0) # coda 0.19-4.1 2024-01-31 [1] CRAN (R 4.5.0) # crayon 1.5.3 2024-06-20 [1] CRAN (R 4.5.0) # data.table * 1.17.2 2025-05-12 [1] CRAN (R 4.5.0) # dichromat 2.0-0.1 2022-05-02 [1] CRAN (R 4.5.0) # digest 0.6.37 2024-08-19 [1] CRAN (R 4.5.0) # distributional 0.5.0 2024-09-17 [1] CRAN (R 4.5.0) # dplyr * 1.1.4 2023-11-17 [1] CRAN (R 4.5.0) # farver 2.1.2 2024-05-13 [1] CRAN (R 4.5.0) # forcats * 1.0.0 2023-01-29 [1] CRAN (R 4.5.0) # Formula 1.2-5 2023-02-24 [1] CRAN (R 4.5.0) # generics 0.1.4 2025-05-09 [1] CRAN (R 4.5.0) # geosphere * 1.5-20 2024-10-04 [1] CRAN (R 4.5.0) # ggdist * 3.3.3 2025-04-23 [1] CRAN (R 4.5.0) # ggplot2 * 3.5.2 2025-04-09 [1] CRAN (R 4.5.0) # ggridges * 0.5.6 2024-01-23 [1] CRAN (R 4.5.0) # glue 1.8.0 2024-09-30 [1] CRAN (R 4.5.0) # gtable 0.3.6 2024-10-25 [1] CRAN (R 4.5.0) # here * 1.0.1 2020-12-13 [1] CRAN (R 4.5.0) # hms 1.1.3 2023-03-21 [1] CRAN (R 4.5.0) # httr 1.4.7 2023-08-15 [1] CRAN (R 4.5.0) # janitor * 2.2.1 2024-12-22 [1] CRAN (R 4.5.0) # lattice 0.22-7 2025-04-02 [1] CRAN (R 4.5.0) # lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.5.0) # lmtest * 0.9-40 2022-03-21 [1] CRAN (R 4.5.0) # lubridate * 1.9.4 2024-12-08 [1] CRAN (R 4.5.0) # magrittr * 2.0.3 2022-03-30 [1] CRAN (R 4.5.0) # MASS 7.3-65 2025-02-28 [1] CRAN (R 4.5.0) # MatchIt * 4.7.1 2025-03-10 [1] CRAN (R 4.5.0) # Matrix 1.7-3 2025-03-11 [1] CRAN (R 4.5.0) # MatrixModels 0.5-4 2025-03-26 [1] CRAN (R 4.5.0) # matrixStats * 1.5.0 2025-01-07 [1] CRAN (R 4.5.0) # maxLik 1.5-2.1 2024-03-24 [1] CRAN (R 4.5.0) # mcmc 0.9-8 2023-11-16 [1] CRAN (R 4.5.0) # MCMCpack 1.7-1 2024-08-27 [1] CRAN (R 4.5.0) # mded * 0.1-2 2015-04-27 [1] CRAN (R 4.5.0) # miscTools 0.6-28 2023-05-03 [1] CRAN (R 4.5.0) # mnormt 2.1.1 2022-09-26 [1] CRAN (R 4.5.0) # mvtnorm 1.3-3 2025-01-10 [1] CRAN (R 4.5.0) # nlme 3.1-168 2025-03-31 [1] CRAN (R 4.5.0) # numDeriv 2016.8-1.1 2019-06-06 [1] CRAN (R 4.5.0) # pillar 1.10.2 2025-04-05 [1] CRAN (R 4.5.0) # pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.5.0) # plyr 1.8.9 2023-10-02 [1] CRAN (R 4.5.0) # PostcodesioR * 0.3.1 2021-12-01 [1] CRAN (R 4.5.0) # psych * 2.5.3 2025-03-21 [1] CRAN (R 4.5.0) # purrr * 1.0.4 2025-02-05 [1] CRAN (R 4.5.0) # quantreg 6.1 2025-03-10 [1] CRAN (R 4.5.0) # R6 2.6.1 2025-02-15 [1] CRAN (R 4.5.0) # randtoolbox 2.0.5 2024-10-18 [1] CRAN (R 4.5.0) # RColorBrewer * 1.1-3 2022-04-03 [1] CRAN (R 4.5.0) # Rcpp * 1.0.14 2025-01-12 [1] CRAN (R 4.5.0) # D RcppParallel * 5.1.10 2025-01-24 [1] CRAN (R 4.5.0) # readr * 2.1.5 2024-01-10 [1] CRAN (R 4.5.0) # readxl * 1.4.5 2025-03-07 [1] CRAN (R 4.5.0) # reshape2 * 1.4.4 2020-04-09 [1] CRAN (R 4.5.0) # Rfast * 2.1.5.1 2025-03-14 [1] CRAN (R 4.5.0) # rlang 1.1.6 2025-04-11 [1] CRAN (R 4.5.0) # rngWELL 0.10-10 2024-10-17 [1] CRAN (R 4.5.0) # rprojroot 2.0.4 2023-11-05 [1] CRAN (R 4.5.0) # RSGHB 1.2.2 2019-07-03 [1] CRAN (R 4.5.0) # Rsolnp 1.16 2015-12-28 [1] CRAN (R 4.5.0) # rstatix * 0.7.2 2023-02-01 [1] CRAN (R 4.5.0) # rstudioapi 0.17.1 2024-10-22 [1] CRAN (R 4.5.0) # sandwich 3.1-1 2024-09-15 [1] CRAN (R 4.5.0) # scales * 1.4.0 2025-04-24 [1] CRAN (R 4.5.0) # sessioninfo 1.2.3 2025-02-05 [1] CRAN (R 4.5.0) # snakecase 0.11.1 2023-08-27 [1] CRAN (R 4.5.0) # sp 2.2-0 2025-02-01 [1] CRAN (R 4.5.0) # SparseM 1.84-2 2024-07-17 [1] CRAN (R 4.5.0) # stringi 1.8.7 2025-03-27 [1] CRAN (R 4.5.0) # stringr * 1.5.1 2023-11-14 [1] CRAN (R 4.5.0) # survival 3.8-3 2024-12-17 [1] CRAN (R 4.5.0) # tibble * 3.2.1 2023-03-20 [1] CRAN (R 4.5.0) # tidyr * 1.3.1 2024-01-24 [1] CRAN (R 4.5.0) # tidyselect 1.2.1 2024-03-11 [1] CRAN (R 4.5.0) # tidyverse * 2.0.0 2023-02-22 [1] CRAN (R 4.5.0) # timechange 0.3.0 2024-01-18 [1] CRAN (R 4.5.0) # truncnorm 1.0-9 2023-03-20 [1] CRAN (R 4.5.0) # tzdb 0.5.0 2025-03-15 [1] CRAN (R 4.5.0) # udunits2 * 0.13.2.1 2022-03-11 [1] CRAN (R 4.5.0) # vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.5.0) # WeightIt * 1.4.0 2025-02-24 [1] CRAN (R 4.5.0) # withr 3.0.2 2024-10-28 [1] CRAN (R 4.5.0) # zigg * 0.0.2 2025-02-07 [1] CRAN (R 4.5.0) # zoo * 1.8-14 2025-04-10 [1] CRAN (R 4.5.0) # ****************************************************************** # Setup Environment: #### # ****************************************************************** rm(list=ls()) library(apollo) library(tidyverse) library(dplyr) library(magrittr) library(mded) library(here) library(data.table) library(Rfast) library(matrixStats) library(ggplot2) library(ggridges) library(ggdist) library(lmtest) library(readxl) library(psych) library(geosphere) library(PostcodesioR) library(udunits2) library(stringr) library(lubridate) library(reshape2) library(MatchIt) library(WeightIt) library(cobalt) library(AMR) library(janitor) library(stats) library(purrr) library(rstatix) library(aod) library(scales) library(RColorBrewer) # ****************************************************************** # Section 1: Setup Data #### ### Stage Zero: Cleaning and transforming the data # The aim of this stage is to import the raw data from Qualtrics, and clean, transform, and prepare for further analysis. # The datasets used in each script are as such: # 1) "*AllSeasons_SurveyData_NotCleaned_Step0.csv*" --\> "*AllSeasons_SurveyData_CleanedNoSpatial_Step1.csv*" # 2) "*AllSeasons_SurveyData_CleanedNoSpatial_Step1.csv*" --\> "*AllSeasons_SurveyData_NoCE_Step2.csv*" # 3) "*AllSeasons_SurveyData_NoCE_Step2.csv*" --\> "[Season]dataframe_Step3.csv*" AND "database[Season]\_Step1.csv*" # 4) "*database_AllSeasons_Step1.csv*" --\> "*database_AllSeasons_Weighted_Step2.csv*" # ****************************************************************** # The very first step is to import the raw survey data: here("SetupScripts", "01_CleanSurveyData.R") %>% source() # Secondly to import the raw survey data: ## ONLY USE IF DATA HAS SPATIAL DATA ## WILL NOT WORK IF ANONYMISED # here("SetupScripts", "02_SurveyDataAddSpatial.R") %>% source() # Thirdly add the CE information: here("SetupScripts", "03_SurveyDataAddCE.R") %>% source() # Finally calculate balancing weights for the appendix: here("SetupScripts", "04_AddBalancingWeights.R") %>% source() # ****************************************************************** # Section 2: Estimate all choice models #### # ****************************************************************** ### HYPOTHESIS 1: EQUAL PARAMETERS: here("CEModelScripts/H1/Correlated", "05_H1_Winter_PreferenceSpaceModel_Correlated.R") %>% source() here("CEModelScripts/H1/Correlated", "06_H1_Spring_PreferenceSpaceModel_Correlated.R") %>% source() here("CEModelScripts/H1/Correlated", "07_H1_Summer_PreferenceSpaceModel_Correlated.R") %>% source() here("CEModelScripts/H1/Correlated", "08_H1_Autumn_PreferenceSpaceModel_Correlated.R") %>% source() here("CEModelScripts/H1/Correlated", "09_H1_AllSeasons_PreferenceSpaceModel_Correlated.R") %>% source() ### HYPOTHESIS 2: EQUAL SCALE here("CEModelScripts/H2/Correlated", "10_H2_WinterFixed_ScaleModel_FullSample_Correlated_Covariates.R") %>% source() ### HYPOTHESIS 3: EQUAL WTP here("CEModelScripts/H3/Correlated", "11_H3_Winter_WTPSpaceModel_Correlated.R") %>% source() here("CEModelScripts/H3/Correlated", "12_H3_Spring_WTPSpaceModel_Correlated.R") %>% source() here("CEModelScripts/H3/Correlated", "13_H3_Summer_WTPSpaceModel_Correlated.R") %>% source() here("CEModelScripts/H3/Correlated", "14_H3_Autumn_WTPSpaceModel_Correlated.R") %>% source() here("CEModelScripts/H3/Correlated", "15_H3_AllSeasons_WTPSpaceModel_Correlated.R") %>% source() # ****************************************************************** # Section 2B: Estimate all BALANCED choice models #### # ****************************************************************** ### HYPOTHESIS 1: EQUAL PARAMETERS: here("CEModelScripts/H1/Balanced/Correlated", "16_H1_Winter_PreferenceSpaceModel_Correlated_Balanced.R") %>% source() here("CEModelScripts/H1/Balanced/Correlated", "17_H1_Spring_PreferenceSpaceModel_Correlated_Balanced.R") %>% source() here("CEModelScripts/H1/Balanced/Correlated", "18_H1_Summer_PreferenceSpaceModel_Correlated_Balanced.R") %>% source() here("CEModelScripts/H1/Balanced/Correlated", "19_H1_Autumn_PreferenceSpaceModel_Correlated_Balanced.R") %>% source() here("CEModelScripts/H1/Balanced/Correlated", "20_H1_AllSeasons_PreferenceSpaceModel_Correlated_Balanced.R") %>% source() ### HYPOTHESIS 2: EQUAL SCALE here("CEModelScripts/H2/Balanced", "21_H2_WinterFixed_ScaleModel_Balanced.R") %>% source() ### HYPOTHESIS 3: EQUAL WTP here("CEModelScripts/H3/Balanced/Correlated", "22_H3_Winter_WTPSpaceModel_Balanced_Correlated.R") %>% source() here("CEModelScripts/H3/Balanced/Correlated", "23_H3_Spring_WTPSpaceModel_Balanced_Correlated.R") %>% source() here("CEModelScripts/H3/Balanced/Correlated", "24_H3_Summer_WTPSpaceModel_Balanced_Correlated.R") %>% source() here("CEModelScripts/H3/Balanced/Correlated", "25_H3_Autumn_WTPSpaceModel_Balanced_Correlated.R") %>% source() here("CEModelScripts/H3/Balanced/Correlated", "26_H3_AllSeasons_WTPSpaceModel_Balanced_Correlated.R") %>% source() # ****************************************************************** # Section 3: Tables #### # Listed in order of appearance # ****************************************************************** ## Misc tables here("OtherScripts/Tables", "27_H0_TableA1_GTestsVarablesVsWinter.R") %>% source() ## I know Appendix tables first is weird, but we talk about their outputs in the results here("OtherScripts/Tables", "28_H0_TableA2_GTestsVarablesVsSpring.R") %>% source() ## This is the same as above, just changing the comparison from Winter to Spring ### HYPOTHESIS 1: EQUAL PARAMETERS: here("OtherScripts/Tables", "29_H1_Table1_LRtests.R") %>% source() ## Table 1 in-text reporting LR tests here("OtherScripts/Tables", "30_H1_TableA3_LRtests_Balanced.R") %>% source() here("OtherScripts/Tables", "31_H1_TableA4_ModelOutputsCorrelated.R") %>% source() here("OtherScripts/Tables", "32_H1_TableA5_ModelOutputsCorrelated_Balanced.R") %>% source() ### HYPOTHESIS 2: EQUAL SCALE here("OtherScripts/Tables", "33_H2_Table2_Waldtests.R") %>% source() here("OtherScripts/Tables", "34_H2_TableB1_Waldtests_Balanced.R") %>% source() ### HYPOTHESIS 3: EQUAL WTP here("OtherScripts/Tables", "35_H3_SimulateMeans.R") %>% source() ## Very memory intensive here("OtherScripts/Tables", "36_H3_TableC1_WTPSummary.R") %>% source() here("OtherScripts/Tables", "37_H3_TableC2_MWtestsWTP.R") %>% source() here("OtherScripts/Tables", "38_H3_TableC3_WTPSpaceModelOutputs.R") %>% source() here("OtherScripts/Tables", "39_H4_Table3_PoeTestsWTP.R") %>% source() # ****************************************************************** # Section 4: Figures #### # ****************************************************************** here("OtherScripts/Figures/", "40_H0_FigureA1_VisitFrequencyBySeason.R") %>% source() here("OtherScripts/Figures/", "41_H3_Figure2_BoxWhiskersDistributionsWTPBySeason.R") %>% source() here("OtherScripts/Figures/", "42_H2_FigureB1_ScaleVariance.R") %>% source() here("OtherScripts/Figures/", "43_H2_FigureB2_ScaleVarianceVisitFrequency.R") %>% source()