This function summarizes the posterior distributions of specified parameters from a model fit. Summary includes mean, sd, and specified quantiles, as well as effective sample size (n_eff) and Rhat for estimated parameters. See more examples in the Package Vignette.
Usage
jointSummarize(modelfit, par = "all", probs = c(0.025, 0.975), digits = 3)
Note
Before fitting the model, this function checks to ensure that the function is possible given the inputs. These checks include:
Input model fit is an object of class 'stanfit'.
Input probs is a numeric vector.
Input par is a character vector.
Input par are present in fitted model.
Input model fit has converged (i.e. no divergent transitions after warm-up).
If any of these checks fail, the function returns an error message.
Examples
# \donttest{
data(greencrabData)
# Fit a model
modelfit <- jointModel(data = greencrabData, family = "negbin", q = TRUE,
multicore = FALSE)
#>
#> SAMPLING FOR MODEL 'joint_binary_catchability_negbin' NOW (CHAIN 1).
#> Chain 1:
#> Chain 1: Gradient evaluation took 0.000277 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 2.77 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1:
#> Chain 1:
#> Chain 1: Iteration: 1 / 3000 [ 0%] (Warmup)
#> Chain 1: Iteration: 500 / 3000 [ 16%] (Warmup)
#> Chain 1: Iteration: 501 / 3000 [ 16%] (Sampling)
#> Chain 1: Iteration: 1000 / 3000 [ 33%] (Sampling)
#> Chain 1: Iteration: 1500 / 3000 [ 50%] (Sampling)
#> Chain 1: Iteration: 2000 / 3000 [ 66%] (Sampling)
#> Chain 1: Iteration: 2500 / 3000 [ 83%] (Sampling)
#> Chain 1: Iteration: 3000 / 3000 [100%] (Sampling)
#> Chain 1:
#> Chain 1: Elapsed Time: 3.42 seconds (Warm-up)
#> Chain 1: 11.581 seconds (Sampling)
#> Chain 1: 15.001 seconds (Total)
#> Chain 1:
#>
#> SAMPLING FOR MODEL 'joint_binary_catchability_negbin' NOW (CHAIN 2).
#> Chain 2:
#> Chain 2: Gradient evaluation took 0.000318 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 3.18 seconds.
#> Chain 2: Adjust your expectations accordingly!
#> Chain 2:
#> Chain 2:
#> Chain 2: Iteration: 1 / 3000 [ 0%] (Warmup)
#> Chain 2: Iteration: 500 / 3000 [ 16%] (Warmup)
#> Chain 2: Iteration: 501 / 3000 [ 16%] (Sampling)
#> Chain 2: Iteration: 1000 / 3000 [ 33%] (Sampling)
#> Chain 2: Iteration: 1500 / 3000 [ 50%] (Sampling)
#> Chain 2: Iteration: 2000 / 3000 [ 66%] (Sampling)
#> Chain 2: Iteration: 2500 / 3000 [ 83%] (Sampling)
#> Chain 2: Iteration: 3000 / 3000 [100%] (Sampling)
#> Chain 2:
#> Chain 2: Elapsed Time: 3.441 seconds (Warm-up)
#> Chain 2: 8.279 seconds (Sampling)
#> Chain 2: 11.72 seconds (Total)
#> Chain 2:
#>
#> SAMPLING FOR MODEL 'joint_binary_catchability_negbin' NOW (CHAIN 3).
#> Chain 3:
#> Chain 3: Gradient evaluation took 0.00032 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 3.2 seconds.
#> Chain 3: Adjust your expectations accordingly!
#> Chain 3:
#> Chain 3:
#> Chain 3: Iteration: 1 / 3000 [ 0%] (Warmup)
#> Chain 3: Iteration: 500 / 3000 [ 16%] (Warmup)
#> Chain 3: Iteration: 501 / 3000 [ 16%] (Sampling)
#> Chain 3: Iteration: 1000 / 3000 [ 33%] (Sampling)
#> Chain 3: Iteration: 1500 / 3000 [ 50%] (Sampling)
#> Chain 3: Iteration: 2000 / 3000 [ 66%] (Sampling)
#> Chain 3: Iteration: 2500 / 3000 [ 83%] (Sampling)
#> Chain 3: Iteration: 3000 / 3000 [100%] (Sampling)
#> Chain 3:
#> Chain 3: Elapsed Time: 3.488 seconds (Warm-up)
#> Chain 3: 11.318 seconds (Sampling)
#> Chain 3: 14.806 seconds (Total)
#> Chain 3:
#>
#> SAMPLING FOR MODEL 'joint_binary_catchability_negbin' NOW (CHAIN 4).
#> Chain 4:
#> Chain 4: Gradient evaluation took 0.000322 seconds
#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 3.22 seconds.
#> Chain 4: Adjust your expectations accordingly!
#> Chain 4:
#> Chain 4:
#> Chain 4: Iteration: 1 / 3000 [ 0%] (Warmup)
#> Chain 4: Iteration: 500 / 3000 [ 16%] (Warmup)
#> Chain 4: Iteration: 501 / 3000 [ 16%] (Sampling)
#> Chain 4: Iteration: 1000 / 3000 [ 33%] (Sampling)
#> Chain 4: Iteration: 1500 / 3000 [ 50%] (Sampling)
#> Chain 4: Iteration: 2000 / 3000 [ 66%] (Sampling)
#> Chain 4: Iteration: 2500 / 3000 [ 83%] (Sampling)
#> Chain 4: Iteration: 3000 / 3000 [100%] (Sampling)
#> Chain 4:
#> Chain 4: Elapsed Time: 3.519 seconds (Warm-up)
#> Chain 4: 11.246 seconds (Sampling)
#> Chain 4: 14.765 seconds (Total)
#> Chain 4:
#> Refer to the eDNAjoint guide for visualization tips: https://ednajoint.netlify.app/tips#visualization-tips
# Create summary table of all parameters
jointSummarize(modelfit$model)
#> mean se_mean sd 2.5% 97.5% n_eff Rhat
#> mu[1,1] 0.106 0.000 0.027 0.060 0.168 12359.010 1
#> mu[1,2] 0.084 0.000 0.022 0.046 0.134 12265.040 1
#> mu[2,1] 0.032 0.000 0.032 0.001 0.119 12956.182 1
#> mu[2,2] 0.026 0.000 0.026 0.001 0.095 13312.843 1
#> mu[3,1] 0.017 0.000 0.017 0.000 0.061 16304.617 1
#> mu[3,2] 0.013 0.000 0.013 0.000 0.048 16196.045 1
#> mu[4,1] 0.678 0.001 0.108 0.491 0.910 12094.958 1
#> mu[4,2] 0.535 0.001 0.091 0.378 0.732 13913.514 1
#> mu[5,1] 0.097 0.001 0.104 0.003 0.379 13798.872 1
#> mu[5,2] 0.077 0.001 0.082 0.002 0.299 13838.035 1
#> mu[6,1] 0.120 0.001 0.130 0.003 0.469 14507.672 1
#> mu[6,2] 0.095 0.001 0.102 0.002 0.364 14586.878 1
#> mu[7,1] 0.013 0.000 0.013 0.000 0.048 14219.485 1
#> mu[7,2] 0.010 0.000 0.010 0.000 0.037 14244.643 1
#> mu[8,1] 0.302 0.003 0.288 0.013 1.061 12800.478 1
#> mu[8,2] 0.238 0.002 0.228 0.010 0.841 13018.581 1
#> mu[9,1] 0.034 0.000 0.032 0.001 0.118 14154.367 1
#> mu[9,2] 0.027 0.000 0.025 0.001 0.093 13860.695 1
#> mu[10,1] 1.043 0.002 0.242 0.650 1.598 13086.667 1
#> mu[10,2] 0.821 0.001 0.186 0.511 1.243 15690.339 1
#> mu[11,1] 0.304 0.003 0.288 0.011 1.052 13071.798 1
#> mu[11,2] 0.240 0.002 0.228 0.009 0.847 12961.337 1
#> mu[12,1] 0.021 0.000 0.022 0.001 0.078 15261.777 1
#> mu[12,2] 0.017 0.000 0.017 0.000 0.062 14787.681 1
#> mu[13,1] 7.685 0.013 1.329 5.471 10.705 10691.991 1
#> mu[13,2] 6.046 0.008 0.995 4.393 8.295 14183.850 1
#> mu[14,1] 0.119 0.000 0.020 0.083 0.162 11994.137 1
#> mu[14,2] 0.094 0.000 0.016 0.065 0.128 15694.801 1
#> mu[15,1] 0.764 0.005 0.545 0.108 2.145 12631.143 1
#> mu[15,2] 0.602 0.004 0.431 0.085 1.691 12929.281 1
#> mu[16,1] 3.810 0.006 0.662 2.684 5.278 10382.789 1
#> mu[16,2] 2.994 0.004 0.474 2.188 4.042 14691.203 1
#> mu[17,1] 0.163 0.002 0.178 0.004 0.642 13153.765 1
#> mu[17,2] 0.128 0.001 0.141 0.003 0.509 12978.636 1
#> mu[18,1] 3.321 0.011 1.100 1.740 5.962 10493.096 1
#> mu[18,2] 2.616 0.009 0.864 1.361 4.679 10289.748 1
#> mu[19,1] 3.936 0.007 0.714 2.762 5.566 9979.501 1
#> mu[19,2] 3.103 0.005 0.576 2.144 4.413 12925.666 1
#> mu[20,1] 0.119 0.001 0.069 0.027 0.291 14453.422 1
#> mu[20,2] 0.094 0.000 0.054 0.021 0.228 14998.787 1
#> q[1] 0.794 0.001 0.103 0.612 1.016 7211.255 1
#> p10 0.018 0.000 0.010 0.005 0.042 11606.815 1
#> beta 1.264 0.002 0.249 0.782 1.753 10683.881 1
#> phi 0.918 0.001 0.131 0.692 1.199 11325.486 1
# Summarize just 'p10' parameter
jointSummarize(modelfit$model, par = "p10", probs = c(0.025, 0.975),
digits = 3)
#> mean se_mean sd 2.5% 97.5% n_eff Rhat
#> p10 0.018 0 0.01 0.005 0.042 11606.82 1
# }