diff --git a/vignettes/Estimate_COA_vignette.Rmd b/vignettes/Estimate_COA_vignette.Rmd index 258a34e..6b2cb35 100644 --- a/vignettes/Estimate_COA_vignette.Rmd +++ b/vignettes/Estimate_COA_vignette.Rmd @@ -1,7 +1,7 @@ --- title: "Estimate activity centers from acoustic telemetry data" author: "Megan Winton" -date: "2018-06-06, updated 2026-06-25" +date: "2018-06-06, updated 2026-06-26" output: rmarkdown::github_document vignette: > %\VignetteIndexEntry{Estimate activity centers from acoustic telemetry data} @@ -35,66 +35,45 @@ library(hexbin) library(ggpubr) rlocs # Receiver locations -``` - -``` -## # A tibble: 30 × 3 -## Station east north -## -## 1 SB1 -1.33 1.61 -## 2 SB2 -0.579 1.91 -## 3 SB3 0.219 2.00 -## 4 SB4 1.00 1.81 -## 5 SB5 -1.69 0.896 -## 6 SB6 -0.879 0.950 -## 7 SB7 -0.231 1.20 -## 8 SB8 0.464 1.21 -## 9 SB9 1.28 1.04 -## 10 SB10 -1.77 0.0952 -## # ℹ 20 more rows -``` - -``` r +#> # A tibble: 30 × 3 +#> Station east north +#> +#> 1 SB1 -1.33 1.61 +#> 2 SB2 -0.579 1.91 +#> 3 SB3 0.219 2.00 +#> 4 SB4 1.00 1.81 +#> 5 SB5 -1.69 0.896 +#> 6 SB6 -0.879 0.950 +#> 7 SB7 -0.231 1.20 +#> 8 SB8 0.464 1.21 +#> 9 SB9 1.28 1.04 +#> 10 SB10 -1.77 0.0952 +#> # ℹ 20 more rows testloc # Test tag location -``` - -``` -## # A tibble: 1 × 2 -## east north -## -## 1 -0.329 0.713 -``` - -``` r +#> # A tibble: 1 × 2 +#> east north +#> +#> 1 -0.329 0.713 head(testdat) # Hourly detection data from the test tag -``` - -``` -## # A tibble: 6 × 5 -## Station Transmitter east north hour -## -## 1 SB12 3447 -0.326 0.513 1 -## 2 SB13 3447 0.125 0.575 1 -## 3 SB7 3447 -0.231 1.20 1 -## 4 SB6 3447 -0.879 0.950 1 -## 5 SB13 3447 0.125 0.575 1 -## 6 SB6 3447 -0.879 0.950 1 -``` - -``` r +#> # A tibble: 6 × 5 +#> Station Transmitter east north hour +#> +#> 1 SB12 3447 -0.326 0.513 1 +#> 2 SB13 3447 0.125 0.575 1 +#> 3 SB7 3447 -0.231 1.20 1 +#> 4 SB6 3447 -0.879 0.950 1 +#> 5 SB13 3447 0.125 0.575 1 +#> 6 SB6 3447 -0.879 0.950 1 head(fishdat) # Hourly detection data from a black sea bass -``` - -``` -## # A tibble: 6 × 5 -## Station Transmitter east north hour -## -## 1 SB15 3425 0.190 0.209 1 -## 2 SB14 3425 -0.261 0.159 1 -## 3 SB15 3425 0.190 0.209 1 -## 4 SB14 3425 -0.261 0.159 1 -## 5 SB12 3425 -0.326 0.513 1 -## 6 SB14 3425 -0.261 0.159 1 +#> # A tibble: 6 × 5 +#> Station Transmitter east north hour +#> +#> 1 SB15 3425 0.190 0.209 1 +#> 2 SB14 3425 -0.261 0.159 1 +#> 3 SB15 3425 0.190 0.209 1 +#> 4 SB14 3425 -0.261 0.159 1 +#> 5 SB12 3425 -0.326 0.513 1 +#> 6 SB14 3425 -0.261 0.159 1 ``` Prior to doing anything else, we need to specify our 'state space' - the spatial extent of interest. This will consist of your receiver array and a 'buffer' area around the array. The buffer needs to be large enough to allow for individuals that may have activity centers outside of the receiver array. There is no general rule of thumb for this, but it should scale with the geographic extent covered by your array. I would suggest selecting a buffer that is large enough to allow you to discriminate between individuals that are detected along the periphery of the array and individuals that are not detected at all - a COA will be estimated for all time steps unless you specify the individual has left the area; time steps with 0 detections will have an estimated COA somewhere outside the detection range of all receivers (note that this could be within the array bounds if your array has non-continuous coverage). If there are many time steps with zeros, you may want to modify your data file to omit time periods with 0 detections or modify the relevant `.stan` code chunk included in the `src/stan_files` folder on your local machine to skip time periods with no detections, which will speed up computing times. As always, it is up to the user to make sure that the results make sense in the context of the species/array of interest. @@ -137,7 +116,7 @@ testdat |> labs(x = "Hours since deployment", y = "Number of detections") ``` -![plot of chunk unnamed-chunk-3](figure/unnamed-chunk-3-1.png) +![](figure/unnamed-chunk-3-1.png) Tally how many time intervals each receiver was operational for - this allows for individual receivers deployed for different periods and/or receivers that were lost. @@ -158,10 +137,7 @@ rs[, c(4:(max(fishdat$hour) + 3))] <- 1 # Create vector of the number of sampling occasions for each receiver tsteps <- rowSums(rs[, 4:ncol(rs)]) tsteps # Will all be the same here because all operational over the entire time span -``` - -``` -## [1] 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 +#> [1] 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ``` Since detection records only include non-zero events (here assuming we'd like to keep time steps with zeros), we'll need to convert the number of detections to include zeros for all receivers that did not detect the tag during that time period. @@ -297,114 +273,111 @@ fit <- COA_Standard( ylim = ylim, # N-S boundary of spatial extent (receiver array + buffer) init = init_fun # initial values (optional) ) -``` - -``` -## -## SAMPLING FOR MODEL 'COA_Standard_gaussian' NOW (CHAIN 1). -## Chain 1: -## Chain 1: Gradient evaluation took 0.00072 seconds -## Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 7.2 seconds. -## Chain 1: Adjust your expectations accordingly! -## Chain 1: -## Chain 1: -## Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup) -## Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup) -## Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup) -## Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup) -## Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup) -## Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup) -## Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling) -## Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling) -## Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling) -## Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling) -## Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling) -## Chain 1: Iteration: 2000 / 2000 [100%] (Sampling) -## Chain 1: -## Chain 1: Elapsed Time: 6.407 seconds (Warm-up) -## Chain 1: 5.378 seconds (Sampling) -## Chain 1: 11.785 seconds (Total) -## Chain 1: -## -## SAMPLING FOR MODEL 'COA_Standard_gaussian' NOW (CHAIN 2). -## Chain 2: -## Chain 2: Gradient evaluation took 0.000546 seconds -## Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 5.46 seconds. -## Chain 2: Adjust your expectations accordingly! -## Chain 2: -## Chain 2: -## Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup) -## Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup) -## Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup) -## Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup) -## Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup) -## Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup) -## Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling) -## Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling) -## Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling) -## Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling) -## Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling) -## Chain 2: Iteration: 2000 / 2000 [100%] (Sampling) -## Chain 2: -## Chain 2: Elapsed Time: 6.155 seconds (Warm-up) -## Chain 2: 5.833 seconds (Sampling) -## Chain 2: 11.988 seconds (Total) -## Chain 2: -## -## SAMPLING FOR MODEL 'COA_Standard_gaussian' NOW (CHAIN 3). -## Chain 3: -## Chain 3: Gradient evaluation took 0.000536 seconds -## Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 5.36 seconds. -## Chain 3: Adjust your expectations accordingly! -## Chain 3: -## Chain 3: -## Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup) -## Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup) -## Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup) -## Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup) -## Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup) -## Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup) -## Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling) -## Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling) -## Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling) -## Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling) -## Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling) -## Chain 3: Iteration: 2000 / 2000 [100%] (Sampling) -## Chain 3: -## Chain 3: Elapsed Time: 6.129 seconds (Warm-up) -## Chain 3: 4.866 seconds (Sampling) -## Chain 3: 10.995 seconds (Total) -## Chain 3: -## -## SAMPLING FOR MODEL 'COA_Standard_gaussian' NOW (CHAIN 4). -## Chain 4: -## Chain 4: Gradient evaluation took 0.000608 seconds -## Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 6.08 seconds. -## Chain 4: Adjust your expectations accordingly! -## Chain 4: -## Chain 4: -## Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup) -## Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup) -## Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup) -## Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup) -## Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup) -## Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup) -## Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling) -## Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling) -## Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling) -## Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling) -## Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling) -## Chain 4: Iteration: 2000 / 2000 [100%] (Sampling) -## Chain 4: -## Chain 4: Elapsed Time: 6.76 seconds (Warm-up) -## Chain 4: 8.023 seconds (Sampling) -## Chain 4: 14.783 seconds (Total) -## Chain 4: -## warmup sample -## chain:1 6.407 5.378 -## chain:2 6.155 5.833 -## chain:3 6.129 4.866 -## chain:4 6.760 8.023 +#> +#> SAMPLING FOR MODEL 'COA_Standard_gaussian' NOW (CHAIN 1). +#> Chain 1: +#> Chain 1: Gradient evaluation took 0.000665 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 6.65 seconds. +#> Chain 1: Adjust your expectations accordingly! +#> Chain 1: +#> Chain 1: +#> Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup) +#> Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup) +#> Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup) +#> Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup) +#> Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup) +#> Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup) +#> Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling) +#> Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling) +#> Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling) +#> Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling) +#> Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling) +#> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling) +#> Chain 1: +#> Chain 1: Elapsed Time: 5.911 seconds (Warm-up) +#> Chain 1: 4.889 seconds (Sampling) +#> Chain 1: 10.8 seconds (Total) +#> Chain 1: +#> +#> SAMPLING FOR MODEL 'COA_Standard_gaussian' NOW (CHAIN 2). +#> Chain 2: +#> Chain 2: Gradient evaluation took 0.000611 seconds +#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 6.11 seconds. +#> Chain 2: Adjust your expectations accordingly! +#> Chain 2: +#> Chain 2: +#> Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup) +#> Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup) +#> Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup) +#> Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup) +#> Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup) +#> Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup) +#> Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling) +#> Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling) +#> Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling) +#> Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling) +#> Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling) +#> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling) +#> Chain 2: +#> Chain 2: Elapsed Time: 6.485 seconds (Warm-up) +#> Chain 2: 5.096 seconds (Sampling) +#> Chain 2: 11.581 seconds (Total) +#> Chain 2: +#> +#> SAMPLING FOR MODEL 'COA_Standard_gaussian' NOW (CHAIN 3). +#> Chain 3: +#> Chain 3: Gradient evaluation took 0.000527 seconds +#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 5.27 seconds. +#> Chain 3: Adjust your expectations accordingly! +#> Chain 3: +#> Chain 3: +#> Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup) +#> Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup) +#> Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup) +#> Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup) +#> Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup) +#> Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup) +#> Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling) +#> Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling) +#> Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling) +#> Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling) +#> Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling) +#> Chain 3: Iteration: 2000 / 2000 [100%] (Sampling) +#> Chain 3: +#> Chain 3: Elapsed Time: 6.557 seconds (Warm-up) +#> Chain 3: 7.947 seconds (Sampling) +#> Chain 3: 14.504 seconds (Total) +#> Chain 3: +#> +#> SAMPLING FOR MODEL 'COA_Standard_gaussian' NOW (CHAIN 4). +#> Chain 4: +#> Chain 4: Gradient evaluation took 0.000534 seconds +#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 5.34 seconds. +#> Chain 4: Adjust your expectations accordingly! +#> Chain 4: +#> Chain 4: +#> Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup) +#> Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup) +#> Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup) +#> Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup) +#> Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup) +#> Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup) +#> Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling) +#> Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling) +#> Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling) +#> Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling) +#> Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling) +#> Chain 4: Iteration: 2000 / 2000 [100%] (Sampling) +#> Chain 4: +#> Chain 4: Elapsed Time: 6.435 seconds (Warm-up) +#> Chain 4: 7.027 seconds (Sampling) +#> Chain 4: 13.462 seconds (Total) +#> Chain 4: +#> warmup sample +#> chain:1 5.911 4.889 +#> chain:2 6.485 5.096 +#> chain:3 6.557 7.947 +#> chain:4 6.435 7.027 ``` The function will automatically spit out the run-time associated with each of the 4 chains used for fitting and returns a list with four objects: @@ -412,19 +385,16 @@ The function will automatically spit out the run-time associated with each of th ``` r summary(fit) -``` - -``` -## Length Class Mode -## model 1 stanfit S4 -## summary 20 -none- numeric -## time 1 -none- numeric -## summary_draws 4 draws_summary list -## coas 8 tbl_df list -## all_estimates 28 draws_df list -## loc_draws 8 tbl_df list -## param_draws 10 tbl_df list -## generated_quantities 1 -none- list +#> Length Class Mode +#> model 1 stanfit S4 +#> summary 20 -none- numeric +#> time 1 -none- numeric +#> summary_draws 4 draws_summary list +#> coas 8 tbl_df list +#> all_estimates 28 draws_df list +#> loc_draws 8 tbl_df list +#> param_draws 10 tbl_df list +#> generated_quantities 1 -none- list ``` The first contains the Stan model object (accessible via `fit$model`, which will allow you to use `rstan` plotting tools and diagnostic plots - see rstan documentation for details). @@ -434,12 +404,9 @@ The second element is a table of parameter estimates and associated quantiles fr ``` r fit$summary -``` - -``` -## mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat -## p0 0.2649269 0.0003857418 0.02195448 0.2244304 0.2492082 0.2646826 0.2796141 0.3089730 3239.312 1.001716 -## sigma 0.2735005 0.0002615187 0.01445862 0.2459703 0.2636200 0.2733011 0.2830180 0.3018919 3056.668 1.002765 +#> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat +#> p0 0.2654382 0.0003688420 0.02189836 0.2243499 0.2505072 0.2647295 0.2798553 0.3110876 3524.867 0.9997398 +#> sigma 0.2732326 0.0002651498 0.01443172 0.2452476 0.2636036 0.2731982 0.2827502 0.3023710 2962.468 0.9995877 ``` The third returns the time required to run the model (in minutes). Note that Stan will automatically detect and use multiple cores. If the computer used to run this has multiple cores, the time returned will be longer than the actual run time (because it will sum the time for each core). To return the realized run time, divide `fit$time` by the number of cores. @@ -447,10 +414,7 @@ The third returns the time required to run the model (in minutes). Note that Sta ``` r fit$time -``` - -``` -## [1] 0.82585 +#> [1] 0.8391167 ``` The fourth returns an array of COA estimates, where each matrix corresponds to one individual, the rows correspond to each time step, and the columns include the median posterior estimate of the east-west (x) and north-south (y) coordinates. The 95% credible interval (Bayesian version of a confidence interval) for each coordinate is also provided. @@ -458,22 +422,19 @@ The fourth returns an array of COA estimates, where each matrix corresponds to o ``` r fit$coas -``` - -``` -## # A tibble: 10 × 8 -## ind time x y x_lower x_upper y_lower y_upper -## -## 1 1 1 -0.0424 0.289 -0.149 0.0577 0.179 0.403 -## 2 1 2 -0.0178 0.360 -0.145 0.103 0.215 0.512 -## 3 1 3 -0.101 0.386 -0.267 0.0622 0.192 0.567 -## 4 1 4 -0.129 0.284 -0.291 0.0351 0.0996 0.481 -## 5 1 5 -0.178 0.325 -0.327 -0.0131 0.143 0.515 -## 6 1 6 -0.133 0.685 -0.463 0.181 0.127 0.871 -## 7 1 7 -0.0527 0.364 -0.174 0.0679 0.232 0.501 -## 8 1 8 -0.159 0.403 -0.285 -0.0318 0.259 0.542 -## 9 1 9 -0.0508 0.333 -0.227 0.118 0.128 0.553 -## 10 1 10 -0.108 0.308 -0.310 0.0935 0.0765 0.571 +#> # A tibble: 10 × 8 +#> ind time x y x_lower x_upper y_lower y_upper +#> +#> 1 1 1 -0.0417 0.291 -0.147 0.0601 0.183 0.407 +#> 2 1 2 -0.0186 0.360 -0.147 0.114 0.217 0.499 +#> 3 1 3 -0.100 0.383 -0.262 0.0610 0.182 0.577 +#> 4 1 4 -0.127 0.280 -0.288 0.0327 0.106 0.481 +#> 5 1 5 -0.177 0.326 -0.340 -0.0201 0.142 0.524 +#> 6 1 6 -0.131 0.681 -0.470 0.181 0.0955 0.880 +#> 7 1 7 -0.0527 0.365 -0.174 0.0749 0.230 0.501 +#> 8 1 8 -0.159 0.405 -0.287 -0.0310 0.264 0.539 +#> 9 1 9 -0.0502 0.337 -0.224 0.123 0.118 0.551 +#> 10 1 10 -0.108 0.306 -0.309 0.0921 0.0856 0.573 ``` The last element (`fit$all_estimates`) contains the estimates from each non-warm-up iteration for all 4 chains. (If you're not familiar with Bayesian lingo and this just seems like statistical jargon, all you need to know is that this is what you'll use to plot the uncertainty cloud around COA estimates and/or the distribution of parameter estimates as presented in the paper.) This includes estimates of all latent parameters for each individual in each time step (aka this element contains tons of parameter estimates), so we will need to subset out parameters for plotting. @@ -500,14 +461,9 @@ for (i in 1:nind) { # The ID field corresponds to the time step. mutate(time = as.numeric(gsub(".*,|\\]", "", name))) } -``` - -``` -## Warning: Dropping 'draws_df' class as required metadata was removed. -## Warning: Dropping 'draws_df' class as required metadata was removed. -``` +#> Warning: Dropping 'draws_df' class as required metadata was removed. +#> Warning: Dropping 'draws_df' class as required metadata was removed. -``` r ## Plot posterior estimates # Select individual for plotting post_fit <- EN_fit[[1]] @@ -567,143 +523,128 @@ fit_vary <- COA_TimeVarying( ylim = ylim, # N-S boundary of spatial extent (receiver array + buffer) init = init_fun # initial values (optional) ) -``` - -``` -## -## SAMPLING FOR MODEL 'COA_TimeVarying_gaussian' NOW (CHAIN 1). -## Chain 1: -## Chain 1: Gradient evaluation took 0.001052 seconds -## Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 10.52 seconds. -## Chain 1: Adjust your expectations accordingly! -## Chain 1: -## Chain 1: -## Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup) -## Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup) -## Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup) -## Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup) -## Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup) -## Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup) -## Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling) -## Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling) -## Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling) -## Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling) -## Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling) -## Chain 1: Iteration: 2000 / 2000 [100%] (Sampling) -## Chain 1: -## Chain 1: Elapsed Time: 72.81 seconds (Warm-up) -## Chain 1: 33.971 seconds (Sampling) -## Chain 1: 106.781 seconds (Total) -## Chain 1: -## -## SAMPLING FOR MODEL 'COA_TimeVarying_gaussian' NOW (CHAIN 2). -## Chain 2: -## Chain 2: Gradient evaluation took 0.000767 seconds -## Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 7.67 seconds. -## Chain 2: Adjust your expectations accordingly! -## Chain 2: -## Chain 2: -## Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup) -## Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup) -## Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup) -## Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup) -## Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup) -## Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup) -## Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling) -## Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling) -## Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling) -## Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling) -## Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling) -## Chain 2: Iteration: 2000 / 2000 [100%] (Sampling) -## Chain 2: -## Chain 2: Elapsed Time: 74.38 seconds (Warm-up) -## Chain 2: 41.743 seconds (Sampling) -## Chain 2: 116.123 seconds (Total) -## Chain 2: -## -## SAMPLING FOR MODEL 'COA_TimeVarying_gaussian' NOW (CHAIN 3). -## Chain 3: -## Chain 3: Gradient evaluation took 0.000758 seconds -## Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 7.58 seconds. -## Chain 3: Adjust your expectations accordingly! -## Chain 3: -## Chain 3: -## Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup) -## Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup) -## Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup) -## Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup) -## Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup) -## Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup) -## Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling) -## Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling) -## Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling) -## Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling) -## Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling) -## Chain 3: Iteration: 2000 / 2000 [100%] (Sampling) -## Chain 3: -## Chain 3: Elapsed Time: 71.218 seconds (Warm-up) -## Chain 3: 26.691 seconds (Sampling) -## Chain 3: 97.909 seconds (Total) -## Chain 3: -## -## SAMPLING FOR MODEL 'COA_TimeVarying_gaussian' NOW (CHAIN 4). -## Chain 4: -## Chain 4: Gradient evaluation took 0.000788 seconds -## Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 7.88 seconds. -## Chain 4: Adjust your expectations accordingly! -## Chain 4: -## Chain 4: -## Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup) -## Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup) -## Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup) -## Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup) -## Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup) -## Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup) -## Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling) -## Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling) -## Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling) -## Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling) -## Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling) -## Chain 4: Iteration: 2000 / 2000 [100%] (Sampling) -## Chain 4: -## Chain 4: Elapsed Time: 73.978 seconds (Warm-up) -## Chain 4: 34.014 seconds (Sampling) -## Chain 4: 107.992 seconds (Total) -## Chain 4: -## warmup sample -## chain:1 72.810 33.971 -## chain:2 74.380 41.743 -## chain:3 71.218 26.691 -## chain:4 73.978 34.014 -``` +#> +#> SAMPLING FOR MODEL 'COA_TimeVarying_gaussian' NOW (CHAIN 1). +#> Chain 1: +#> Chain 1: Gradient evaluation took 0.000852 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 8.52 seconds. +#> Chain 1: Adjust your expectations accordingly! +#> Chain 1: +#> Chain 1: +#> Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup) +#> Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup) +#> Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup) +#> Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup) +#> Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup) +#> Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup) +#> Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling) +#> Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling) +#> Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling) +#> Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling) +#> Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling) +#> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling) +#> Chain 1: +#> Chain 1: Elapsed Time: 70.703 seconds (Warm-up) +#> Chain 1: 26.146 seconds (Sampling) +#> Chain 1: 96.849 seconds (Total) +#> Chain 1: +#> +#> SAMPLING FOR MODEL 'COA_TimeVarying_gaussian' NOW (CHAIN 2). +#> Chain 2: +#> Chain 2: Gradient evaluation took 0.000745 seconds +#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 7.45 seconds. +#> Chain 2: Adjust your expectations accordingly! +#> Chain 2: +#> Chain 2: +#> Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup) +#> Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup) +#> Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup) +#> Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup) +#> Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup) +#> Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup) +#> Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling) +#> Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling) +#> Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling) +#> Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling) +#> Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling) +#> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling) +#> Chain 2: +#> Chain 2: Elapsed Time: 71.902 seconds (Warm-up) +#> Chain 2: 30.07 seconds (Sampling) +#> Chain 2: 101.972 seconds (Total) +#> Chain 2: +#> +#> SAMPLING FOR MODEL 'COA_TimeVarying_gaussian' NOW (CHAIN 3). +#> Chain 3: +#> Chain 3: Gradient evaluation took 0.000741 seconds +#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 7.41 seconds. +#> Chain 3: Adjust your expectations accordingly! +#> Chain 3: +#> Chain 3: +#> Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup) +#> Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup) +#> Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup) +#> Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup) +#> Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup) +#> Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup) +#> Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling) +#> Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling) +#> Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling) +#> Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling) +#> Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling) +#> Chain 3: Iteration: 2000 / 2000 [100%] (Sampling) +#> Chain 3: +#> Chain 3: Elapsed Time: 71.009 seconds (Warm-up) +#> Chain 3: 29.33 seconds (Sampling) +#> Chain 3: 100.339 seconds (Total) +#> Chain 3: +#> +#> SAMPLING FOR MODEL 'COA_TimeVarying_gaussian' NOW (CHAIN 4). +#> Chain 4: +#> Chain 4: Gradient evaluation took 0.000734 seconds +#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 7.34 seconds. +#> Chain 4: Adjust your expectations accordingly! +#> Chain 4: +#> Chain 4: +#> Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup) +#> Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup) +#> Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup) +#> Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup) +#> Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup) +#> Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup) +#> Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling) +#> Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling) +#> Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling) +#> Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling) +#> Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling) +#> Chain 4: Iteration: 2000 / 2000 [100%] (Sampling) +#> Chain 4: +#> Chain 4: Elapsed Time: 71.187 seconds (Warm-up) +#> Chain 4: 36.17 seconds (Sampling) +#> Chain 4: 107.357 seconds (Total) +#> Chain 4: +#> warmup sample +#> chain:1 70.703 26.146 +#> chain:2 71.902 30.070 +#> chain:3 71.009 29.330 +#> chain:4 71.187 36.170 -``` r summary(fit_vary) -``` - -``` -## Length Class Mode -## model 1 stanfit S4 -## summary 3010 -none- numeric -## time 1 -none- numeric -## summary_draws 4 draws_summary list -## coas 8 tbl_df list -## detection_probs 5 draws_summary list -## all_estimates 626 draws_df list -## loc_draws 8 tbl_df list -## param_draws 608 tbl_df list -## generated_quantities 1 -none- list -``` +#> Length Class Mode +#> model 1 stanfit S4 +#> summary 3010 -none- numeric +#> time 1 -none- numeric +#> summary_draws 4 draws_summary list +#> coas 8 tbl_df list +#> detection_probs 5 draws_summary list +#> all_estimates 626 draws_df list +#> loc_draws 8 tbl_df list +#> param_draws 608 tbl_df list +#> generated_quantities 1 -none- list -``` r fit_vary$time -``` - -``` -## [1] 7.14675 -``` +#> [1] 6.775283 -``` r # As before, extract east-west and north-south coordinates of COAs from each iteration of each chain # Note that 'sx' and 'sy' are the variable names used to store the coordinates for each individual (rows) in each time step (columns). # We'll store them as a list, where each element corresponds to an individual @@ -724,14 +665,9 @@ for (i in 1:nind) { # The ID field corresponds to the time step. mutate(time = as.numeric(gsub(".*,|\\]", "", name))) } -``` - -``` -## Warning: Dropping 'draws_df' class as required metadata was removed. -## Warning: Dropping 'draws_df' class as required metadata was removed. -``` +#> Warning: Dropping 'draws_df' class as required metadata was removed. +#> Warning: Dropping 'draws_df' class as required metadata was removed. -``` r ## Plot posterior estimates # Select individual for plotting post_vary <- EN_vary[[1]] @@ -798,143 +734,128 @@ fit_tag <- COA_TagInt( testY = array(testloc$north, dim = c(nsentinel)), init = init_fun # initial values (optional) ) -``` - -``` -## -## SAMPLING FOR MODEL 'COA_Tag_Integrated_gaussian' NOW (CHAIN 1). -## Chain 1: -## Chain 1: Gradient evaluation took 0.001106 seconds -## Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 11.06 seconds. -## Chain 1: Adjust your expectations accordingly! -## Chain 1: -## Chain 1: -## Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup) -## Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup) -## Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup) -## Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup) -## Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup) -## Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup) -## Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling) -## Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling) -## Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling) -## Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling) -## Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling) -## Chain 1: Iteration: 2000 / 2000 [100%] (Sampling) -## Chain 1: -## Chain 1: Elapsed Time: 66.656 seconds (Warm-up) -## Chain 1: 36.17 seconds (Sampling) -## Chain 1: 102.826 seconds (Total) -## Chain 1: -## -## SAMPLING FOR MODEL 'COA_Tag_Integrated_gaussian' NOW (CHAIN 2). -## Chain 2: -## Chain 2: Gradient evaluation took 0.001032 seconds -## Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 10.32 seconds. -## Chain 2: Adjust your expectations accordingly! -## Chain 2: -## Chain 2: -## Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup) -## Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup) -## Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup) -## Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup) -## Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup) -## Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup) -## Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling) -## Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling) -## Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling) -## Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling) -## Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling) -## Chain 2: Iteration: 2000 / 2000 [100%] (Sampling) -## Chain 2: -## Chain 2: Elapsed Time: 65.921 seconds (Warm-up) -## Chain 2: 32.703 seconds (Sampling) -## Chain 2: 98.624 seconds (Total) -## Chain 2: -## -## SAMPLING FOR MODEL 'COA_Tag_Integrated_gaussian' NOW (CHAIN 3). -## Chain 3: -## Chain 3: Gradient evaluation took 0.001052 seconds -## Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 10.52 seconds. -## Chain 3: Adjust your expectations accordingly! -## Chain 3: -## Chain 3: -## Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup) -## Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup) -## Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup) -## Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup) -## Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup) -## Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup) -## Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling) -## Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling) -## Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling) -## Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling) -## Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling) -## Chain 3: Iteration: 2000 / 2000 [100%] (Sampling) -## Chain 3: -## Chain 3: Elapsed Time: 63.123 seconds (Warm-up) -## Chain 3: 34.967 seconds (Sampling) -## Chain 3: 98.09 seconds (Total) -## Chain 3: -## -## SAMPLING FOR MODEL 'COA_Tag_Integrated_gaussian' NOW (CHAIN 4). -## Chain 4: -## Chain 4: Gradient evaluation took 0.001025 seconds -## Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 10.25 seconds. -## Chain 4: Adjust your expectations accordingly! -## Chain 4: -## Chain 4: -## Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup) -## Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup) -## Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup) -## Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup) -## Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup) -## Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup) -## Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling) -## Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling) -## Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling) -## Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling) -## Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling) -## Chain 4: Iteration: 2000 / 2000 [100%] (Sampling) -## Chain 4: -## Chain 4: Elapsed Time: 63.2 seconds (Warm-up) -## Chain 4: 34.995 seconds (Sampling) -## Chain 4: 98.195 seconds (Total) -## Chain 4: -## warmup sample -## chain:1 66.656 36.170 -## chain:2 65.921 32.703 -## chain:3 63.123 34.967 -## chain:4 63.200 34.995 -``` +#> +#> SAMPLING FOR MODEL 'COA_Tag_Integrated_gaussian' NOW (CHAIN 1). +#> Chain 1: +#> Chain 1: Gradient evaluation took 0.001124 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 11.24 seconds. +#> Chain 1: Adjust your expectations accordingly! +#> Chain 1: +#> Chain 1: +#> Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup) +#> Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup) +#> Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup) +#> Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup) +#> Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup) +#> Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup) +#> Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling) +#> Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling) +#> Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling) +#> Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling) +#> Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling) +#> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling) +#> Chain 1: +#> Chain 1: Elapsed Time: 66.441 seconds (Warm-up) +#> Chain 1: 27.627 seconds (Sampling) +#> Chain 1: 94.068 seconds (Total) +#> Chain 1: +#> +#> SAMPLING FOR MODEL 'COA_Tag_Integrated_gaussian' NOW (CHAIN 2). +#> Chain 2: +#> Chain 2: Gradient evaluation took 0.00103 seconds +#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 10.3 seconds. +#> Chain 2: Adjust your expectations accordingly! +#> Chain 2: +#> Chain 2: +#> Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup) +#> Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup) +#> Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup) +#> Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup) +#> Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup) +#> Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup) +#> Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling) +#> Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling) +#> Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling) +#> Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling) +#> Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling) +#> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling) +#> Chain 2: +#> Chain 2: Elapsed Time: 64.252 seconds (Warm-up) +#> Chain 2: 34.917 seconds (Sampling) +#> Chain 2: 99.169 seconds (Total) +#> Chain 2: +#> +#> SAMPLING FOR MODEL 'COA_Tag_Integrated_gaussian' NOW (CHAIN 3). +#> Chain 3: +#> Chain 3: Gradient evaluation took 0.001032 seconds +#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 10.32 seconds. +#> Chain 3: Adjust your expectations accordingly! +#> Chain 3: +#> Chain 3: +#> Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup) +#> Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup) +#> Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup) +#> Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup) +#> Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup) +#> Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup) +#> Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling) +#> Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling) +#> Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling) +#> Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling) +#> Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling) +#> Chain 3: Iteration: 2000 / 2000 [100%] (Sampling) +#> Chain 3: +#> Chain 3: Elapsed Time: 65.148 seconds (Warm-up) +#> Chain 3: 31.545 seconds (Sampling) +#> Chain 3: 96.693 seconds (Total) +#> Chain 3: +#> +#> SAMPLING FOR MODEL 'COA_Tag_Integrated_gaussian' NOW (CHAIN 4). +#> Chain 4: +#> Chain 4: Gradient evaluation took 0.001026 seconds +#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 10.26 seconds. +#> Chain 4: Adjust your expectations accordingly! +#> Chain 4: +#> Chain 4: +#> Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup) +#> Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup) +#> Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup) +#> Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup) +#> Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup) +#> Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup) +#> Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling) +#> Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling) +#> Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling) +#> Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling) +#> Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling) +#> Chain 4: Iteration: 2000 / 2000 [100%] (Sampling) +#> Chain 4: +#> Chain 4: Elapsed Time: 66.824 seconds (Warm-up) +#> Chain 4: 35.706 seconds (Sampling) +#> Chain 4: 102.53 seconds (Total) +#> Chain 4: +#> warmup sample +#> chain:1 66.441 27.627 +#> chain:2 64.252 34.917 +#> chain:3 65.148 31.545 +#> chain:4 66.824 35.706 -``` r summary(fit_tag) -``` +#> Length Class Mode +#> model 1 stanfit S4 +#> summary 3010 -none- numeric +#> time 1 -none- numeric +#> summary_draws 4 draws_summary list +#> coas 8 tbl_df list +#> detection_probs 5 draws_summary list +#> all_estimates 626 draws_df list +#> loc_draws 8 tbl_df list +#> param_draws 608 tbl_df list +#> generated_quantities 2 -none- list -``` -## Length Class Mode -## model 1 stanfit S4 -## summary 3010 -none- numeric -## time 1 -none- numeric -## summary_draws 4 draws_summary list -## coas 8 tbl_df list -## detection_probs 5 draws_summary list -## all_estimates 626 draws_df list -## loc_draws 8 tbl_df list -## param_draws 608 tbl_df list -## generated_quantities 2 -none- list -``` - -``` r fit_tag$time # See the comment about run time when your computer has multiple cores above. -``` +#> [1] 6.541 -``` -## [1] 6.628917 -``` - -``` r # As before, extract east-west and north-south coordinates of COAs from each iteration of each chain # Note that 'sx' and 'sy' are the variable names used to store the coordinates for each individual (rows) in each time step (columns). # We'll store them as a list, where each element corresponds to an individual @@ -955,14 +876,9 @@ for (i in 1:nind) { # The ID field corresponds to the time step. mutate(time = as.numeric(gsub(".*,|\\]", "", name))) } -``` +#> Warning: Dropping 'draws_df' class as required metadata was removed. +#> Warning: Dropping 'draws_df' class as required metadata was removed. -``` -## Warning: Dropping 'draws_df' class as required metadata was removed. -## Warning: Dropping 'draws_df' class as required metadata was removed. -``` - -``` r ## Plot posterior estimates # Select individual for plotting post_tag <- EN_tag[[1]] @@ -1022,7 +938,7 @@ ggarrange( ) ``` -![plot of chunk unnamed-chunk-16](figure/unnamed-chunk-16-1.png) +![](figure/unnamed-chunk-16-1.png) ## References diff --git a/vignettes/_Estimate_COA_vignette.Rmd b/vignettes/_Estimate_COA_vignette.Rmd index cba5e84..a721912 100644 --- a/vignettes/_Estimate_COA_vignette.Rmd +++ b/vignettes/_Estimate_COA_vignette.Rmd @@ -50,7 +50,7 @@ ylim <- c(min(rlocs$north - buffer), max(rlocs$north + buffer)) Next, we need to prepare our test tag data. First, calculate the distance between the test tag's location and each receiver. This can be done using the included 'distf' function. -```{r, echo=T, message = F, fig.width=6, fig.height=6} +```{r, echo=T, message = F, fig.width=6, fig.height=6, fig.cap=""} # Set up a blank vector for storage D <- NULL # Loop over each hour @@ -497,7 +497,7 @@ plotTagInt <- ggplot(aes(x = X, y = Y), data = post_tag) + Now plot them all up together to see how they compare! -```{r, echo=T, message = F, fig.width=8, fig.height=8} +```{r, echo=T, message = F, fig.width=8, fig.height=8,fig.cap=""} ggarrange( plotCOAs, plotTVary, diff --git a/vignettes/_ps_estimate_coa_vignette.Rmd b/vignettes/_ps_estimate_coa_vignette.Rmd index e98877b..2d2d6b4 100644 --- a/vignettes/_ps_estimate_coa_vignette.Rmd +++ b/vignettes/_ps_estimate_coa_vignette.Rmd @@ -235,7 +235,7 @@ summary(m) ``` Let's look at our trace plots for the model parameters and posterior distributions to ensure the model converged properly. Remember the trace plots should look grassy or caterpillar like. A trace plot is the posterior draw for a given iteration plotted with the iteration number on the x axis and the posterior value for a given parameter or latent variable on the y. We evaluate this for both chains and want to see that both chains are converging on a smiler posterior draw for a given parameter or latent variable. We will first look at parameters of the model. -``` {r trace plots and post dist} +``` {r trace plots and post dist, fig.cap=""} stan_trace(m$model, pars = c("alpha0", "alpha1", "p0", "sigma")) stan_dens( @@ -252,7 +252,7 @@ Next let’s look at our latent variables which are `sx` and `sy` or the estimat this way and we recommend inspecting $\hat R$ and ESS. -``` {r trace plots and post dist latent} +``` {r trace plots and post dist latent, fig.cap=""} stan_trace(m$model, pars = c("sx[1,1]", "sx[1,2]", "sy[1,1]", "sy[1,2]")) stan_dens( @@ -321,7 +321,7 @@ The ninth element returned is a `list` that contains generated quantities for `y ``` {r yrep} yrep <- m$generated_quantities -yrep +str(yrep) ``` ## Plotting @@ -358,13 +358,13 @@ p1 <- p + Let's first look at the posterior densities for each time step -```{r post densities timestep} +```{r post densities timestep, fig.cap=""} p1 ``` Next let's look at the densities combined to gather a better understanding of the movement over the 8 timesteps. -```{r post densities combined} +```{r post densities combined, fig.cap=""} p ``` @@ -384,7 +384,7 @@ param_draws_long <- param_draws |> We can now plot those posterior distributions of the model parameters. -```{r plot param} +```{r plot param, fig.cap=""} p_param <- ggplot( data = param_draws_long, aes(x = time, y = est, fill = fish), @@ -401,16 +401,17 @@ p_param <- ggplot( p_param ``` + We can see that they are all quite tightly distributed with `p0` indicating that detection probability at a distance of `0` is between 48 - 54 %, while the `sigma` is around 1 km. Lastly, we can plot the predictive posterior check using `{tidybayes}`. First we need to make detection counts as a vector from our `build_count()` object. -```{r y_obs } +```{r y_obs} y_obs <- as.vector(ps_count_example[!is.na(ps_count_example)]) ``` Next we can plot the densities using `ppc_dens_overlay()` from `{bayesplot}`. -```{r ppc dens} +```{r ppc dens, fig.cap=""} ppc <- ppc_dens_overlay(y = y_obs, yrep = yrep$yrep) ppc ``` diff --git a/vignettes/figure/plot param-1.png b/vignettes/figure/plot param-1.png index dc1ccb7..a8664dc 100644 Binary files a/vignettes/figure/plot param-1.png and b/vignettes/figure/plot param-1.png differ diff --git a/vignettes/figure/post densities combined-1.png b/vignettes/figure/post densities combined-1.png index 641f57e..be94488 100644 Binary files a/vignettes/figure/post densities combined-1.png and b/vignettes/figure/post densities combined-1.png differ diff --git a/vignettes/figure/post densities timestep-1.png b/vignettes/figure/post densities timestep-1.png index 0230527..df14b41 100644 Binary files a/vignettes/figure/post densities timestep-1.png and b/vignettes/figure/post densities timestep-1.png differ diff --git a/vignettes/figure/ppc dens-1.png b/vignettes/figure/ppc dens-1.png index 51636f6..deb17b8 100644 Binary files a/vignettes/figure/ppc dens-1.png and b/vignettes/figure/ppc dens-1.png differ diff --git a/vignettes/figure/trace plots and post dist latent-1.png b/vignettes/figure/trace plots and post dist latent-1.png index 6528036..796c362 100644 Binary files a/vignettes/figure/trace plots and post dist latent-1.png and b/vignettes/figure/trace plots and post dist latent-1.png differ diff --git a/vignettes/figure/trace plots and post dist latent-2.png b/vignettes/figure/trace plots and post dist latent-2.png index 45eeb61..2e71b54 100644 Binary files a/vignettes/figure/trace plots and post dist latent-2.png and b/vignettes/figure/trace plots and post dist latent-2.png differ diff --git a/vignettes/figure/trace plots and post dist-1.png b/vignettes/figure/trace plots and post dist-1.png index 93d3f9a..d43b66c 100644 Binary files a/vignettes/figure/trace plots and post dist-1.png and b/vignettes/figure/trace plots and post dist-1.png differ diff --git a/vignettes/figure/trace plots and post dist-2.png b/vignettes/figure/trace plots and post dist-2.png index d51b73b..40e44a6 100644 Binary files a/vignettes/figure/trace plots and post dist-2.png and b/vignettes/figure/trace plots and post dist-2.png differ diff --git a/vignettes/figure/unnamed-chunk-16-1.png b/vignettes/figure/unnamed-chunk-16-1.png index e88f644..eb7bb5c 100644 Binary files a/vignettes/figure/unnamed-chunk-16-1.png and b/vignettes/figure/unnamed-chunk-16-1.png differ diff --git a/vignettes/ps_estimate_coa_vignette.Rmd b/vignettes/ps_estimate_coa_vignette.Rmd index a6d3137..aa0f06f 100644 --- a/vignettes/ps_estimate_coa_vignette.Rmd +++ b/vignettes/ps_estimate_coa_vignette.Rmd @@ -278,8 +278,8 @@ m <- COA_Standard( #> #> SAMPLING FOR MODEL 'COA_Standard_gaussian' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 0.001088 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 10.88 seconds. +#> Chain 1: Gradient evaluation took 0.000967 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 9.67 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -296,15 +296,15 @@ m <- COA_Standard( #> Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling) #> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 13.128 seconds (Warm-up) -#> Chain 1: 10.399 seconds (Sampling) -#> Chain 1: 23.527 seconds (Total) +#> Chain 1: Elapsed Time: 12.964 seconds (Warm-up) +#> Chain 1: 12.452 seconds (Sampling) +#> Chain 1: 25.416 seconds (Total) #> Chain 1: #> #> SAMPLING FOR MODEL 'COA_Standard_gaussian' NOW (CHAIN 2). #> Chain 2: -#> Chain 2: Gradient evaluation took 0.001036 seconds -#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 10.36 seconds. +#> Chain 2: Gradient evaluation took 0.00096 seconds +#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 9.6 seconds. #> Chain 2: Adjust your expectations accordingly! #> Chain 2: #> Chain 2: @@ -321,13 +321,13 @@ m <- COA_Standard( #> Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling) #> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 2: -#> Chain 2: Elapsed Time: 12.355 seconds (Warm-up) -#> Chain 2: 12.772 seconds (Sampling) -#> Chain 2: 25.127 seconds (Total) +#> Chain 2: Elapsed Time: 11.924 seconds (Warm-up) +#> Chain 2: 10.856 seconds (Sampling) +#> Chain 2: 22.78 seconds (Total) #> Chain 2: #> warmup sample -#> chain:1 13.128 10.399 -#> chain:2 12.355 12.772 +#> chain:1 12.964 12.452 +#> chain:2 11.924 10.856 ``` @@ -357,7 +357,7 @@ Let's look at our trace plots for the model parameters and posterior distributio stan_trace(m$model, pars = c("alpha0", "alpha1", "p0", "sigma")) ``` -![plot of chunk trace plots and post dist](figure/trace plots and post dist-1.png) +![](figure/trace plots and post dist-1.png) ``` r @@ -369,7 +369,7 @@ stan_dens( ) ``` -![plot of chunk trace plots and post dist](figure/trace plots and post dist-2.png) +![](figure/trace plots and post dist-2.png) We can see our trace plots look good and that the posterior distributions of our paramaters look good. @@ -382,7 +382,7 @@ this way and we recommend inspecting $\hat R$ and ESS. stan_trace(m$model, pars = c("sx[1,1]", "sx[1,2]", "sy[1,1]", "sy[1,2]")) ``` -![plot of chunk trace plots and post dist latent](figure/trace plots and post dist latent-1.png) +![](figure/trace plots and post dist latent-1.png) ``` r @@ -394,7 +394,7 @@ stan_dens( ) ``` -![plot of chunk trace plots and post dist latent](figure/trace plots and post dist latent-2.png) +![](figure/trace plots and post dist latent-2.png) Again, we can see that everything looks good and our model has converged. Now moving on to the other elements in the outputted object from `COA_*()`. @@ -405,9 +405,9 @@ The second element is a table of parameter estimates, `p0` which is the estimate ``` r m$summary -#> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat -#> p0 0.5021174 0.0009529285 0.01918709 0.4684838 0.4877082 0.5017623 0.5153259 0.5396254 405.4131 1.000994 -#> sigma 0.9952465 0.0014471561 0.02871756 0.9363534 0.9754131 0.9963352 1.0155073 1.0547302 393.7897 1.001954 +#> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat +#> p0 0.5018673 0.000965220 0.01893527 0.4670082 0.4887808 0.5021665 0.5152408 0.5360255 384.8492 1.003026 +#> sigma 0.9926248 0.001377877 0.02835745 0.9404584 0.9723176 0.9916287 1.0118301 1.0472763 423.5588 1.004424 ``` We can see that the mean detection probability at a distance of 0 m is 0.5 or 50% and that the model converged well for these parameters. @@ -417,7 +417,7 @@ The thrid element returned, is the time required to run the model in minutes. No ``` r m$time -#> [1] 0.8109 +#> [1] 0.8032667 ``` @@ -429,16 +429,16 @@ m$summary_draws #> # A tibble: 21 × 4 #> variable median q2.5 q97.5 #> -#> 1 alpha0 0.00705 -0.126 0.159 -#> 2 alpha1 0.504 0.449 0.570 -#> 3 sx[1,1] -2.97 -3.23 -2.68 -#> 4 sx[1,2] -2.94 -3.32 -2.61 -#> 5 sx[1,3] -2.13 -2.35 -1.92 -#> 6 sx[1,4] -2.27 -2.50 -2.05 -#> 7 sx[1,5] -2.79 -3.15 -2.49 -#> 8 sx[1,6] -2.30 -2.53 -2.06 -#> 9 sx[1,7] -2.29 -2.50 -2.08 -#> 10 sx[1,8] -2.98 -3.26 -2.73 +#> 1 alpha0 0.00867 -0.132 0.144 +#> 2 alpha1 0.508 0.456 0.565 +#> 3 sx[1,1] -2.96 -3.28 -2.67 +#> 4 sx[1,2] -2.96 -3.30 -2.61 +#> 5 sx[1,3] -2.12 -2.30 -1.91 +#> 6 sx[1,4] -2.26 -2.48 -2.04 +#> 7 sx[1,5] -2.77 -3.09 -2.47 +#> 8 sx[1,6] -2.29 -2.52 -2.05 +#> 9 sx[1,7] -2.28 -2.48 -2.07 +#> 10 sx[1,8] -2.98 -3.25 -2.73 #> # ℹ 11 more rows ``` @@ -450,14 +450,14 @@ m$coas #> # A tibble: 8 × 8 #> ind time x y x_lower x_upper y_lower y_upper #> -#> 1 1 1 -2.97 -0.515 -3.23 -2.68 -0.903 -0.163 -#> 2 1 2 -2.94 -0.326 -3.32 -2.61 -0.744 0.0513 -#> 3 1 3 -2.13 0.0554 -2.35 -1.92 -0.192 0.249 -#> 4 1 4 -2.27 0.145 -2.50 -2.05 -0.0818 0.383 -#> 5 1 5 -2.79 -0.285 -3.15 -2.49 -0.602 0.0360 -#> 6 1 6 -2.30 -0.728 -2.53 -2.06 -1.06 -0.445 -#> 7 1 7 -2.29 -0.0921 -2.50 -2.08 -0.295 0.129 -#> 8 1 8 -2.98 -0.476 -3.26 -2.73 -0.748 -0.160 +#> 1 1 1 -2.96 -0.518 -3.28 -2.67 -0.882 -0.179 +#> 2 1 2 -2.96 -0.331 -3.30 -2.61 -0.699 0.0925 +#> 3 1 3 -2.12 0.0652 -2.30 -1.91 -0.182 0.249 +#> 4 1 4 -2.26 0.144 -2.48 -2.04 -0.0993 0.396 +#> 5 1 5 -2.77 -0.273 -3.09 -2.47 -0.578 0.0535 +#> 6 1 6 -2.29 -0.715 -2.52 -2.05 -0.987 -0.461 +#> 7 1 7 -2.28 -0.0781 -2.48 -2.07 -0.279 0.125 +#> 8 1 8 -2.98 -0.473 -3.25 -2.73 -0.766 -0.184 ``` The sixth element returned, is a `data.frame` containing the posterior draws from each non-warm-up iteration from all chains. This contains the posterior distribution for each parameter and latent variable for each individual in each time step. It is unlikely that you will use this object instead we have created further objects that organize this data for specific applications that you are more likely to use. @@ -465,17 +465,17 @@ The sixth element returned, is a `data.frame` containing the posterior draws fro ``` r m$all_estimates #> # A draws_df: 200 iterations, 2 chains, and 21 variables -#> alpha0 alpha1 sx[1,1] sx[1,2] sx[1,3] sx[1,4] sx[1,5] sx[1,6] -#> 1 -0.11145 0.45 -3.2 -3.1 -2.2 -2.2 -2.7 -2.4 -#> 2 0.10130 0.49 -2.7 -3.0 -2.1 -2.2 -2.8 -2.3 -#> 3 0.08593 0.53 -3.0 -2.8 -2.2 -2.5 -3.0 -2.4 -#> 4 0.00502 0.48 -2.8 -3.0 -2.0 -2.2 -2.9 -2.0 -#> 5 -0.05169 0.48 -3.1 -3.0 -2.2 -2.5 -2.8 -2.2 -#> 6 -0.00041 0.52 -3.1 -2.8 -2.2 -2.4 -2.7 -2.1 -#> 7 -0.00792 0.48 -3.1 -3.1 -2.2 -2.4 -2.7 -2.2 -#> 8 -0.03658 0.47 -3.4 -3.4 -2.0 -2.4 -3.0 -2.5 -#> 9 0.00985 0.53 -2.9 -3.0 -2.2 -2.4 -2.7 -2.3 -#> 10 0.01182 0.54 -2.7 -2.8 -2.0 -2.2 -3.1 -2.0 +#> alpha0 alpha1 sx[1,1] sx[1,2] sx[1,3] sx[1,4] sx[1,5] sx[1,6] +#> 1 0.0491 0.52 -2.9 -2.9 -2.3 -2.2 -2.7 -2.3 +#> 2 0.1010 0.51 -3.1 -2.8 -2.1 -2.1 -2.8 -2.2 +#> 3 0.0498 0.52 -3.2 -2.6 -2.2 -2.1 -2.8 -2.1 +#> 4 0.0020 0.51 -2.8 -3.0 -2.2 -2.1 -2.9 -2.2 +#> 5 -0.0043 0.49 -2.9 -3.1 -2.1 -2.2 -3.0 -2.2 +#> 6 -0.0358 0.47 -2.9 -3.0 -2.1 -2.3 -2.6 -2.3 +#> 7 0.0061 0.53 -2.8 -3.1 -2.1 -2.2 -2.9 -2.2 +#> 8 0.0050 0.50 -2.7 -3.0 -2.2 -2.3 -2.7 -2.3 +#> 9 -0.0139 0.49 -2.9 -3.0 -2.2 -2.1 -2.9 -2.4 +#> 10 0.0076 0.49 -2.9 -3.0 -2.2 -2.0 -2.9 -2.3 #> # ... with 390 more draws, and 13 more variables #> # ... hidden reserved variables {'.chain', '.iteration', '.draw'} ``` @@ -490,18 +490,18 @@ Later on we will plot this object. loc_draws <- m$loc_draws loc_draws #> # A tibble: 3,200 × 8 -#> .chain .iteration .draw lp__ fish time x y -#> -#> 1 1 1 1 -1281. 1 1 -3.25 -0.609 -#> 2 1 1 1 -1281. 1 2 -3.08 -0.391 -#> 3 1 1 1 -1281. 1 3 -2.20 0.00656 -#> 4 1 1 1 -1281. 1 4 -2.23 0.122 -#> 5 1 1 1 -1281. 1 5 -2.75 -0.342 -#> 6 1 1 1 -1281. 1 6 -2.43 -0.610 -#> 7 1 1 1 -1281. 1 7 -2.31 -0.202 -#> 8 1 1 1 -1281. 1 8 -3.08 -0.503 -#> 9 1 2 2 -1289. 1 1 -2.75 -0.698 -#> 10 1 2 2 -1289. 1 2 -2.96 -0.546 +#> .chain .iteration .draw lp__ fish time x y +#> +#> 1 1 1 1 -1279. 1 1 -2.85 -0.723 +#> 2 1 1 1 -1279. 1 2 -2.87 -0.175 +#> 3 1 1 1 -1279. 1 3 -2.27 0.129 +#> 4 1 1 1 -1279. 1 4 -2.20 0.262 +#> 5 1 1 1 -1279. 1 5 -2.75 -0.190 +#> 6 1 1 1 -1279. 1 6 -2.26 -0.518 +#> 7 1 1 1 -1279. 1 7 -2.32 -0.184 +#> 8 1 1 1 -1279. 1 8 -2.95 -0.400 +#> 9 1 2 2 -1281. 1 1 -3.07 -0.440 +#> 10 1 2 2 -1281. 1 2 -2.80 -0.338 #> # ℹ 3,190 more rows ``` @@ -515,16 +515,16 @@ param_draws #> # A tibble: 6,400 × 10 #> .chain .iteration .draw lp__ fish time alpha0 alpha1 p0 sigma #> -#> 1 1 1 1 -1281. 1 1 -0.111 0.446 0.472 1.06 -#> 2 1 1 1 -1281. 1 2 -0.111 0.446 0.472 1.06 -#> 3 1 1 1 -1281. 1 3 -0.111 0.446 0.472 1.06 -#> 4 1 1 1 -1281. 1 4 -0.111 0.446 0.472 1.06 -#> 5 1 1 1 -1281. 1 5 -0.111 0.446 0.472 1.06 -#> 6 1 1 1 -1281. 1 6 -0.111 0.446 0.472 1.06 -#> 7 1 1 1 -1281. 1 7 -0.111 0.446 0.472 1.06 -#> 8 1 1 1 -1281. 1 8 -0.111 0.446 0.472 1.06 -#> 9 1 1 1 -1281. 1 1 -0.111 0.446 0.472 1.06 -#> 10 1 1 1 -1281. 1 2 -0.111 0.446 0.472 1.06 +#> 1 1 1 1 -1279. 1 1 0.0491 0.519 0.512 0.982 +#> 2 1 1 1 -1279. 1 2 0.0491 0.519 0.512 0.982 +#> 3 1 1 1 -1279. 1 3 0.0491 0.519 0.512 0.982 +#> 4 1 1 1 -1279. 1 4 0.0491 0.519 0.512 0.982 +#> 5 1 1 1 -1279. 1 5 0.0491 0.519 0.512 0.982 +#> 6 1 1 1 -1279. 1 6 0.0491 0.519 0.512 0.982 +#> 7 1 1 1 -1279. 1 7 0.0491 0.519 0.512 0.982 +#> 8 1 1 1 -1279. 1 8 0.0491 0.519 0.512 0.982 +#> 9 1 1 1 -1279. 1 1 0.0491 0.519 0.512 0.982 +#> 10 1 1 1 -1279. 1 2 0.0491 0.519 0.512 0.982 #> # ℹ 6,390 more rows ``` @@ -533,259 +533,12 @@ The ninth element returned is a `list` that contains generated quantities for `y ``` r yrep <- m$generated_quantities -yrep -#> $yrep -#> tag_1_rec_1_time_1 tag_1_rec_2_time_1 tag_1_rec_3_time_1 tag_1_rec_4_time_1 tag_1_rec_5_time_1 tag_1_rec_6_time_1 -#> yrep_1 0 3 3 9 3 8 -#> tag_1_rec_7_time_1 tag_1_rec_8_time_1 tag_1_rec_9_time_1 tag_1_rec_10_time_1 tag_1_rec_11_time_1 tag_1_rec_12_time_1 -#> yrep_1 10 4 1 1 0 0 -#> tag_1_rec_13_time_1 tag_1_rec_14_time_1 tag_1_rec_15_time_1 tag_1_rec_16_time_1 tag_1_rec_17_time_1 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_18_time_1 tag_1_rec_19_time_1 tag_1_rec_20_time_1 tag_1_rec_21_time_1 tag_1_rec_22_time_1 -#> yrep_1 1 3 3 3 0 -#> tag_1_rec_23_time_1 tag_1_rec_24_time_1 tag_1_rec_25_time_1 tag_1_rec_26_time_1 tag_1_rec_27_time_1 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_28_time_1 tag_1_rec_29_time_1 tag_1_rec_30_time_1 tag_1_rec_31_time_1 tag_1_rec_32_time_1 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_33_time_1 tag_1_rec_34_time_1 tag_1_rec_35_time_1 tag_1_rec_36_time_1 tag_1_rec_37_time_1 -#> yrep_1 0 1 0 0 0 -#> tag_1_rec_38_time_1 tag_1_rec_39_time_1 tag_1_rec_40_time_1 tag_1_rec_41_time_1 tag_1_rec_42_time_1 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_43_time_1 tag_1_rec_44_time_1 tag_1_rec_45_time_1 tag_1_rec_46_time_1 tag_1_rec_47_time_1 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_48_time_1 tag_1_rec_49_time_1 tag_1_rec_50_time_1 tag_1_rec_51_time_1 tag_1_rec_52_time_1 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_53_time_1 tag_1_rec_54_time_1 tag_1_rec_55_time_1 tag_1_rec_56_time_1 tag_1_rec_57_time_1 -#> yrep_1 0 0 1 0 0 -#> tag_1_rec_58_time_1 tag_1_rec_59_time_1 tag_1_rec_60_time_1 tag_1_rec_61_time_1 tag_1_rec_62_time_1 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_63_time_1 tag_1_rec_64_time_1 tag_1_rec_65_time_1 tag_1_rec_66_time_1 tag_1_rec_67_time_1 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_68_time_1 tag_1_rec_69_time_1 tag_1_rec_70_time_1 tag_1_rec_71_time_1 tag_1_rec_72_time_1 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_73_time_1 tag_1_rec_74_time_1 tag_1_rec_75_time_1 tag_1_rec_76_time_1 tag_1_rec_77_time_1 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_78_time_1 tag_1_rec_79_time_1 tag_1_rec_80_time_1 tag_1_rec_1_time_2 tag_1_rec_2_time_2 tag_1_rec_3_time_2 -#> yrep_1 0 0 0 0 0 5 -#> tag_1_rec_4_time_2 tag_1_rec_5_time_2 tag_1_rec_6_time_2 tag_1_rec_7_time_2 tag_1_rec_8_time_2 tag_1_rec_9_time_2 -#> yrep_1 5 6 6 10 2 0 -#> tag_1_rec_10_time_2 tag_1_rec_11_time_2 tag_1_rec_12_time_2 tag_1_rec_13_time_2 tag_1_rec_14_time_2 -#> yrep_1 1 0 0 0 0 -#> tag_1_rec_15_time_2 tag_1_rec_16_time_2 tag_1_rec_17_time_2 tag_1_rec_18_time_2 tag_1_rec_19_time_2 -#> yrep_1 0 0 0 1 2 -#> tag_1_rec_20_time_2 tag_1_rec_21_time_2 tag_1_rec_22_time_2 tag_1_rec_23_time_2 tag_1_rec_24_time_2 -#> yrep_1 3 1 4 0 1 -#> tag_1_rec_25_time_2 tag_1_rec_26_time_2 tag_1_rec_27_time_2 tag_1_rec_28_time_2 tag_1_rec_29_time_2 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_30_time_2 tag_1_rec_31_time_2 tag_1_rec_32_time_2 tag_1_rec_33_time_2 tag_1_rec_34_time_2 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_35_time_2 tag_1_rec_36_time_2 tag_1_rec_37_time_2 tag_1_rec_38_time_2 tag_1_rec_39_time_2 -#> yrep_1 0 0 1 0 0 -#> tag_1_rec_40_time_2 tag_1_rec_41_time_2 tag_1_rec_42_time_2 tag_1_rec_43_time_2 tag_1_rec_44_time_2 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_45_time_2 tag_1_rec_46_time_2 tag_1_rec_47_time_2 tag_1_rec_48_time_2 tag_1_rec_49_time_2 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_50_time_2 tag_1_rec_51_time_2 tag_1_rec_52_time_2 tag_1_rec_53_time_2 tag_1_rec_54_time_2 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_55_time_2 tag_1_rec_56_time_2 tag_1_rec_57_time_2 tag_1_rec_58_time_2 tag_1_rec_59_time_2 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_60_time_2 tag_1_rec_61_time_2 tag_1_rec_62_time_2 tag_1_rec_63_time_2 tag_1_rec_64_time_2 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_65_time_2 tag_1_rec_66_time_2 tag_1_rec_67_time_2 tag_1_rec_68_time_2 tag_1_rec_69_time_2 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_70_time_2 tag_1_rec_71_time_2 tag_1_rec_72_time_2 tag_1_rec_73_time_2 tag_1_rec_74_time_2 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_75_time_2 tag_1_rec_76_time_2 tag_1_rec_77_time_2 tag_1_rec_78_time_2 tag_1_rec_79_time_2 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_80_time_2 tag_1_rec_1_time_3 tag_1_rec_2_time_3 tag_1_rec_3_time_3 tag_1_rec_4_time_3 tag_1_rec_5_time_3 -#> yrep_1 0 0 0 7 9 2 -#> tag_1_rec_6_time_3 tag_1_rec_7_time_3 tag_1_rec_8_time_3 tag_1_rec_9_time_3 tag_1_rec_10_time_3 tag_1_rec_11_time_3 -#> yrep_1 2 5 7 7 1 0 -#> tag_1_rec_12_time_3 tag_1_rec_13_time_3 tag_1_rec_14_time_3 tag_1_rec_15_time_3 tag_1_rec_16_time_3 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_17_time_3 tag_1_rec_18_time_3 tag_1_rec_19_time_3 tag_1_rec_20_time_3 tag_1_rec_21_time_3 -#> yrep_1 1 4 4 8 2 -#> tag_1_rec_22_time_3 tag_1_rec_23_time_3 tag_1_rec_24_time_3 tag_1_rec_25_time_3 tag_1_rec_26_time_3 -#> yrep_1 5 0 4 1 0 -#> tag_1_rec_27_time_3 tag_1_rec_28_time_3 tag_1_rec_29_time_3 tag_1_rec_30_time_3 tag_1_rec_31_time_3 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_32_time_3 tag_1_rec_33_time_3 tag_1_rec_34_time_3 tag_1_rec_35_time_3 tag_1_rec_36_time_3 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_37_time_3 tag_1_rec_38_time_3 tag_1_rec_39_time_3 tag_1_rec_40_time_3 tag_1_rec_41_time_3 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_42_time_3 tag_1_rec_43_time_3 tag_1_rec_44_time_3 tag_1_rec_45_time_3 tag_1_rec_46_time_3 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_47_time_3 tag_1_rec_48_time_3 tag_1_rec_49_time_3 tag_1_rec_50_time_3 tag_1_rec_51_time_3 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_52_time_3 tag_1_rec_53_time_3 tag_1_rec_54_time_3 tag_1_rec_55_time_3 tag_1_rec_56_time_3 -#> yrep_1 0 0 3 2 1 -#> tag_1_rec_57_time_3 tag_1_rec_58_time_3 tag_1_rec_59_time_3 tag_1_rec_60_time_3 tag_1_rec_61_time_3 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_62_time_3 tag_1_rec_63_time_3 tag_1_rec_64_time_3 tag_1_rec_65_time_3 tag_1_rec_66_time_3 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_67_time_3 tag_1_rec_68_time_3 tag_1_rec_69_time_3 tag_1_rec_70_time_3 tag_1_rec_71_time_3 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_72_time_3 tag_1_rec_73_time_3 tag_1_rec_74_time_3 tag_1_rec_75_time_3 tag_1_rec_76_time_3 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_77_time_3 tag_1_rec_78_time_3 tag_1_rec_79_time_3 tag_1_rec_80_time_3 tag_1_rec_1_time_4 tag_1_rec_2_time_4 -#> yrep_1 0 0 0 0 2 1 -#> tag_1_rec_3_time_4 tag_1_rec_4_time_4 tag_1_rec_5_time_4 tag_1_rec_6_time_4 tag_1_rec_7_time_4 tag_1_rec_8_time_4 -#> yrep_1 6 4 1 3 3 9 -#> tag_1_rec_9_time_4 tag_1_rec_10_time_4 tag_1_rec_11_time_4 tag_1_rec_12_time_4 tag_1_rec_13_time_4 -#> yrep_1 3 1 0 0 0 -#> tag_1_rec_14_time_4 tag_1_rec_15_time_4 tag_1_rec_16_time_4 tag_1_rec_17_time_4 tag_1_rec_18_time_4 -#> yrep_1 0 0 0 3 4 -#> tag_1_rec_19_time_4 tag_1_rec_20_time_4 tag_1_rec_21_time_4 tag_1_rec_22_time_4 tag_1_rec_23_time_4 -#> yrep_1 6 10 2 1 3 -#> tag_1_rec_24_time_4 tag_1_rec_25_time_4 tag_1_rec_26_time_4 tag_1_rec_27_time_4 tag_1_rec_28_time_4 -#> yrep_1 1 1 0 0 0 -#> tag_1_rec_29_time_4 tag_1_rec_30_time_4 tag_1_rec_31_time_4 tag_1_rec_32_time_4 tag_1_rec_33_time_4 -#> yrep_1 0 0 0 1 0 -#> tag_1_rec_34_time_4 tag_1_rec_35_time_4 tag_1_rec_36_time_4 tag_1_rec_37_time_4 tag_1_rec_38_time_4 -#> yrep_1 1 1 0 0 0 -#> tag_1_rec_39_time_4 tag_1_rec_40_time_4 tag_1_rec_41_time_4 tag_1_rec_42_time_4 tag_1_rec_43_time_4 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_44_time_4 tag_1_rec_45_time_4 tag_1_rec_46_time_4 tag_1_rec_47_time_4 tag_1_rec_48_time_4 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_49_time_4 tag_1_rec_50_time_4 tag_1_rec_51_time_4 tag_1_rec_52_time_4 tag_1_rec_53_time_4 -#> yrep_1 0 0 0 1 0 -#> tag_1_rec_54_time_4 tag_1_rec_55_time_4 tag_1_rec_56_time_4 tag_1_rec_57_time_4 tag_1_rec_58_time_4 -#> yrep_1 1 0 0 0 0 -#> tag_1_rec_59_time_4 tag_1_rec_60_time_4 tag_1_rec_61_time_4 tag_1_rec_62_time_4 tag_1_rec_63_time_4 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_64_time_4 tag_1_rec_65_time_4 tag_1_rec_66_time_4 tag_1_rec_67_time_4 tag_1_rec_68_time_4 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_69_time_4 tag_1_rec_70_time_4 tag_1_rec_71_time_4 tag_1_rec_72_time_4 tag_1_rec_73_time_4 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_74_time_4 tag_1_rec_75_time_4 tag_1_rec_76_time_4 tag_1_rec_77_time_4 tag_1_rec_78_time_4 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_79_time_4 tag_1_rec_80_time_4 tag_1_rec_1_time_5 tag_1_rec_2_time_5 tag_1_rec_3_time_5 tag_1_rec_4_time_5 -#> yrep_1 0 0 1 7 4 8 -#> tag_1_rec_5_time_5 tag_1_rec_6_time_5 tag_1_rec_7_time_5 tag_1_rec_8_time_5 tag_1_rec_9_time_5 tag_1_rec_10_time_5 -#> yrep_1 3 3 8 5 1 0 -#> tag_1_rec_11_time_5 tag_1_rec_12_time_5 tag_1_rec_13_time_5 tag_1_rec_14_time_5 tag_1_rec_15_time_5 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_16_time_5 tag_1_rec_17_time_5 tag_1_rec_18_time_5 tag_1_rec_19_time_5 tag_1_rec_20_time_5 -#> yrep_1 0 0 2 1 3 -#> tag_1_rec_21_time_5 tag_1_rec_22_time_5 tag_1_rec_23_time_5 tag_1_rec_24_time_5 tag_1_rec_25_time_5 -#> yrep_1 0 1 1 0 0 -#> tag_1_rec_26_time_5 tag_1_rec_27_time_5 tag_1_rec_28_time_5 tag_1_rec_29_time_5 tag_1_rec_30_time_5 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_31_time_5 tag_1_rec_32_time_5 tag_1_rec_33_time_5 tag_1_rec_34_time_5 tag_1_rec_35_time_5 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_36_time_5 tag_1_rec_37_time_5 tag_1_rec_38_time_5 tag_1_rec_39_time_5 tag_1_rec_40_time_5 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_41_time_5 tag_1_rec_42_time_5 tag_1_rec_43_time_5 tag_1_rec_44_time_5 tag_1_rec_45_time_5 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_46_time_5 tag_1_rec_47_time_5 tag_1_rec_48_time_5 tag_1_rec_49_time_5 tag_1_rec_50_time_5 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_51_time_5 tag_1_rec_52_time_5 tag_1_rec_53_time_5 tag_1_rec_54_time_5 tag_1_rec_55_time_5 -#> yrep_1 0 1 0 2 0 -#> tag_1_rec_56_time_5 tag_1_rec_57_time_5 tag_1_rec_58_time_5 tag_1_rec_59_time_5 tag_1_rec_60_time_5 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_61_time_5 tag_1_rec_62_time_5 tag_1_rec_63_time_5 tag_1_rec_64_time_5 tag_1_rec_65_time_5 -#> yrep_1 0 0 0 0 1 -#> tag_1_rec_66_time_5 tag_1_rec_67_time_5 tag_1_rec_68_time_5 tag_1_rec_69_time_5 tag_1_rec_70_time_5 -#> yrep_1 1 0 0 0 0 -#> tag_1_rec_71_time_5 tag_1_rec_72_time_5 tag_1_rec_73_time_5 tag_1_rec_74_time_5 tag_1_rec_75_time_5 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_76_time_5 tag_1_rec_77_time_5 tag_1_rec_78_time_5 tag_1_rec_79_time_5 tag_1_rec_80_time_5 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_1_time_6 tag_1_rec_2_time_6 tag_1_rec_3_time_6 tag_1_rec_4_time_6 tag_1_rec_5_time_6 tag_1_rec_6_time_6 -#> yrep_1 2 5 6 7 9 3 -#> tag_1_rec_7_time_6 tag_1_rec_8_time_6 tag_1_rec_9_time_6 tag_1_rec_10_time_6 tag_1_rec_11_time_6 tag_1_rec_12_time_6 -#> yrep_1 5 6 2 0 1 0 -#> tag_1_rec_13_time_6 tag_1_rec_14_time_6 tag_1_rec_15_time_6 tag_1_rec_16_time_6 tag_1_rec_17_time_6 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_18_time_6 tag_1_rec_19_time_6 tag_1_rec_20_time_6 tag_1_rec_21_time_6 tag_1_rec_22_time_6 -#> yrep_1 2 2 3 0 0 -#> tag_1_rec_23_time_6 tag_1_rec_24_time_6 tag_1_rec_25_time_6 tag_1_rec_26_time_6 tag_1_rec_27_time_6 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_28_time_6 tag_1_rec_29_time_6 tag_1_rec_30_time_6 tag_1_rec_31_time_6 tag_1_rec_32_time_6 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_33_time_6 tag_1_rec_34_time_6 tag_1_rec_35_time_6 tag_1_rec_36_time_6 tag_1_rec_37_time_6 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_38_time_6 tag_1_rec_39_time_6 tag_1_rec_40_time_6 tag_1_rec_41_time_6 tag_1_rec_42_time_6 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_43_time_6 tag_1_rec_44_time_6 tag_1_rec_45_time_6 tag_1_rec_46_time_6 tag_1_rec_47_time_6 -#> yrep_1 1 1 0 0 0 -#> tag_1_rec_48_time_6 tag_1_rec_49_time_6 tag_1_rec_50_time_6 tag_1_rec_51_time_6 tag_1_rec_52_time_6 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_53_time_6 tag_1_rec_54_time_6 tag_1_rec_55_time_6 tag_1_rec_56_time_6 tag_1_rec_57_time_6 -#> yrep_1 0 2 0 0 0 -#> tag_1_rec_58_time_6 tag_1_rec_59_time_6 tag_1_rec_60_time_6 tag_1_rec_61_time_6 tag_1_rec_62_time_6 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_63_time_6 tag_1_rec_64_time_6 tag_1_rec_65_time_6 tag_1_rec_66_time_6 tag_1_rec_67_time_6 -#> yrep_1 0 0 0 0 1 -#> tag_1_rec_68_time_6 tag_1_rec_69_time_6 tag_1_rec_70_time_6 tag_1_rec_71_time_6 tag_1_rec_72_time_6 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_73_time_6 tag_1_rec_74_time_6 tag_1_rec_75_time_6 tag_1_rec_76_time_6 tag_1_rec_77_time_6 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_78_time_6 tag_1_rec_79_time_6 tag_1_rec_80_time_6 tag_1_rec_1_time_7 tag_1_rec_2_time_7 tag_1_rec_3_time_7 -#> yrep_1 0 0 0 2 6 6 -#> tag_1_rec_4_time_7 tag_1_rec_5_time_7 tag_1_rec_6_time_7 tag_1_rec_7_time_7 tag_1_rec_8_time_7 tag_1_rec_9_time_7 -#> yrep_1 2 3 6 12 8 6 -#> tag_1_rec_10_time_7 tag_1_rec_11_time_7 tag_1_rec_12_time_7 tag_1_rec_13_time_7 tag_1_rec_14_time_7 -#> yrep_1 1 0 0 0 0 -#> tag_1_rec_15_time_7 tag_1_rec_16_time_7 tag_1_rec_17_time_7 tag_1_rec_18_time_7 tag_1_rec_19_time_7 -#> yrep_1 0 0 0 4 2 -#> tag_1_rec_20_time_7 tag_1_rec_21_time_7 tag_1_rec_22_time_7 tag_1_rec_23_time_7 tag_1_rec_24_time_7 -#> yrep_1 6 1 3 1 1 -#> tag_1_rec_25_time_7 tag_1_rec_26_time_7 tag_1_rec_27_time_7 tag_1_rec_28_time_7 tag_1_rec_29_time_7 -#> yrep_1 0 1 0 0 0 -#> tag_1_rec_30_time_7 tag_1_rec_31_time_7 tag_1_rec_32_time_7 tag_1_rec_33_time_7 tag_1_rec_34_time_7 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_35_time_7 tag_1_rec_36_time_7 tag_1_rec_37_time_7 tag_1_rec_38_time_7 tag_1_rec_39_time_7 -#> yrep_1 1 0 0 0 0 -#> tag_1_rec_40_time_7 tag_1_rec_41_time_7 tag_1_rec_42_time_7 tag_1_rec_43_time_7 tag_1_rec_44_time_7 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_45_time_7 tag_1_rec_46_time_7 tag_1_rec_47_time_7 tag_1_rec_48_time_7 tag_1_rec_49_time_7 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_50_time_7 tag_1_rec_51_time_7 tag_1_rec_52_time_7 tag_1_rec_53_time_7 tag_1_rec_54_time_7 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_55_time_7 tag_1_rec_56_time_7 tag_1_rec_57_time_7 tag_1_rec_58_time_7 tag_1_rec_59_time_7 -#> yrep_1 2 0 1 0 0 -#> tag_1_rec_60_time_7 tag_1_rec_61_time_7 tag_1_rec_62_time_7 tag_1_rec_63_time_7 tag_1_rec_64_time_7 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_65_time_7 tag_1_rec_66_time_7 tag_1_rec_67_time_7 tag_1_rec_68_time_7 tag_1_rec_69_time_7 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_70_time_7 tag_1_rec_71_time_7 tag_1_rec_72_time_7 tag_1_rec_73_time_7 tag_1_rec_74_time_7 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_75_time_7 tag_1_rec_76_time_7 tag_1_rec_77_time_7 tag_1_rec_78_time_7 tag_1_rec_79_time_7 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_80_time_7 tag_1_rec_1_time_8 tag_1_rec_2_time_8 tag_1_rec_3_time_8 tag_1_rec_4_time_8 tag_1_rec_5_time_8 -#> yrep_1 0 2 0 5 7 10 -#> tag_1_rec_6_time_8 tag_1_rec_7_time_8 tag_1_rec_8_time_8 tag_1_rec_9_time_8 tag_1_rec_10_time_8 tag_1_rec_11_time_8 -#> yrep_1 4 8 3 0 0 0 -#> tag_1_rec_12_time_8 tag_1_rec_13_time_8 tag_1_rec_14_time_8 tag_1_rec_15_time_8 tag_1_rec_16_time_8 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_17_time_8 tag_1_rec_18_time_8 tag_1_rec_19_time_8 tag_1_rec_20_time_8 tag_1_rec_21_time_8 -#> yrep_1 0 0 1 2 0 -#> tag_1_rec_22_time_8 tag_1_rec_23_time_8 tag_1_rec_24_time_8 tag_1_rec_25_time_8 tag_1_rec_26_time_8 -#> yrep_1 0 1 0 0 0 -#> tag_1_rec_27_time_8 tag_1_rec_28_time_8 tag_1_rec_29_time_8 tag_1_rec_30_time_8 tag_1_rec_31_time_8 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_32_time_8 tag_1_rec_33_time_8 tag_1_rec_34_time_8 tag_1_rec_35_time_8 tag_1_rec_36_time_8 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_37_time_8 tag_1_rec_38_time_8 tag_1_rec_39_time_8 tag_1_rec_40_time_8 tag_1_rec_41_time_8 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_42_time_8 tag_1_rec_43_time_8 tag_1_rec_44_time_8 tag_1_rec_45_time_8 tag_1_rec_46_time_8 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_47_time_8 tag_1_rec_48_time_8 tag_1_rec_49_time_8 tag_1_rec_50_time_8 tag_1_rec_51_time_8 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_52_time_8 tag_1_rec_53_time_8 tag_1_rec_54_time_8 tag_1_rec_55_time_8 tag_1_rec_56_time_8 -#> yrep_1 0 0 1 0 0 -#> tag_1_rec_57_time_8 tag_1_rec_58_time_8 tag_1_rec_59_time_8 tag_1_rec_60_time_8 tag_1_rec_61_time_8 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_62_time_8 tag_1_rec_63_time_8 tag_1_rec_64_time_8 tag_1_rec_65_time_8 tag_1_rec_66_time_8 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_67_time_8 tag_1_rec_68_time_8 tag_1_rec_69_time_8 tag_1_rec_70_time_8 tag_1_rec_71_time_8 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_72_time_8 tag_1_rec_73_time_8 tag_1_rec_74_time_8 tag_1_rec_75_time_8 tag_1_rec_76_time_8 -#> yrep_1 0 0 0 0 0 -#> tag_1_rec_77_time_8 tag_1_rec_78_time_8 tag_1_rec_79_time_8 tag_1_rec_80_time_8 -#> yrep_1 0 0 0 0 -#> [ reached 'max' / getOption("max.print") -- omitted 9 rows ] +str(yrep) +#> List of 1 +#> $ yrep: int [1:10, 1:640] 1 2 2 0 4 0 0 2 0 1 ... +#> ..- attr(*, "dimnames")=List of 2 +#> .. ..$ : chr [1:10] "yrep_1" "yrep_2" "yrep_3" "yrep_4" ... +#> .. ..$ : chr [1:640] "tag_1_rec_1_time_1" "tag_1_rec_2_time_1" "tag_1_rec_3_time_1" "tag_1_rec_4_time_1" ... ``` ## Plotting @@ -829,7 +582,7 @@ Let's first look at the posterior densities for each time step p1 ``` -![plot of chunk post densities timestep](figure/post densities timestep-1.png) +![](figure/post densities timestep-1.png) Next let's look at the densities combined to gather a better understanding of the movement over the 8 timesteps. @@ -838,7 +591,7 @@ Next let's look at the densities combined to gather a better understanding of th p ``` -![plot of chunk post densities combined](figure/post densities combined-1.png) +![](figure/post densities combined-1.png) Next we can plot the posterior distributions for `alpha0`, `alpha1`, `p0`, and `sigma`. We need to first make `fish` and `time` a `character` and then to make plotting easier we need to make the `data.frame` in long format. @@ -876,7 +629,8 @@ p_param <- ggplot( p_param ``` -![plot of chunk plot param](figure/plot param-1.png) +![](figure/plot param-1.png) + We can see that they are all quite tightly distributed with `p0` indicating that detection probability at a distance of `0` is between 48 - 54 %, while the `sigma` is around 1 km. Lastly, we can plot the predictive posterior check using `{tidybayes}`. First we need to make @@ -893,7 +647,7 @@ ppc <- ppc_dens_overlay(y = y_obs, yrep = yrep$yrep) ppc ``` -![plot of chunk ppc dens](figure/ppc dens-1.png) +![](figure/ppc dens-1.png) We can see our predictive posterior check distribution for 10 draws closely lines up with our observed detection counts indicating that the model fits the data well.