
Appendix B: Troubleshooting Error Messages
RSTr-troubleshoot.Rmd
Overview
The initialize_model()
function includes checks to
ensure that all data is set up in a way that the model can use. If the
checks notice something incompatible with the model, an error will be
displayed in the console. Here, we list each possible error for the
MSTCAR model, including its reasoning and ways to check and fix your
inputs.
Generic errors and warnings
All checks that are run on the data check for general information,
such as extraneous list objects which cannot be used by the model. In
these cases, RSTr
will not use these parts of the dataset.
It is recommended to remove these datasets from the model to prevent
unnecessary clutter.
Errors and warnings with list data
One or more objects missing from list 'data'
: Thedata
object requires a list with two objects: an arrayY
for mortality counts and an arrayn
for population counts. These are needed to perform parameter updates inside of the MSTCAR model. Checknames(data)
to see a vector of names that exists inside of your array and fix names accordingly.Data not same dimensions. Ensure dim(Y) == dim(n)
: This error occurs when the arrays fed into thedata
list are not of the same size. Use thedim()
function to check that the dimensions of your two arrays do line up. You can use theaperm()
function to rearrange arrays if they have the same set of dimensions on different margins.Invalid Y/n values. Check that all Y's/n's are at least 0 and finite
: WhileNA
andNULL
are accepted values inY
, bothY
andn
must be comprised of positive finite values. Check your data withsummary()
for a quick look at your minimum values.
Errors and warnings with list spatial_data
Adjacency different length than data. Ensure length(adjacency) == dim(Y)[1]
: Adjacency information must be present for all regions. Look at the length of your adjacency information: it should line up with the number of rows in yourY
andn
arrays.Some regions have no neighbors. Ensure all regions have at least one neighbor
: If a region does not have a neighbor, the model will not run. If working withlist
adjacency information, you can first check which regions have no neighbors by runningwhich(lapply(adjacency, \(x) all(x == 0)))
and then fixing the regions accordingly. For assistance with fixing the adjacency information, readvignette("RSTr-adj")
.
Errors and warnings with list priors
Ag_scale
Ag_scale
is a positive-definite covariance matrix with
size num_group x num_group
. This means that
Ag_scale
:
Must have positive values along its diagonal. Check for zero or negative values along the diagonal with
summary(diag(Ag_scale))
.Must be symmetric. Check that
Ag_scale
is symmetric usingisSymmetric(Ag_scale)
, and if not, you can force symmetry by definingAg_scale
as(Ag_scale + t(Ag_scale)) / 2
.Must not contain infinite values. Check using
which(!is.finite(Ag_scale))
.Must have size
num_group x num_group
, wherenum_group
is the number of groups in the model according to the third margin ofY
andn
. Ifnrow(Ag_scale)
is different thandim(Y)[2]
, then forceAg_scale
into the appropriate size using either thematrix()
orarray()
functions.
G_df
, Ag_df
G_df
and Ag_df
are positive integers that
must be greater than or equal to num_group
, where
num_group
is the number of groups in the model according to
dim(Y)[2]
.
Errors and warnings with list inits
theta
and z
theta
and z
are arrays with sizes identical
to dim(Y)
, with all finite values. Check for potential
infinite values in either of these by using the which()
and
!is.finite()
functions. Note that theta
may be
comprised of log
or logit
-transformed values,
depending on your model choice.
beta
beta
is an array of size
num_island x num_group x num_time
, where
num_island
is the number of contiguous regions known as
“islands” in the model, num_group
is the number of groups
in the model according to dim(Y)[2]
, and
num_time
is the number of time periods in the model
according to dim(Y)[3]
. All values must be finite, which
can be checked using the which()
and
!is.finite()
functions. Note that beta
must be
comprised of log
or logit
-transformed values,
depending on your model choice.
G
G
is a covariance matrix array of size
num_group x num_group x num_time
, where
num_group
is the number of groups in the model according to
dim(Y)[2]
and num_time
is the number of time
periods in the model according to dim(Y)[3]
. Every matrix
slice of G
must be positive definite, following the same
rules as the Ag_scale
prior.
tau2
tau2
is a postive vector of variances of length
num_group
, where num_group
is the number of
groups in the model according to dim(Y)[2]
. Check for
negative or infinite values by using which(tau2 <= 0)
and which(is.finite(tau2))
.
.ignore_checks
If you have input data that you are certain is correct, yet are
receiving error messages anyway, set the .ignore_checks
argument to TRUE
when setting up your model to skip data
checks. This is not recommended as it is easy to break
RSTr
when data isn’t properly checked, and should only be
used as a last resort when using RSTr
.