Tutorial

library(rbioacc)
# library(ggplot2)

A Simple Example: Male Gammarus Single

Data

Load the data set with the function data(), define the duration of the exposure time_accumulation, and check if the data set is correctly imported with the function modelData(). Here the data set is called Male Gammarus Single

Inference

The function fitTK() performs the inference process.

Results

TK parameters

The 4 MCMC are stored in the object fitMCMC. The quantiles for each TK parameter can be obtained with the quantile() function.

Male Gammarus Merged

data("Male_Gammarus_Merged")
data_MGM708 <- Male_Gammarus_Merged[Male_Gammarus_Merged$expw == 7.08021e-05, ]
modelData_MGM708 <- modelData(data_MGM708, time_accumulation = 4)
fit_MGM708 <- fitTK(modelData_MGM708, iter = 10000)
quantile_table(fit_MGM708)
plot(fit_MGM708)
ppc(fit_MGM708)
data_MGM141 <- Male_Gammarus_Merged[Male_Gammarus_Merged$expw == 1.41604e-04, ]
modelData_MGM141 <- modelData(data_MGM141, time_accumulation = 7)
fit_MGM141 <- fitTK(modelData_MGM141, iter = 20000)
quantile_table(fit_MGM141)
plot(fit_MGM141)
ppc(fit_MGM141)
data_MGM283 <- Male_Gammarus_Merged[Male_Gammarus_Merged$expw == 2.83208e-04, ]
modelData_MGM283 <- modelData(data_MGM283, time_accumulation = 4)
fit_MGM283 <- fitTK(modelData_MGM283, iter = 10000)
quantile_table(fit_MGM283)
plot(fit_MGM283)
ppc(fit_MGM283)

Male Gammarus seanine with growth

data("Male_Gammarus_seanine_growth")
modelData_MGSG <- modelData(Male_Gammarus_seanine_growth, time_accumulation = 1.417)
fit_MGSG <- fitTK(modelData_MGSG, iter = 10000)
quantile_table(fit_MGSG)
plot(fit_MGSG)
ppc(fit_MGSG)

Oncorhynchus

data("Oncorhynchus_two") #  Pimephales_two
data_OT440 = Oncorhynchus_two[Oncorhynchus_two$expw == 0.00440,]
modelData_OT440 <- modelData(data_OT440, time_accumulation = 49)
fit_OT440 <- fitTK(modelData_OT440, iter = 10000)
quantile_table(fit_OT440)
plot(fit_OT440)
ppc(fit_OT440)
data_OT041 <- Oncorhynchus_two[Oncorhynchus_two$expw == 0.00041,]
modelData_OT041 <- modelData(data_OT041, time_accumulation = 49)
fit_OT041 <- fitTK(modelData_OT041, iter = 10000)
quantile_table(fit_OT041)
plot(fit_OT041)
ppc(fit_OT041)

Chironomus benzo-a-pyrene

data("Chironomus_benzoapyrene")
modelData_CB <- modelData(Chironomus_benzoapyrene, time_accumulation = 3)
modelData_CB$unifMax = modelData_CB$unifMax  * 100
fit_CB <- fitTK(modelData_CB, iter = 10000)
quantile_table(fit_CB)
plot(fit_CB)
ppc(fit_CB)

Prediction

data("Male_Gammarus_Single")
modelData_MGS <- modelData(Male_Gammarus_Single, time_accumulation = 4)
fit_MGS <- fitTK(modelData_MGS, iter = 5000, chains = 3)

# Data 4 prediction should respect the exposure routes
data_4pred <- data.frame( time = 1:25, expw = 4e-5 )
predict_MGS <- predict(fit_MGS, data_4pred)
plot(predict_MGS)
# data("Male_Gammarus_seanine_growth")
# modelData_MGSG <- modelData(Male_Gammarus_seanine_growth, time_accumulation = 4)
# fit_MGSG <- fitTK(modelData_MGSG, iter = 5000, chains = 3)
# 
# # Data 4 prediction should respect the exposure routes
# data_4pred <- data.frame( time = 1:25, expw = 18 )
# predict_MGSG <- predict(fit_MGSG, data_4pred)
# plot(predict_MGSG)
data("Chiro_Creuzot")
modelData_CC <- modelData(Male_Gammarus_Single, time_accumulation = 4)
fit_CC <- fitTK(modelData_CC, iter = 5000, chains = 3)

# Data 4 prediction should respect the exposure routes
data_4pred <- data.frame( time = 1:25, expw = 18, exps = 1200, exppw = 15 )
predict_CC <- predict(fit_CC, data_4pred)
plot(predict_CC)