diff --git a/articles/web_only/basic-intro.html b/articles/web_only/basic-intro.html index 6ef2e3f0b..49cdf4ec0 100644 --- a/articles/web_only/basic-intro.html +++ b/articles/web_only/basic-intro.html @@ -406,8 +406,8 @@

Model diagnostics#> #> SAMPLING FOR MODEL 'tmb_generic' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 0.010127 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 101.27 seconds. +#> Chain 1: Gradient evaluation took 0.009973 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 99.73 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -432,9 +432,9 @@

Model diagnostics#> Chain 1: Iteration: 100 / 101 [ 99%] (Warmup) #> Chain 1: Iteration: 101 / 101 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 27.666 seconds (Warm-up) -#> Chain 1: 0.199 seconds (Sampling) -#> Chain 1: 27.865 seconds (Total) +#> Chain 1: Elapsed Time: 26.631 seconds (Warm-up) +#> Chain 1: 0.198 seconds (Sampling) +#> Chain 1: 26.829 seconds (Total) #> Chain 1: r <- residuals(m3, "mle-mcmc", mcmc_samples = samps) qqnorm(r) @@ -601,9 +601,6 @@

Time-varying effects#> Detected irregular time spacing with an AR(1) or random walk process. #> Consider filling in the missing time slices with `extra_time`. #> `extra_time = c(2006, 2008, 2010, 2012, 2014, 2016)` -#> Warning in sqrt(diag(cov)): NaNs produced -#> Warning: The model may not have converged: non-positive-definite Hessian -#> matrix. m4 #> Spatiotemporal model fit by ML ['sdmTMB'] #> Formula: density ~ 0 + as.factor(year) @@ -611,72 +608,6 @@

Time-varying effects#> Time column: year #> Data: pcod #> Family: tweedie(link = 'log') -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced - -#> Warning in sqrt(diag(object$cov.fixed)): NaNs produced #> #> coef.est coef.se #> as.factor(year)2003 3.36 0.30 diff --git a/articles/web_only/basic-intro_files/figure-html/plot-cv-1.png b/articles/web_only/basic-intro_files/figure-html/plot-cv-1.png index 36fd75b60..6099e53c1 100644 Binary files a/articles/web_only/basic-intro_files/figure-html/plot-cv-1.png and b/articles/web_only/basic-intro_files/figure-html/plot-cv-1.png differ diff --git a/articles/web_only/basic-intro_files/figure-html/residuals-1.png b/articles/web_only/basic-intro_files/figure-html/residuals-1.png index 6bae34c3b..05c1c92f0 100644 Binary files a/articles/web_only/basic-intro_files/figure-html/residuals-1.png and b/articles/web_only/basic-intro_files/figure-html/residuals-1.png differ diff --git a/articles/web_only/basic-intro_files/figure-html/residuals-2.png b/articles/web_only/basic-intro_files/figure-html/residuals-2.png index ecc7177ad..00012ea6d 100644 Binary files a/articles/web_only/basic-intro_files/figure-html/residuals-2.png and b/articles/web_only/basic-intro_files/figure-html/residuals-2.png differ diff --git a/articles/web_only/basic-intro_files/figure-html/residuals-mcmc-1.png b/articles/web_only/basic-intro_files/figure-html/residuals-mcmc-1.png index 12687e223..e82f92aca 100644 Binary files a/articles/web_only/basic-intro_files/figure-html/residuals-mcmc-1.png and b/articles/web_only/basic-intro_files/figure-html/residuals-mcmc-1.png differ diff --git a/articles/web_only/basic-intro_files/figure-html/tv-depth-eff-1.png b/articles/web_only/basic-intro_files/figure-html/tv-depth-eff-1.png index 873e4fd7b..e9fb11d7a 100644 Binary files a/articles/web_only/basic-intro_files/figure-html/tv-depth-eff-1.png and b/articles/web_only/basic-intro_files/figure-html/tv-depth-eff-1.png differ diff --git a/articles/web_only/bayesian.html b/articles/web_only/bayesian.html index 67c4ff16d..55e1a471a 100644 --- a/articles/web_only/bayesian.html +++ b/articles/web_only/bayesian.html @@ -396,7 +396,7 @@

Passing the model to tmbstan#> omega_s[85] -0.29 0.01 0.21 -0.68 -0.44 -0.30 -0.15 0.11 1111 1.00 #> lp__ 136.06 0.93 9.26 118.11 129.87 136.38 142.46 152.88 100 1.02 #> -#> Samples were drawn using NUTS(diag_e) at Wed Apr 3 19:10:41 2024. +#> Samples were drawn using NUTS(diag_e) at Wed Apr 3 19:35:42 2024. #> For each parameter, n_eff is a crude measure of effective sample size, #> and Rhat is the potential scale reduction factor on split chains (at #> convergence, Rhat=1). diff --git a/articles/web_only/bayesian_files/figure-html/unnamed-chunk-9-1.png b/articles/web_only/bayesian_files/figure-html/unnamed-chunk-9-1.png index 06b21ee3d..ba82aa7ce 100644 Binary files a/articles/web_only/bayesian_files/figure-html/unnamed-chunk-9-1.png and b/articles/web_only/bayesian_files/figure-html/unnamed-chunk-9-1.png differ diff --git a/articles/web_only/cross-validation.html b/articles/web_only/cross-validation.html index 4e36466d6..4650b721c 100644 --- a/articles/web_only/cross-validation.html +++ b/articles/web_only/cross-validation.html @@ -213,9 +213,9 @@

Measuring model performance#> Set a parallel `future::plan()` to use parallel processing. m_cv$fold_loglik # fold log-likelihood -#> [1] -1529.945 -1792.257 -1545.111 -1766.426 +#> [1] -1590.421 -1522.668 -1670.647 -1780.221 m_cv$sum_loglik # total log-likelihood -#> [1] -6633.738 +#> [1] -6563.958 +#> [1] -725.435 @@ -284,9 +284,9 @@

Comparing two or more models# Compare log-likelihoods -- higher is better! m1$sum_loglik -#> [1] -6721.528 +#> [1] -6726.297 m2$sum_loglik -#> [1] -6573.109 +#> [1] -6583.089

Model ensembling diff --git a/articles/web_only/delta-models.html b/articles/web_only/delta-models.html index 7c27696d9..5dd641891 100644 --- a/articles/web_only/delta-models.html +++ b/articles/web_only/delta-models.html @@ -517,8 +517,8 @@

#> #> Dispersion parameter: 0.94 #> Matérn range: 0.01 -#> Spatial SD: 727.59 -#> Spatiotemporal IID SD: 2065.79 +#> Spatial SD: 727.43 +#> Spatiotemporal IID SD: 2065.32 #> ML criterion at convergence: 5102.136 #> #> See ?tidy.sdmTMB to extract these values as a data frame. diff --git a/articles/web_only/delta-models_files/figure-html/cv-1.png b/articles/web_only/delta-models_files/figure-html/cv-1.png index 6e46d0b49..6eb823ecf 100644 Binary files a/articles/web_only/delta-models_files/figure-html/cv-1.png and b/articles/web_only/delta-models_files/figure-html/cv-1.png differ diff --git a/articles/web_only/delta-models_files/figure-html/unnamed-chunk-14-1.png b/articles/web_only/delta-models_files/figure-html/unnamed-chunk-14-1.png index 0039810de..44f631718 100644 Binary files a/articles/web_only/delta-models_files/figure-html/unnamed-chunk-14-1.png and b/articles/web_only/delta-models_files/figure-html/unnamed-chunk-14-1.png differ diff --git a/articles/web_only/delta-models_files/figure-html/unnamed-chunk-19-1.png b/articles/web_only/delta-models_files/figure-html/unnamed-chunk-19-1.png index ef700095e..e041e2f89 100644 Binary files a/articles/web_only/delta-models_files/figure-html/unnamed-chunk-19-1.png and b/articles/web_only/delta-models_files/figure-html/unnamed-chunk-19-1.png differ diff --git a/articles/web_only/delta-models_files/figure-html/unnamed-chunk-20-1.png b/articles/web_only/delta-models_files/figure-html/unnamed-chunk-20-1.png index 0bbb84a2d..587a63f4c 100644 Binary files a/articles/web_only/delta-models_files/figure-html/unnamed-chunk-20-1.png and b/articles/web_only/delta-models_files/figure-html/unnamed-chunk-20-1.png differ diff --git a/articles/web_only/index-standardization_files/figure-html/residuals-1.png b/articles/web_only/index-standardization_files/figure-html/residuals-1.png index 185329b82..572a87ccb 100644 Binary files a/articles/web_only/index-standardization_files/figure-html/residuals-1.png and b/articles/web_only/index-standardization_files/figure-html/residuals-1.png differ diff --git a/articles/web_only/index-standardization_files/figure-html/residuals-2.png b/articles/web_only/index-standardization_files/figure-html/residuals-2.png index 6eea69322..d13276912 100644 Binary files a/articles/web_only/index-standardization_files/figure-html/residuals-2.png and b/articles/web_only/index-standardization_files/figure-html/residuals-2.png differ diff --git a/articles/web_only/index-standardization_files/figure-html/residuals-3.png b/articles/web_only/index-standardization_files/figure-html/residuals-3.png index ca91d0c15..02167fca5 100644 Binary files a/articles/web_only/index-standardization_files/figure-html/residuals-3.png and b/articles/web_only/index-standardization_files/figure-html/residuals-3.png differ diff --git a/articles/web_only/residual-checking.html b/articles/web_only/residual-checking.html index 440888419..37eb1a6ed 100644 --- a/articles/web_only/residual-checking.html +++ b/articles/web_only/residual-checking.html @@ -229,8 +229,8 @@

MCMC-based randomized-quantile #> #> SAMPLING FOR MODEL 'tmb_generic' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 0.000958 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 9.58 seconds. +#> Chain 1: Gradient evaluation took 0.001005 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 10.05 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -247,9 +247,9 @@

MCMC-based randomized-quantile #> Chain 1: Iteration: 720 / 800 [ 90%] (Sampling) #> Chain 1: Iteration: 800 / 800 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 6.679 seconds (Warm-up) -#> Chain 1: 4.757 seconds (Sampling) -#> Chain 1: 11.436 seconds (Total) +#> Chain 1: Elapsed Time: 6.663 seconds (Warm-up) +#> Chain 1: 4.766 seconds (Sampling) +#> Chain 1: 11.429 seconds (Total) #> Chain 1: mcmc_res <- residuals(fit_nb2, type = "mle-mcmc", mcmc_samples = samps) qqnorm(mcmc_res) @@ -500,8 +500,8 @@

The need for one-sample residuals#> #> SAMPLING FOR MODEL 'tmb_generic' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 0.002196 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 21.96 seconds. +#> Chain 1: Gradient evaluation took 0.002193 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 21.93 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -518,11 +518,11 @@

The need for one-sample residuals#> Chain 1: Iteration: 360 / 400 [ 90%] (Sampling) #> Chain 1: Iteration: 400 / 400 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 29.354 seconds (Warm-up) -#> Chain 1: 32.877 seconds (Sampling) -#> Chain 1: 62.231 seconds (Total) +#> Chain 1: Elapsed Time: 32.076 seconds (Warm-up) +#> Chain 1: 31.174 seconds (Sampling) +#> Chain 1: 63.25 seconds (Total) #> Chain 1: -#> Warning: The largest R-hat is 1.09, indicating chains have not mixed. +#> Warning: The largest R-hat is 1.08, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#r-hat #> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. @@ -540,7 +540,7 @@

The need for one-sample residuals#> Asymptotic one-sample Kolmogorov-Smirnov test #> #> data: r3 -#> D = 0.036042, p-value = 0.1488 +#> D = 0.024522, p-value = 0.5845 #> alternative hypothesis: two-sided

Here that gets us something similar and we would (correctly) fail to reject the hypothesis that \(r_3 \sim diff --git a/articles/web_only/residual-checking_files/figure-html/unnamed-chunk-17-1.png b/articles/web_only/residual-checking_files/figure-html/unnamed-chunk-17-1.png index fb3b74569..50ad2538a 100644 Binary files a/articles/web_only/residual-checking_files/figure-html/unnamed-chunk-17-1.png and b/articles/web_only/residual-checking_files/figure-html/unnamed-chunk-17-1.png differ diff --git a/articles/web_only/spatial-trend-models_files/figure-html/unnamed-chunk-13-1.png b/articles/web_only/spatial-trend-models_files/figure-html/unnamed-chunk-13-1.png index 5a996bac8..12f511f0a 100644 Binary files a/articles/web_only/spatial-trend-models_files/figure-html/unnamed-chunk-13-1.png and b/articles/web_only/spatial-trend-models_files/figure-html/unnamed-chunk-13-1.png differ diff --git a/pkgdown.yml b/pkgdown.yml index 7d1fa164a..6dfe314c7 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -15,7 +15,7 @@ articles: spatial-trend-models: web_only/spatial-trend-models.html threshold-models: web_only/threshold-models.html visreg: web_only/visreg.html -last_built: 2024-04-03T19:06Z +last_built: 2024-04-03T19:31Z urls: reference: https://pbs-assess.github.io/sdmTMB/reference article: https://pbs-assess.github.io/sdmTMB/articles diff --git a/reference/dharma_residuals-1.png b/reference/dharma_residuals-1.png index 273675e51..d576270cb 100644 Binary files a/reference/dharma_residuals-1.png and b/reference/dharma_residuals-1.png differ diff --git a/reference/dharma_residuals-2.png b/reference/dharma_residuals-2.png index c7b363974..3c7ad5fbb 100644 Binary files a/reference/dharma_residuals-2.png and b/reference/dharma_residuals-2.png differ diff --git a/reference/dharma_residuals-3.png b/reference/dharma_residuals-3.png index d981380e5..0d9f71310 100644 Binary files a/reference/dharma_residuals-3.png and b/reference/dharma_residuals-3.png differ diff --git a/reference/dharma_residuals-4.png b/reference/dharma_residuals-4.png index 2e44173c8..74e1d4f4e 100644 Binary files a/reference/dharma_residuals-4.png and b/reference/dharma_residuals-4.png differ diff --git a/reference/dharma_residuals-5.png b/reference/dharma_residuals-5.png index d98cb4bf4..122518af2 100644 Binary files a/reference/dharma_residuals-5.png and b/reference/dharma_residuals-5.png differ diff --git a/reference/dharma_residuals-6.png b/reference/dharma_residuals-6.png index 4d225afe4..7bad50e36 100644 Binary files a/reference/dharma_residuals-6.png and b/reference/dharma_residuals-6.png differ diff --git a/reference/dharma_residuals.html b/reference/dharma_residuals.html index c6299d0e7..c13f99c3a 100644 --- a/reference/dharma_residuals.html +++ b/reference/dharma_residuals.html @@ -172,46 +172,51 @@

Examples family = tweedie(link = "log"), spatial = "on") # The `simulated_response` argument is first so the output from -# simulate() can be piped to dharma_residuals(): +# simulate() can be piped to dharma_residuals(). + +# We will work with 100 simulations for fast examples, but you'll +# likely want to work with more than this (enough that the results +# are stable from run to run). # not great: set.seed(123) -simulate(fit, nsim = 200, type = "mle-mvn") |> +simulate(fit, nsim = 100, type = "mle-mvn") |> dharma_residuals(fit) +# \donttest{ # delta-lognormal looks better: set.seed(123) fit_dl <- update(fit, family = delta_lognormal()) -simulate(fit_dl, nsim = 200, type = "mle-mvn") |> +simulate(fit_dl, nsim = 100, type = "mle-mvn") |> dharma_residuals(fit) # or skip the pipe: set.seed(123) -s <- simulate(fit_dl, nsim = 200, type = "mle-mvn") +s <- simulate(fit_dl, nsim = 100, type = "mle-mvn") # and manually plot it: r <- dharma_residuals(s, fit_dl, plot = FALSE) head(r) #> observed expected -#> 1 0.0002489617 0.001030928 -#> 2 0.0003748640 0.002061856 -#> 3 0.0014616353 0.003092784 -#> 4 0.0029613685 0.004123711 +#> 1 0.0002512885 0.001030928 +#> 2 0.0003998549 0.002061856 +#> 3 0.0017916820 0.003092784 +#> 4 0.0030243763 0.004123711 #> 5 0.0032777465 0.005154639 -#> 6 0.0059662537 0.006185567 +#> 6 0.0060709249 0.006185567 plot(r$expected, r$observed) abline(0, 1) # return the DHARMa object and work with the DHARMa methods -ret <- simulate(fit_dl, nsim = 200, type = "mle-mvn") |> +ret <- simulate(fit_dl, nsim = 100, type = "mle-mvn") |> dharma_residuals(fit, return_DHARMa = TRUE) plot(ret) # try normal(0, 1) residuals: -s <- simulate(fit_dl, nsim = 200, type = "mle-mvn") +s <- simulate(fit_dl, nsim = 100, type = "mle-mvn") dharma_residuals(s, fit, expected_distribution = "normal") # note the points in the top right corner that had Inf quantiles @@ -221,6 +226,7 @@

Examplesr <- dharma_residuals(s, fit, return_DHARMa = TRUE) plot(fitted(fit), r$scaledResiduals) +# }