You first need to uninstall the current
installation of ssdtools
and then install the dev. version.
detach("package:ssdtools", unload = TRUE)
remove.packages("ssdtools")
remotes::install_github("bcgov/ssdtools@v1.0.6.9009")
After executing the
remotes::install_github("bcgov/ssdtools@v1.0.6.9009")
command you will probably get a message such as:
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?
1: All
2: CRAN packages only
3: None
4: Rcpp (1.0.11 -> 1.0.12 ) [CRAN]
5: ....
6: ....
Enter one or more numbers, or an empty line to skip updates:
I suggest you choose Option#1 (All).
Let the process complete - there’s a lot of output (computer jargon)
and it might take a while. The process may well terminate with
errors.
For example:
Error in TMB::compile(file = paste0(tmb_name, ".cpp"), PKG_CXXFLAGS = tmb_flags, :
Compilation failed
.
.
.
Please re-install 'TMB' from source using install.packages('TMB', type = 'source')
In this example, the installation failed because of a problem with
the existing TMB package installation. Follow the suggestion and
re-install TMB
:
install.packages('TMB', type = 'source')
Then try the ssdtools installation again
remotes::install_github("bcgov/ssdtools@v1.0.6.9009")
The syntax of some of the ssdtools commands has changed so I
recommend consulting the help - particularly for the command
ssd_hc()
.
We’ll use the csiro nickel data set
found in the ssddata
package.
library(ssdtools)
library(ssddata)
head(csiro_nickel_fresh) # look at first 6 rows of the data
## # A tibble: 6 × 6
## Conc Domain Group Notes Species Test_endpoint
## <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 1.4 temperate Mollusc (snail) none Lymnaea stagnal… EC10
## 2 1.52 temperate Crustacean (water flea) geomean Ceriodaphnia du… EC10/LOEC
## 3 3.63 temperate Crustacean (water flea) geomean Alona affinis LC50
## 4 8.49 temperate Crustacean (water flea) geomean Ceriodaphnia qu… EC10
## 5 11.0 temperate Crustacean (water flea) geomean Peracantha trun… EC10
## 6 12 temperate Crustacean (water flea) geomean Daphnia magna EC10
# We'll fits the default ANZECC set of distributions
fit<-ssd_fit_bcanz(data=csiro_nickel_fresh)
summary(fit)
## Distribution 'gamma'
## scale 59.4824
## shape 0.786083
##
## Distribution 'lgumbel'
## locationlog 2.43819
## scalelog 1.28726
##
## Distribution 'llogis'
## locationlog 3.09974
## scalelog 0.730068
##
## Distribution 'lnorm'
## meanlog 3.08823
## sdlog 1.2833
##
## Distribution 'lnorm_lnorm'
## meanlog1 0.377467
## meanlog2 3.2692
## pmix 0.0625861
## sdlog1 0.0411175
## sdlog2 1.11059
##
## Distribution 'weibull'
## scale 41.4129
## shape 0.822934
##
## Parameters estimated from 31 rows of data.
# examine the goodness-of-fit statistics
ssd_gof(fit)
## # A tibble: 6 × 9
## dist ad ks cvm aic aicc bic delta weight
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 gamma 0.633 0.136 0.113 303. 304. 306. 4.18 0.04
## 2 lgumbel 0.691 0.136 0.0964 304. 305. 307. 5.53 0.021
## 3 llogis 0.145 0.0678 0.0178 299. 300. 302. 0.55 0.247
## 4 lnorm 0.173 0.0854 0.0211 299. 299. 302. 0 0.326
## 5 lnorm_lnorm 0.175 0.0803 0.0276 297. 300. 304. 0.19 0.296
## 6 weibull 0.448 0.114 0.0720 302. 302. 305. 3.06 0.07
autoplot(fit)
# get HC values and confidence intervals. Use 1,000 bootstrap samples
ssd_hc(fit,ci=TRUE,multi_est = TRUE,multi_ci=TRUE,percent=c(1,5,10,20),nboot=1000)
## Warning: One or more pboot values less than 0.99 (decrease min_pboot with
## caution).
## # A tibble: 4 × 11
## dist percent est se lcl ucl wt method nboot pboot samples
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <dbl> <dbl> <I<list>>
## 1 average 1 0.899 NA NA NA 1 parametric 1000 0.886 <dbl [0]>
## 2 average 5 2.03 NA NA NA 1 parametric 1000 0.886 <dbl [0]>
## 3 average 10 4.02 NA NA NA 1 parametric 1000 0.886 <dbl [0]>
## 4 average 20 7.72 NA NA NA 1 parametric 1000 0.886 <dbl [0]>