THIS README IS FOR THE GRID_MESH/REGULAR_POLYGON_LGCP/REGPOLLGCP_ANALYSIS DIRECTORY.

THIS DIRECTORY CONTAINS THE R SCRIPTS THAT CAN PRODUCE PLOTS AND TABLE OUTPUTS FOR THE TWO SIMULATION STUDIES. THERE ARE R MARKDOWNS WHICH WILL RUN THESE R SCRIPTS TO PRODUCE THE REQUIRED OUPUTS. WE ALSO INCLUDE SOME R SCRIPTS WHICH WILL LOOK AT ANY RUNS WHICH PRODUCED ERRORS, IN PARTICULAR THE BEHAVIOUR OF THE FIXED MEAN OF THE MEAN FIELD.

ADDITIONALLY, WE HAVE THE SUB-DIRECTORY ReLabelledPlots WHICH WAS INCLUDED TO PRODUCE ANY ALTERRED PLOTS - WHERE THE ALTERATIONS WERE DUE TO CHANGING THE X OR Y AXIS LABELS, OR THE TITLES.

- GridMeshRegPolLGCPTradOutput_final.R + GridMeshRegPolLGCPTradbyGrid.Rmd + GridMeshRegPolLGCPTradbyMesh.Rmd: this R script contains the code that will take in the output from the traditional simluation study and output plots and tables with summaries of the outputs, including inla() run times, parameter recovery, credible interval coverage as well as any information on the WAIC/DIC (which were not used within the thesis however the code and its output are useful to keep) as well as any errors, FFT warnings, or warnings. The .Rmd file loads the output files and sets up the required variable values to run the R script functions. They also print the outputs from the R script, maybe some plots as well as tables.
NOTE: The .Rmd files have been tidied up and re-run in the original folder, to ensure that the plots would not be re-run needlessly, due to the cache and files stored. Although, one addition post-run was to include the corrected paths for the files for the source and loading of output.
	-- Outputs: GridMeshRegPolLGCPTradbyGrid.html and GridMeshRegPolLGCPTradbyMesh.html which contain some printed tables and plots, the plots created tend to contain be pre-fixed by "RegPolLGCPTrad*.pdf", except for the coverage of the quantiles, which is just labelled "RegPolLGCPCoverageby*.pdf" where * is either Grid or Mesh.

- SBC_RegPolLGCP_Param.R + GridMeshRegPolLGCPSBCParam.Rmd: this R script considers the results for the SBC simulations study related to the parameters of the models and produce summaries, such as plotting all of the histograms for the SBC ranks as well as the summary statistics detailed in Chapter 3. This will also produce outputs for the errors and warnings for the SBC simulation study. Additionally, the histograms are overlayed with the results of the GLMs for the rank frequencies and the histogram plots also include the estimates of these model parameters. As with the traditional simulation study, the .Rmd file sets up the variables and loads the necessary data, printing the summary ouputs, while all plots are also saved.
The .Rmd files have been tidied up and re-run in the original folder, to ensure that the plots would not be re-run needlessly, due to the cache and files stored. Although, one addition post-run was to include the corrected paths for the files for the source and loading of output.
	-- Outputs: GridMeshRegPolLGCPSBCParam.html which contains some printed tables and plots, the plots created tend to contain be pre-fixed by "RegPolLGCPSBC*.pdf", except for the summary statistics which are labelled as "sumdisttest_param.pdf" or "outsideboundstest_param.pdf" and the histograms divergences/non-divergences which are labelled as "sbcdivergences_paramwErr.pdf" and "sbcnondivergences_paramwErr.pdf", respectively. If all histograms exhibit divergences then the non-divergences output will be empty. Note that the `wErr' denotes the inclusion of the simulations which resulted in more than 10 FFT warnings (which are discussed in Chapter 3 and Appendix C of my thesis) rather than excluding them. Not all of the output plots have this included in the filenames, however, the same data is used across all  of the analysis, where we do not exclude any of the runs with >10 warnings.

- SBC_RegPolLGCP_Latent.R + GridMeshRegPolLGCPSBCLatent.Rmd: this R script considers the results for the SBC simulations study related to the mean field and produce summaries, such as plotting the histograms for the SBC ranks, in particular, for each Mesh the "worst" divergent histograms are plotted rather than all of the locations as this wold be extremely unreasonable. The number of "worst" divergent histograms plotted for each mesh are decided by the user in the .Rmd file. Also, the summary statistics across all the grid centres as detailed in Chapter 3 are plotted. Additionally, the histograms are overlayed with the results of the GLMs for the rank frequencies and the histogram plots also include the estimates of these model parameters. As with the traditional simulation study, the .Rmd file sets up the variables and loads the necessary data, printing the summary outputs, while all plots are also saved.
The .Rmd files have been tidied up and re-run in the original folder, to ensure that the plots would not be re-run needlessly, due to the cache and files stored. Although, one addition post-run was to include the corrected paths for the files for the source and loading of output.
	-- Outputs: GridMeshRegPolLGCPSBCLatent.html which contains some printed tables and plots, the plots created for the summary statistics are labelled as "sumdisttestby*.pdf" or "outsideboundstest*.pdf" where * is either Mesh or Grid and the histograms ``worst'' divergences are labelled as "sbcdivergencesGrid*.pdf" for each grid resolution in the example.

- ParametersforErrors.R, GridMeshErrorMeanFieldChecks.R: these two R scripts are meant to briefly investigate the parameters and beahviour of the fixed mean of the latent field that resulted in erroneous outputs. The figures in MeanFieldandExpMeanFieldforErr.pdf contains plots of the fixed mean field and the exponential of this for the parameters which simulated data that resulted in errors for some of our runs.

ReLabelledPlots SUB-DIRECTORY:
THIS CONTAINS THE .R SCRIPTS AND .Rmd FILES TO RE-RUN THE MAIN ANALYSIS PLOTS, WITH THE ADDITIONAL "*_Relabel.*" ADDED IN THE TITLE TO DISTINGUISH. PLOT LABELS THAT REQUIRED CHANGING WERE THE Y-AXIS AND X-AXIS FOR THE SUMMARY STATISTICS PLOTS. THEREFORE, ANY OTHER PLOTS THAT WOULD HAVE BEEN PRODUCED IN THE "*_final.*" FILES THAT WE ARE NOT INTERESTED IN CHANGING THE LABELS FOR, ARE COMMENTED OUT IN THE FILES BELOW SO THAT THEY ARE NOT UNNECESSARILY REPRODUCED AS THEY WILL BE UNUSED.

- GridMeshRegPolLGCPTradOutput_Relabel.R + GridMeshRegPolLGCPTradbyMesh_Relabel.Rmd + GridMeshRegPolLGCPTradbyGrid_Relabel.Rmd: same as before, without the parameter recovery, credible interval coverage, error or DIC/WAIC plots output, only saving the re-plotted average time with (s) to denotes the time unit on the y-axis label. Plots will have the following suffix attached: "*_Relabel.pdf".

- SBC_RegPolLGCP_Param_Relabel.R + GridMeshRegPolLGCPSBCParam_Relabel.Rmd: same as before with label changes for the summary statistics, and commenting out any plots for errors, DIC/WAIC and histograms for the SBC simulations. Plots will have the following suffix attached: "*_Relabel.pdf".

- SBC_RegPolLGCP_Latent_Relabel.R + GridMeshRegPolLGCPSBCLatent_Relabel.Rmd: same as before, although as with the parameter SBC analysis we have changed the y-axis labels for the summary statistics label changes, and commenting out any plots for histograms  Plots will have the following suffix attached: "*_Relabel.pdf".