The goal of BeeGUTS is to analyse the survival toxicity tests performed for bee species. It can be used to fit a Toxicokinetic-Toxicodynamic (TKTD) model adapted for bee standard studies (acute oral, acute contact, and chronic oral studies). The TKTD model used is the General Unified Threshold model of Survival (GUTS).

You can install the released version of BeeGUTS from CRAN with:

`install.packages("BeeGUTS")`

And the development version from GitHub with:

```
# install.packages("devtools")
::install_github("bgoussen/BeeGUTS") devtools
```

This is a basic example which shows you how to solve a common problem:

```
library(BeeGUTS)
#> BeeGUTS (Version 1.1.2, packaged on the: )
#> - For execution on a local, multicore CPU with excess RAM we recommend calling
#> options(mc.cores = parallel::detectCores()-1)
#> - In addition to the functions provided by 'BeeGUTS', we recommend using the packages:
#> - 'bayesplot' for posterior analysis, model checking, and MCMC diagnostics.
#> - 'loo' for leave-one-out cross-validation (LOO) using Pareto smoothed
#> importance sampling (PSIS), comparison of predictive errors between models, and
#> widely applicable information criterion (WAIC).
<- system.file("extdata", "betacyfluthrin_chronic_ug.txt", package = "BeeGUTS") # Load the path to one of the example file
file_location <- dataGUTS(file_location = file_location, test_type = 'Chronic_Oral') # Read the example file
lsData plot(lsData) # Plot the data
#> [[1]]
```

```
<- fitBeeGUTS(lsData, modelType = "SD", nIter = 2000, nChains = 1) # Fit a SD model. This can take some time...
fit #>
#> SAMPLING FOR MODEL 'GUTS_SD' NOW (CHAIN 1).
#> Chain 1:
#> Chain 1: Gradient evaluation took 0.001 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 10 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: 204.713 seconds (Warm-up)
#> Chain 1: 98.778 seconds (Sampling)
#> Chain 1: 303.491 seconds (Total)
#> Chain 1:
traceplot(fit) # Produce a diagnostic plot of the fit
```

```
plot(fit) # Plot the fit results
#> [[1]]
```

```
summary(fit) # Gives a summary of the results
#> Computing summary can take some time. Please be patient...Summary:
#>
#> Bayesian Inference performed with Stan.
#> Model type: SD
#> Bee species: Honey_Bee
#>
#> MCMC sampling setup (select with '$setupMCMC')
#> Iterations: 2000
#> Warmup iterations: 1000
#> Thinning interval: 1
#> Number of chains: 1
#>
#> Priors of the parameters (quantiles) (select with '$Qpriors'):
#>
#> parameters median Q2.5 Q97.5
#> hb 8.32763e-03 1.09309e-04 6.34432e-01
#> kd 2.62826e-03 1.17073e-06 5.90041e+00
#> zw 1.30384e-03 1.15441e-06 1.47261e+00
#> bw 7.36245e-02 6.78843e-05 7.98500e+01
#>
#> Posteriors of the parameters (quantiles) (select with '$Qposteriors'):
#>
#> parameters median Q2.5 Q97.5
#> hb[1] 7.01736e-03 4.58362e-03 1.00796e-02
#> parameters median Q2.5 Q97.5
#> kd 9.89072e-01 7.31050e-01 1.41124e+00
#> zw 2.37712e-01 1.97600e-01 2.68104e-01
#> bw 3.55224e-01 2.95449e-01 4.23758e-01
#>
#>
#> Maximum Rhat computed (na.rm = TRUE): 1.005239
#> Minimum Bulk_ESS: 417
#> Minimum Tail_ESS: 389
#> Bulk_ESS and Tail_ESS are crude measures of effecting sampling size for
#> bulk and tail quantities respectively. An ESS > 100 per chain can be
#> considered as a good indicator. Rhat is an indicator of chains convergence.
#> A Rhat <= 1.05 is a good indicator of convergence. For detail results,
#> one can call 'rstan::monitor(YOUR_beeSurvFit_OBJECT$stanFit)
#>
#> EFSA Criteria (PPC, NRMSE, and SPPE) can be accessed via 'x$EFSA'
<- validate(fit, lsData) # produce a validation of the fit (here it uses the same dataset as calibration as an example, so not relevantâ€¦)
validation #> Note that computing can be quite long (several minutes).
#> Tips: To reduce that time you can reduce Number of MCMC chains (default mcmc_size is set to 1000).
plot(validation) # plot the validation results
```

```
<- data.frame(time = c(1:5, 1:15), conc = c(rep(5, 5), rep(15, 15)), replicate = c(rep("rep1", 5), rep("rep3", 15))) # Prepare data for forwards prediction
dataPredict <- predict(fit, dataPredict) # Perform forwards prediction. At the moment, no concentration recalculation is performed in the forwards prediction. The concentrations are taken as in a chronic test
prediction plot(prediction) # Plot of the prediction results
```