You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: vignettes/articles/basic-intro.Rmd
+27-23
Original file line number
Diff line number
Diff line change
@@ -46,12 +46,12 @@ glimpse(pcod)
46
46
```
47
47
48
48
The most basic model structure possible in sdmTMB replicates a GLM as can be fit with `glm()` or a GLMM as can be fit with lme4 or glmmTMB, for example.
49
-
The spatial components in sdmTMB are included as random fields using a triangulated mesh with vertices, known as knots, used to approximate the spatial variability in observations.
49
+
The spatial components in sdmTMB are included as random fields using a triangulated mesh with vertices, known as knots, used to approximate the spatial variability in observations.
50
50
Bilinear interpolation is used to approximate a continuous spatial field (Rue et al., 2009; Lindgren et al., 2011) from the estimated values of the spatial surface at these knot locations to other locations including those of actual observations.
51
51
These spatial random effects are assumed to be drawn from Gaussian Markov random fields (e.g., Cressie & Wikle, 2011; Lindgren et al., 2011) with covariance matrices that are constrained by Matérn covariance functions (Cressie & Wikle, 2011).
52
52
53
-
There are different options for creating the spatial mesh (see `sdmTMB::make_mesh()`).
54
-
We will start with a relatively coarse mesh for a balance between speed and accuracy (`cutoff = 10`, where cutoff is in the units of X and Y (km here) and represents the minimum distance between knots before a new mesh vertex is added).
53
+
There are different options for creating the spatial mesh (see `sdmTMB::make_mesh()`).
54
+
We will start with a relatively coarse mesh for a balance between speed and accuracy (`cutoff = 10`, where cutoff is in the units of X and Y (km here) and represents the minimum distance between knots before a new mesh vertex is added).
55
55
Smaller values create meshes with more knots.
56
56
You will likely want to use a higher resolution mesh (more knots) in applied scenarios, but care must be taken to avoid overfitting.
57
57
The circles represent observations and the vertices are the knot locations.
@@ -146,8 +146,8 @@ And similarly for the random effect and variance parameters:
146
146
tidy(m3, "ran_pars", conf.int = TRUE)
147
147
```
148
148
149
-
Note that standard errors are not reported when coefficients are in log space, but the confidence intervals are reported. These parameters are defined as follows:
150
-
149
+
Note that standard errors are not reported when coefficients are in log space, but the confidence intervals are reported. These parameters are defined as follows:
150
+
151
151
*`range`: A derived parameter that defines the distance at which 2 points are effectively independent (actually about 13% correlated). If the `share_range` argument is changed to `FALSE` then the spatial and spatiotemporal ranges will be unique, otherwise the default is for both to share the same range.
152
152
153
153
*`phi`: Observation error scale parameter (e.g., SD in Gaussian).
@@ -181,11 +181,11 @@ ggplot(pcod, aes(X, Y, col = resids)) +
181
181
coord_fixed()
182
182
```
183
183
184
-
Those were fast to calculate but can look 'off' even when the model is consistent with the data.
184
+
Those were fast to calculate but can look 'off' even when the model is consistent with the data.
185
185
MCMC-based residuals are more reliable but slow.
186
186
We can calculate them through some help from the sdmTMBextra package. <https://github.com/pbs-assess/sdmTMBextra>.
187
-
In practice you would like want more `mcmc_iter` and `mcmc_warmup`.
188
-
Total samples is `mcmc_iter - mcmc_warmup`.
187
+
In practice you would like want more `mcmc_iter` and `mcmc_warmup`.
188
+
Total samples is `mcmc_iter - mcmc_warmup`.
189
189
We will also just use the spatial model here so the vignette builds quickly.
We can look at the spatial random effects that represent consistent deviations in space through time that are not accounted for by our fixed effects.
257
+
We can look at the spatial random effects that represent consistent deviations in space through time that are not accounted for by our fixed effects.
258
258
In other words, these deviations represent consistent biotic and abiotic factors that are affecting biomass density but are not accounted for in the model.
And finally we can look at the spatiotemporal random effects that represent deviation from the fixed effect predictions and the spatial random effect deviations.
266
+
And finally we can look at the spatiotemporal random effects that represent deviation from the fixed effect predictions and the spatial random effect deviations.
267
267
These represent biotic and abiotic factors that are changing through time and are not accounted for in the model.
We can also estimate the uncertainty in our spatiotemporal density predictions using simulations from the joint precision matrix by setting `nsim > 0` in the predict function.
277
-
Here we generate 100 estimates and use `apply()` to calculate upper and lower confidence intervals, a standard deviation, and a coefficient of variation (CV).
276
+
We can also estimate the uncertainty in our spatiotemporal density predictions using simulations from the joint precision matrix by setting `nsim > 0` in the predict function.
277
+
Here we generate 100 estimates and use `apply()` to calculate upper and lower confidence intervals, a standard deviation, and a coefficient of variation (CV).
To plot these, we make a data frame that contains all combinations of the time-varying covariate and time. This is easily created using `expand.grid()` or `tidyr::expand_grid()`.
360
+
To plot these, we make a data frame that contains all combinations of the time-varying covariate and time.
361
+
This is easily created using `expand.grid()` or `tidyr::expand_grid()`.
0 commit comments