THIS README IS FOR THE GRID_MESH/IRREGULAR_POLYGON_LGCP/IRREGPOLLGCP_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, THERE IS A SUB-DIRECTORY ReLabelledPlots THAT CONTAINS THE SAME .R AND .Rmd CODE WITH SLIGHT ALTERATIONS TO SOME OF THE PLOTS IN THE .R CODE, MOSTLY CAPTIONS AND THEREFORE WERE RE-RUN ONLY TO OUTPUT THESE ALTERRED PLOTS COMMENTING OUT THE OTHER UN-ALTERRED PLOTS SO THEY ARE NOT UNNECESSARILY REPRODUCED.

- GridMeshIrregPolLGCPTradOutput_final.R + GridMeshIrregPolLGCPTradbyMesh.Rmd + GridMeshIrregPolLGCPTradbyGrid.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 require variable values to run the R script functions.
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 to the .Rmd post-run was to include the corrected paths for the files for the source and loading of output.
	-- Outputs: GridMeshIrregPolLGCPTradbyGrid.html and GridMeshIrregPolLGCPTradbyMesh.html which contain some printed tables and plots, the plots created tend to contain be pre-fixed by "IrregPolLGCPTrad*.pdf", except for the coverage of the quantiles, which is just labelled "IrregPolLGCPCoverageby*.pdf" where * is either Grid or Mesh.

- SBC_IrregPolLGCP_Param_final.R + GridMeshIrregPolLGCPSBCParamwFFT.Rmd: these R scripts and R markdowns produce plots and tables for the SBC results for 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. The *wFFT* denotes the use of all of the output data, even if some runs contained more than 10 FFT warnings.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.
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 to the .Rmd post-run was to include the corrected paths for the files for the source and loading of output.
	-- Outputs: GridMeshIrregPolLGCPSBCParamwFFT.html which contains some printed tables and plots, the plots created tend to contain be pre-fixed by "IrregPolLGCPSBC*.pdf", except for the summary statistics which are labelled as "irregpolsumdisttest_paramwErr_by*.pdf" or "irregpoloutsideboundstest_paramwErr_by*.pdf" where * is either Grid or Mesh, and the histograms divergences/non-divergences which are labelled as "irregpolsbcdivergences_paramwErr.pdf" and "irregpolsbcnondivergences_paramwErr.pdf", respectively. If all histograms exhibit divergences then the non-divergences pdf will be empty. Note that as for the *wFFT* in the R markdown title, the *wErr* in the plot titles is due to the inclusion of all outputs, regardless if there were more than 10 FFT warnings. 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_IrregPolLGCP_Latent_final.R + GridMeshIrregPolLGCPSBCLatentwFFT.Rmd: these R scripts and R markdowns produce plots and tables for the mean field SBC results 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 ouputs, while all plots are also saved. The *wFFT* denotes the use of all of the output data, even if some runs contained more than 10 FFT warnings.
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 to the .Rmd post-run was to include the corrected paths for the files for the source and loading of output.
	-- Outputs: GridMeshIrregPolLGCPSBCLatentwFFT.html which contains some printed tables and plots, the plots created for the summary statistics are labelled as "irregpolsumdisttestby*.pdf" or "irregpoloutsideboundstestby*.pdf" where * is either Mesh or Grid and the histograms ``worst'' divergences are labelled as "sbcdivergencesGrid*.pdf" for each grid resolution in the implementation.

- IrregPolTrad_ExtraPlots_final.R, IrregPolSBCParam_ExtraPlots_final.R, IrregPolSBCLatent_ExtraPlots_final.R: these R script produce a few extra plots, such as separate-by-mesh/grid summary statistics for the SBC simulation study. So rather than facetted plots by Mesh or Grid, there are separate .pdf outputs for each Mesh or Grid.
	-- Outputs: these plots for the traditional simulation study take the form "IrregPolLGCPTradErrFFTOnlyMeanby*.pdf" where *=Mesh or Grid. For the SBC simulation study results, these are the summary statistis for the parameters and latent field and have plots suffixed by *Meshi.pdf or *Gridi.pdf where i=1,2,3,4 where smaller i indicates the coarser resolutions of both.

- ParametersforErrors_final.R + IrregGridMeshErrorMeanFieldChecks_final.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 latter R script produces some plots to visualise the mean field and exponentiated mean field that resulted in data for which some errors occurred in our runs, IrregPolMeanFieldandExpMeanFieldforErr.pdf, and those for the time errors that were successfully re-run and placed as warnings, IrregPolMeanFieldandExpMeanFieldforTimeErr.pdf.


ReLabelledPlots SUB-DIRECTORY CONTAINS THE FOLLOWING FILES
 - GridMeshIrregPolLGCPTradOutput_Relabel.R + GridMeshIrregPolLGCPTradbyGrid_Relabel.Rmd + GridMeshIrregPolLGCPTradbyMesh_Relabel.Rmd: these produce a few additional plots with captions and/or titles slightly changed. When the .Rmd files are run only a few of the plots are output, with a majority commented out as we did not require they're reproduction. Any outputs have the suffix _Relabel.pdf attached.

- SBC_IrregPolLGCP_Param_Relabel.R + GridMeshIrregPolLGCPSBCParam_Relabel.Rmd: these produce a few re-labelled plots for the Parameter SBC results, namely the summary statistics plots with altered captions. Any outputs have the suffix _Relabel.pdf attached.

- SBC_IrregPolLGCP_Latent_Relabel.R + GridMeshIrregPolLGCPSBCLatent_Relabel.Rmd: these produce a few re-labelled plots for the Mean Field SBC results, namely the summary statistics with alterred captions. Any outputs have the suffix _Relabel.pdf attached.

- IrregPolTrad_ExtraPlots_Relabel.R: this R script produces re-labelled plots for the traditional simulation study. Any outputs have the suffix _Relabel.pdf attached.

- IrregPolSBCParam_ExtraPlots_Relabel.R: this R script produces additional re-labelled plots for the Parameter SBC results. Any outputs have the suffix _Relabel.pdf attached.

- IrregPolSBCLatent_ExtraPlots_Relabel.R: this R script produces additional re-labelled plots for the mean field SBC results. Any outputs have the suffix _Relabel.pdf attached.


