This function imports a list of BUGS outputs previously exported by
fit_trend()
. Users can import one, several, or all models.
Arguments
- series
a vector of
character
strings. One or several count series names. IfNULL
(default) BUGS outputs for all count series will be imported. Users can runlist_series()
to get the correct spelling of count series names.- path
a
character
string. The directory in which BUGS outputs have been saved by the functionfit_trend()
.
Value
An n-element list
(where n
is the number of count series). See
fit_trend()
for further information.
Examples
## Load Garamba raw dataset ----
file_path <- system.file("extdata", "garamba_survey.csv",
package = "popbayes")
garamba <- read.csv(file = file_path)
## Create temporary folder ----
temp_path <- tempdir()
## Format dataset ----
garamba_formatted <- popbayes::format_data(
data = garamba,
path = temp_path,
field_method = "field_method",
pref_field_method = "pref_field_method",
conversion_A2G = "conversion_A2G",
rmax = "rmax")
#> ✔ Detecting 10 count series.
## Select one serie ----
a_buselaphus <- popbayes::filter_series(garamba_formatted,
location = "Garamba",
species = "Alcelaphus buselaphus")
#> ✔ Found 1 series with "Alcelaphus buselaphus" and "Garamba".
# \donttest{
## Fit population trends (requires JAGS) ----
a_buselaphus_mod <- popbayes::fit_trend(a_buselaphus, path = temp_path)
#> Compiling data graph
#> Resolving undeclared variables
#> Allocating nodes
#> Initializing
#> Reading data back into data table
#> Compiling model graph
#> Resolving undeclared variables
#> Allocating nodes
#> Graph information:
#> Observed stochastic nodes: 15
#> Unobserved stochastic nodes: 15
#> Total graph size: 227
#>
#> Initializing model
#>
## Import BUGS outputs for one count series ----
popbayes::read_bugs(series = "garamba__alcelaphus_buselaphus",
path = temp_path)
#> $garamba__alcelaphus_buselaphus
#> Inference for Bugs model at "model.bug", fit using jags,
#> 2 chains, each with 50000 iterations (first 10000 discarded), n.thin = 3
#> n.sims = 26666 iterations saved
#> mu.vect sd.vect 2.5% 25% 50% 75% 97.5%
#> N[1] 17704.622 1732.733 14325.106 16540.416 17703.472 18854.702 21163.344
#> N[2] 3852.142 502.639 2892.122 3508.397 3843.527 4184.916 4857.835
#> N[3] 3313.482 390.724 2546.642 3049.617 3310.108 3578.820 4084.715
#> N[4] 3014.466 429.307 2205.787 2717.981 3003.240 3293.856 3893.400
#> N[5] 2675.016 326.426 2044.811 2451.061 2673.333 2895.294 3318.233
#> N[6] 3218.382 532.626 2269.759 2844.462 3181.803 3555.310 4353.830
#> N[7] 3748.142 663.983 2546.570 3288.082 3705.828 4163.506 5177.966
#> N[8] 3466.347 365.261 2769.738 3216.155 3459.593 3711.216 4200.803
#> N[9] 2886.866 208.334 2487.130 2745.760 2884.456 3027.397 3297.413
#> N[10] 2752.945 204.828 2356.488 2615.835 2749.331 2887.875 3159.933
#> N[11] 2760.178 257.254 2266.479 2584.772 2753.992 2929.448 3276.859
#> N[12] 2637.946 299.094 2078.455 2431.105 2627.825 2836.367 3248.185
#> N[13] 1311.255 73.453 1168.538 1261.814 1310.698 1360.683 1457.331
#> N[14] 1569.207 90.255 1393.237 1507.414 1568.650 1629.738 1747.739
#> N[15] 2393.256 151.154 2102.252 2291.875 2391.633 2494.663 2692.417
#> meanr -0.049 0.003 -0.054 -0.051 -0.049 -0.047 -0.043
#> r[1] -0.218 0.023 -0.265 -0.233 -0.218 -0.203 -0.174
#> r[2] -0.149 0.069 -0.284 -0.195 -0.149 -0.103 -0.014
#> r[3] -0.049 0.061 -0.168 -0.090 -0.049 -0.008 0.072
#> r[4] -0.023 0.033 -0.087 -0.046 -0.024 -0.001 0.044
#> r[5] 0.089 0.062 -0.035 0.048 0.090 0.131 0.216
#> r[6] 0.075 0.057 -0.037 0.037 0.076 0.114 0.187
#> r[7] -0.023 0.051 -0.122 -0.057 -0.023 0.011 0.079
#> r[8] -0.090 0.050 -0.185 -0.124 -0.091 -0.057 0.009
#> r[9] -0.024 0.043 -0.109 -0.053 -0.024 0.005 0.061
#> r[10] 0.001 0.067 -0.132 -0.044 0.001 0.046 0.131
#> r[11] -0.047 0.065 -0.175 -0.092 -0.047 -0.003 0.080
#> r[12] -0.087 0.015 -0.116 -0.097 -0.087 -0.077 -0.056
#> r[13] 0.090 0.036 0.020 0.066 0.090 0.114 0.159
#> r[14] 0.141 0.028 0.086 0.122 0.141 0.159 0.194
#> sdr 0.112 0.010 0.094 0.105 0.112 0.118 0.132
#> vrrmax 0.461 0.040 0.388 0.434 0.460 0.487 0.543
#> deviance 236.153 5.155 227.325 232.521 235.731 239.276 247.447
#> Rhat n.eff
#> N[1] 1.002 1600
#> N[2] 1.001 27000
#> N[3] 1.001 13000
#> N[4] 1.001 13000
#> N[5] 1.001 7100
#> N[6] 1.001 3200
#> N[7] 1.004 1400
#> N[8] 1.001 6300
#> N[9] 1.001 27000
#> N[10] 1.001 12000
#> N[11] 1.002 2400
#> N[12] 1.002 1400
#> N[13] 1.001 21000
#> N[14] 1.001 27000
#> N[15] 1.001 27000
#> meanr 1.002 1900
#> r[1] 1.001 3000
#> r[2] 1.001 14000
#> r[3] 1.001 27000
#> r[4] 1.001 27000
#> r[5] 1.003 7400
#> r[6] 1.002 3600
#> r[7] 1.003 1900
#> r[8] 1.001 12000
#> r[9] 1.001 6100
#> r[10] 1.001 2900
#> r[11] 1.001 3200
#> r[12] 1.002 1300
#> r[13] 1.001 19000
#> r[14] 1.001 27000
#> sdr 1.002 1300
#> vrrmax 1.002 1300
#> deviance 1.001 27000
#>
#> For each parameter, n.eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor (at convergence, Rhat=1).
#>
#> DIC info (using the rule, pD = var(deviance)/2)
#> pD = 13.3 and DIC = 249.4
#> DIC is an estimate of expected predictive error (lower deviance is better).
#>
## Import BUGS outputs for all count series ----
popbayes::read_bugs(path = temp_path)
#> $garamba__alcelaphus_buselaphus
#> Inference for Bugs model at "model.bug", fit using jags,
#> 2 chains, each with 50000 iterations (first 10000 discarded), n.thin = 3
#> n.sims = 26666 iterations saved
#> mu.vect sd.vect 2.5% 25% 50% 75% 97.5%
#> N[1] 17704.622 1732.733 14325.106 16540.416 17703.472 18854.702 21163.344
#> N[2] 3852.142 502.639 2892.122 3508.397 3843.527 4184.916 4857.835
#> N[3] 3313.482 390.724 2546.642 3049.617 3310.108 3578.820 4084.715
#> N[4] 3014.466 429.307 2205.787 2717.981 3003.240 3293.856 3893.400
#> N[5] 2675.016 326.426 2044.811 2451.061 2673.333 2895.294 3318.233
#> N[6] 3218.382 532.626 2269.759 2844.462 3181.803 3555.310 4353.830
#> N[7] 3748.142 663.983 2546.570 3288.082 3705.828 4163.506 5177.966
#> N[8] 3466.347 365.261 2769.738 3216.155 3459.593 3711.216 4200.803
#> N[9] 2886.866 208.334 2487.130 2745.760 2884.456 3027.397 3297.413
#> N[10] 2752.945 204.828 2356.488 2615.835 2749.331 2887.875 3159.933
#> N[11] 2760.178 257.254 2266.479 2584.772 2753.992 2929.448 3276.859
#> N[12] 2637.946 299.094 2078.455 2431.105 2627.825 2836.367 3248.185
#> N[13] 1311.255 73.453 1168.538 1261.814 1310.698 1360.683 1457.331
#> N[14] 1569.207 90.255 1393.237 1507.414 1568.650 1629.738 1747.739
#> N[15] 2393.256 151.154 2102.252 2291.875 2391.633 2494.663 2692.417
#> meanr -0.049 0.003 -0.054 -0.051 -0.049 -0.047 -0.043
#> r[1] -0.218 0.023 -0.265 -0.233 -0.218 -0.203 -0.174
#> r[2] -0.149 0.069 -0.284 -0.195 -0.149 -0.103 -0.014
#> r[3] -0.049 0.061 -0.168 -0.090 -0.049 -0.008 0.072
#> r[4] -0.023 0.033 -0.087 -0.046 -0.024 -0.001 0.044
#> r[5] 0.089 0.062 -0.035 0.048 0.090 0.131 0.216
#> r[6] 0.075 0.057 -0.037 0.037 0.076 0.114 0.187
#> r[7] -0.023 0.051 -0.122 -0.057 -0.023 0.011 0.079
#> r[8] -0.090 0.050 -0.185 -0.124 -0.091 -0.057 0.009
#> r[9] -0.024 0.043 -0.109 -0.053 -0.024 0.005 0.061
#> r[10] 0.001 0.067 -0.132 -0.044 0.001 0.046 0.131
#> r[11] -0.047 0.065 -0.175 -0.092 -0.047 -0.003 0.080
#> r[12] -0.087 0.015 -0.116 -0.097 -0.087 -0.077 -0.056
#> r[13] 0.090 0.036 0.020 0.066 0.090 0.114 0.159
#> r[14] 0.141 0.028 0.086 0.122 0.141 0.159 0.194
#> sdr 0.112 0.010 0.094 0.105 0.112 0.118 0.132
#> vrrmax 0.461 0.040 0.388 0.434 0.460 0.487 0.543
#> deviance 236.153 5.155 227.325 232.521 235.731 239.276 247.447
#> Rhat n.eff
#> N[1] 1.002 1600
#> N[2] 1.001 27000
#> N[3] 1.001 13000
#> N[4] 1.001 13000
#> N[5] 1.001 7100
#> N[6] 1.001 3200
#> N[7] 1.004 1400
#> N[8] 1.001 6300
#> N[9] 1.001 27000
#> N[10] 1.001 12000
#> N[11] 1.002 2400
#> N[12] 1.002 1400
#> N[13] 1.001 21000
#> N[14] 1.001 27000
#> N[15] 1.001 27000
#> meanr 1.002 1900
#> r[1] 1.001 3000
#> r[2] 1.001 14000
#> r[3] 1.001 27000
#> r[4] 1.001 27000
#> r[5] 1.003 7400
#> r[6] 1.002 3600
#> r[7] 1.003 1900
#> r[8] 1.001 12000
#> r[9] 1.001 6100
#> r[10] 1.001 2900
#> r[11] 1.001 3200
#> r[12] 1.002 1300
#> r[13] 1.001 19000
#> r[14] 1.001 27000
#> sdr 1.002 1300
#> vrrmax 1.002 1300
#> deviance 1.001 27000
#>
#> For each parameter, n.eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor (at convergence, Rhat=1).
#>
#> DIC info (using the rule, pD = var(deviance)/2)
#> pD = 13.3 and DIC = 249.4
#> DIC is an estimate of expected predictive error (lower deviance is better).
#>
# }