-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathsanity.Rd
52 lines (47 loc) · 1.51 KB
/
sanity.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/check.R
\name{sanity}
\alias{sanity}
\title{Sanity check of an sdmTMB model}
\usage{
sanity(object, big_sd_log10 = 2, gradient_thresh = 0.001, silent = FALSE)
}
\arguments{
\item{object}{Fitted model from \code{\link[=sdmTMB]{sdmTMB()}}.}
\item{big_sd_log10}{Value to check size of standard errors against. A value
of 2 would indicate that standard errors greater than \code{10^2} (i.e., 100)
should be flagged.}
\item{gradient_thresh}{Gradient threshold to issue warning.}
\item{silent}{Logical: suppress messages? Useful to set to \code{TRUE} if running
large numbers of models and just interested in returning sanity list
objects.}
}
\value{
An invisible named list of checks.
}
\description{
Sanity check of an sdmTMB model
}
\details{
If \code{object} is \code{NA}, \code{NULL}, or of class \code{"try-error"}, \code{sanity()} will
return \code{FALSE}. This is to facilitate using \code{sanity()} on models with \code{\link[=try]{try()}}
or \code{\link[=tryCatch]{tryCatch()}}. See the examples section.
}
\examples{
fit <- sdmTMB(
present ~ s(depth),
data = pcod_2011, mesh = pcod_mesh_2011,
family = binomial()
)
sanity(fit)
s <- sanity(fit)
s
# If fitting many models in a loop, you may want to wrap
# sdmTMB() in try() to handle errors. sanity() will take an object
# of class "try-error" and return FALSE.
# Here, we will use stop() to simulate a failed sdmTMB() fit:
failed_fit <- try(stop())
s2 <- sanity(failed_fit)
all(unlist(s))
all(unlist(s2))
}