This repository code contain template code associated with the article "Spatial Confounding in Joint Species Distribution Models" by Francis KC Hui, Quan Vu, and Mevin B Hooten, which is accepted for publication in Methods in Ecology and Evolution.
The following directories are currently available in this repository:
-
simulation
, which contains the following folders/documents for reproducing the simulation results in the manuscript:- A
simdatfnv0.R
script that contains a function for simulating spatial multivariate abundance data from a joint species distribution model assuming some observed and some unobserved covariates; -
simulationexample_coarsescaleX.pdf
andsimulationexample_finescaleX.pdf
, which are the plots available in the manuscript demonstrating a coarse or fine-scaled observed covariate, along with fine or coarse-scaled spatial errors forming the residual component of the unobserved covariates. -
binary_N400
folder, which contains twoR
scripts and two correspondingcpp
scripts for reproducing the simulations involving binary responses,$N = 400$ spatial locations from the Great Britain butterfly data, and either a coarse or fine-scaled observed covariate. The models compared include independent factor analysis, and spatial factor analysis/restricted spatial factor analysis (SFA/RSFA); -
negin_N400
folder, which is set up analogously to thebinary_N400
folder except involving negative binomial count responses instead; -
tweedie_N400
folder, which is set up analogously to thebinary_N400
folder except involving non-negative continuous responses from the Tweedie distribution instead; - A
analysis.R
script for gathering and visualizing the simulation results, after theR
scripts in the above three folders have been run; - A subfolder
plots
containing some of the plots available in the manuscript.
- A
-
application_butterflies
, which contains template scripts to for reproducing the case study results for the Great Britain butterfly data in the manuscript. Also contained are:- Two
cpp
scripts implementing independent factor analysis and spatial factor analysis/restricted spatial factor analysis (SFA/RSFA); these scripts are subsequently passed into TMB for model fitting; - A subfolder
plots
containing some of the plots available in the manuscript.
- Two
-
application_SOCPR
, which contains template scripts to for reproducing the case study results for the Southern Ocean Continuous Plankton Recorder survey data in the manuscript. Also contained are:- Two
cpp
scripts implementing independent factor analysis and spatial factor analysis/restricted spatial factor analysis (SFA/RSFA); these scripts are subsequently passed into TMB for model fitting; - A
socpr_reduced.RData
file that contains contains a synthetic version of the data; - A subfolder
plots
containing some of the plots available in the manuscript.
- Two
The simulation results for R
scripts in the simulation
folder.
If you find something that looks like a bug/issue, please use Github issues and post it up there. As much as possible, please include in the issue:
- A description of the bug/issue;
- Paste-able code along with some comments that reproduces the problem e.g., using the reprex package. If you also have an idea of how to fix the problem, then that is also much appreciated.
- Required data files etc...