Skip to content

Commit

Permalink
- The optim argument pgtol is set to 1e-5 if not specified via the …
Browse files Browse the repository at this point in the history
…control argument.
  • Loading branch information
joethorley committed Aug 21, 2024
1 parent b301d52 commit 49f4618
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 26 deletions.
6 changes: 4 additions & 2 deletions R/devtools-helpers.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Province of British Columbia
# Copyright 2024 Province of British Columbia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,8 @@ release_questions <- function() {
c(
"Have you confirmed Apache 2.0 license at the top of all code files?",
"Have you confirmed Creative Commons license for all non-code files?",
"Have you rerun `vignettestatic/small-sample-bias.Rmd`?"
"Have you run `data-raw/data-raw.R`?",
"Have you tested using `ssdtests` package?",
"Have you updated `small-sample-bias.pdf` using `ssdtests` package?"
)
}
4 changes: 3 additions & 1 deletion R/fit-burrlioz.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
#' @examples
#' ssd_fit_burrlioz(ssddata::ccme_boron)
ssd_fit_burrlioz <- function(data, left = "Conc", rescale = FALSE,
control = list(),
silent = FALSE) {
if (nrow(data) <= 8) {
fit <- ssd_fit_dists(data,
left = left, dists = "llogis",
computable = FALSE, nrow = 5L,
rescale = rescale, silent = silent
rescale = rescale, silent = silent, control = control,
)
class(fit) <- c("fitburrlioz", class(fit))
return(fit)
Expand All @@ -46,6 +47,7 @@ ssd_fit_burrlioz <- function(data, left = "Conc", rescale = FALSE,
left = left, dists = "burrIII3",
rescale = rescale, computable = FALSE,
at_boundary_ok = TRUE, silent = TRUE,
control = control,
range_shape1 = range_shape1,
range_shape2 = range_shape2
),
Expand Down
17 changes: 13 additions & 4 deletions R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,19 @@ fits_dists <- function(data, dists, min_pmix, range_shape1, range_shape2, contro
#'
#' Fits one or more distributions to species sensitivity data.
#'
#' By default the 'llogis', 'gamma' and 'lnorm'
#' distributions are fitted to the data.
#' For a complete list of the implemented distributions see [`ssd_dists_all()`].
#' By default the 'gamma', 'lgumbel', 'llogis', 'lnorm', 'lnorm_lnorm' and
#' 'weibull' distributions are fitted to the data.
#' For a complete list of the distributions that are currently implemented in
#' `ssdtools` see [`ssd_dists_all()`].
#'
#' If weight specifies a column in the data frame with positive numbers,
#' weighted estimation occurs.
#' However, currently only the resultant parameter estimates are available.
#'
#' If the `right` argument is different to the `left` argument then the data are considered to be censored.
#' If the `right` argument is different to the `left` argument
#' then the data are considered to be censored.
#'
#' The optim argument `pgtol` is set to 1e-5 if not specified via the control argument.
#'
#' @inheritParams params
#' @return An object of class fitdists.
Expand Down Expand Up @@ -214,6 +218,11 @@ ssd_fit_dists <- function(
if (any(is.infinite(attrs$data$right))) {
err("Distributions cannot currently be fitted to right censored data.")
}

if(!utils::hasName(control, "pgtol")) {
control$pgtol <- 1e-5
}

fits <- fits_dists(attrs$data, dists,
min_pmix = min_pmix, range_shape1 = range_shape1,
range_shape2 = range_shape2,
Expand Down
10 changes: 9 additions & 1 deletion man/ssd_fit_burrlioz.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions man/ssd_fit_dists.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/testthat/_snaps/gompertz/hc_prob.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dist,proportion,est,se,lcl,ucl,wt,method,nboot,pboot,samples
average,0.05,0.179453,0.307799,0.0992422,1.23754,1,parametric,100,0.92,"c(`000000001_gompertz` = 0.232668, `000000003_gompertz` = 0.104651, `000000004_gompertz` = 0.546479, `000000005_gompertz` = 0.59723, `000000006_gompertz` = 0.232644, `000000007_gompertz` = 0.26047, `000000008_gompertz` = 0.194946, `000000009_gompertz` = 0.687566, `000000010_gompertz` = 0.158672, `000000011_gompertz` = 0.252489, `000000012_gompertz` = 0.212705, `000000013_gompertz` = 1.32526, `000000014_gompertz` = 0.196413, `000000015_gompertz` = 0.556619, `000000016_gompertz` = 0.542088, `000000017_gompertz` = 0.258851,
`000000018_gompertz` = 0.467362, `000000019_gompertz` = 0.444558, `000000020_gompertz` = 0.252365, `000000021_gompertz` = 1.00627, `000000022_gompertz` = 0.262159, `000000023_gompertz` = 0.201961, `000000024_gompertz` = 0.221781, `000000025_gompertz` = 0.370823, `000000026_gompertz` = 0.381622, `000000027_gompertz` = 0.587692, `000000028_gompertz` = 0.154181, `000000031_gompertz` = 0.10423, `000000032_gompertz` = 0.250053, `000000033_gompertz` = 0.462225, `000000034_gompertz` = 0.39652, `000000035_gompertz` = 0,
`000000018_gompertz` = 0.467362, `000000019_gompertz` = 0.444558, `000000020_gompertz` = 0.252366, `000000021_gompertz` = 1.00627, `000000022_gompertz` = 0.262159, `000000023_gompertz` = 0.201961, `000000024_gompertz` = 0.221781, `000000025_gompertz` = 0.370823, `000000026_gompertz` = 0.381622, `000000027_gompertz` = 0.587692, `000000028_gompertz` = 0.154181, `000000031_gompertz` = 0.10423, `000000032_gompertz` = 0.250053, `000000033_gompertz` = 0.462225, `000000034_gompertz` = 0.39652, `000000035_gompertz` = 0,
`000000036_gompertz` = 0.258822, `000000037_gompertz` = 0.242274, `000000038_gompertz` = 0.347614, `000000039_gompertz` = 0.29439, `000000040_gompertz` = 1.14346, `000000041_gompertz` = 0.135087, `000000042_gompertz` = 0.119971, `000000043_gompertz` = 0.314016, `000000044_gompertz` = 0.0979661, `000000045_gompertz` = 0.135296, `000000046_gompertz` = 0.260949, `000000047_gompertz` = 0.50742, `000000049_gompertz` = 1.83785, `000000050_gompertz` = 0.183739, `000000051_gompertz` = 0.119605, `000000052_gompertz` = 0.166286,
`000000053_gompertz` = 0.375928, `000000054_gompertz` = 0.16, `000000055_gompertz` = 0.378692, `000000056_gompertz` = 0.198193, `000000057_gompertz` = 0.854231, `000000058_gompertz` = 0.113677, `000000059_gompertz` = 0.0460489, `000000060_gompertz` = 0.26119, `000000061_gompertz` = 0.349783, `000000062_gompertz` = 0.155674, `000000063_gompertz` = 0.25708, `000000065_gompertz` = 0.862409, `000000066_gompertz` = 0.252748, `000000067_gompertz` = 1.27322, `000000068_gompertz` = 0.30646, `000000069_gompertz` = 0.102607,
`000000053_gompertz` = 0.375928, `000000054_gompertz` = 0.16, `000000055_gompertz` = 0.378693, `000000056_gompertz` = 0.198193, `000000057_gompertz` = 0.854231, `000000058_gompertz` = 0.113677, `000000059_gompertz` = 0.0460489, `000000060_gompertz` = 0.26119, `000000061_gompertz` = 0.349783, `000000062_gompertz` = 0.155674, `000000063_gompertz` = 0.25708, `000000065_gompertz` = 0.862409, `000000066_gompertz` = 0.252748, `000000067_gompertz` = 1.27322, `000000068_gompertz` = 0.306461, `000000069_gompertz` = 0.102607,
`000000071_gompertz` = 0.882485, `000000072_gompertz` = 0.738937, `000000074_gompertz` = 0.2907, `000000075_gompertz` = 0.428083, `000000076_gompertz` = 0.325723, `000000077_gompertz` = 0.260432, `000000078_gompertz` = 0.331494, `000000079_gompertz` = 1.0526, `000000080_gompertz` = 0.616152, `000000081_gompertz` = 0.183109, `000000082_gompertz` = 0.184165, `000000083_gompertz` = 0.141392, `000000084_gompertz` = 0.324602, `000000085_gompertz` = 0.366267, `000000086_gompertz` = 0.672032, `000000087_gompertz` = 0.274923,
`000000088_gompertz` = 0.283306, `000000089_gompertz` = 0.252262, `000000090_gompertz` = 0.244424, `000000091_gompertz` = 0.109766, `000000092_gompertz` = 0.192248, `000000093_gompertz` = 0.156249, `000000094_gompertz` = 0.392504, `000000095_gompertz` = 0.171986, `000000096_gompertz` = 0.217738, `000000097_gompertz` = 0.548714, `000000098_gompertz` = 0.431485, `000000100_gompertz` = 0.298434)"
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/hc/fullyleft.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dist,proportion,est,se,lcl,ucl,wt,method,nboot,pboot,samples
average,0.05,0.0276016,0,0.0457802,0.0457802,1,parametric,10,1,numeric(0)
average,0.05,0.0267647,0,0.0462203,0.0462203,1,parametric,10,1,numeric(0)
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/hc/hc_cis.csv
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ average,0.05,1.68118,0.682856,0.916053,3.47924,1,parametric,1000,1,"c(`000000001
`000000253_lnorm` = 0.957097, `000000254_lnorm` = 1.71972, `000000255_lnorm` = 1.246, `000000256_lnorm` = 1.64064, `000000257_lnorm` = 1.85754, `000000258_lnorm` = 2.32517, `000000259_lnorm` = 1.53654, `000000260_lnorm` = 4.93482, `000000261_lnorm` = 2.92566, `000000262_lnorm` = 1.80187, `000000263_lnorm` = 1.30003, `000000264_lnorm` = 3.32539, `000000265_lnorm` = 1.00911, `000000266_lnorm` = 1.3714, `000000267_lnorm` = 1.49066, `000000268_lnorm` = 1.16181, `000000269_lnorm` = 2.17011, `000000270_lnorm` = 1.93628,
`000000271_lnorm` = 1.93382, `000000272_lnorm` = 1.56229, `000000273_lnorm` = 1.934, `000000274_lnorm` = 1.48945, `000000275_lnorm` = 1.5608, `000000276_lnorm` = 2.76426, `000000277_lnorm` = 1.41112, `000000278_lnorm` = 3.0299, `000000279_lnorm` = 1.20218, `000000280_lnorm` = 1.17921, `000000281_lnorm` = 3.31634, `000000282_lnorm` = 2.2934, `000000283_lnorm` = 1.75066, `000000284_lnorm` = 2.23803, `000000285_lnorm` = 1.73284, `000000286_lnorm` = 2.27553, `000000287_lnorm` = 1.06919, `000000288_lnorm` = 2.22348,
`000000289_lnorm` = 1.43162, `000000290_lnorm` = 2.38861, `000000291_lnorm` = 1.9776, `000000292_lnorm` = 1.75615, `000000293_lnorm` = 1.51279, `000000294_lnorm` = 4.17684, `000000295_lnorm` = 1.10022, `000000296_lnorm` = 3.42715, `000000297_lnorm` = 1.28569, `000000298_lnorm` = 1.91589, `000000299_lnorm` = 1.14508, `000000300_lnorm` = 1.36318, `000000301_lnorm` = 1.23333, `000000302_lnorm` = 1.07115, `000000303_lnorm` = 1.85, `000000304_lnorm` = 2.22285, `000000305_lnorm` = 1.22099, `000000306_lnorm` = 0.769899,
`000000307_lnorm` = 2.26783, `000000308_lnorm` = 2.76718, `000000309_lnorm` = 2.80311, `000000310_lnorm` = 1.7925, `000000311_lnorm` = 1.50201, `000000312_lnorm` = 2.33447, `000000313_lnorm` = 1.51844, `000000314_lnorm` = 1.49481, `000000315_lnorm` = 2.28878, `000000316_lnorm` = 2.50457, `000000317_lnorm` = 1.49334, `000000318_lnorm` = 1.2303, `000000319_lnorm` = 2.97667, `000000320_lnorm` = 2.11936, `000000321_lnorm` = 1.49001, `000000322_lnorm` = 1.68884, `000000323_lnorm` = 1.43209, `000000324_lnorm` = 1.93249,
`000000307_lnorm` = 2.26783, `000000308_lnorm` = 2.76718, `000000309_lnorm` = 2.80311, `000000310_lnorm` = 1.7925, `000000311_lnorm` = 1.50201, `000000312_lnorm` = 2.33447, `000000313_lnorm` = 1.51844, `000000314_lnorm` = 1.49481, `000000315_lnorm` = 2.28877, `000000316_lnorm` = 2.50457, `000000317_lnorm` = 1.49334, `000000318_lnorm` = 1.2303, `000000319_lnorm` = 2.97667, `000000320_lnorm` = 2.11936, `000000321_lnorm` = 1.49001, `000000322_lnorm` = 1.68884, `000000323_lnorm` = 1.43209, `000000324_lnorm` = 1.93249,
`000000325_lnorm` = 1.48784, `000000326_lnorm` = 2.98808, `000000327_lnorm` = 2.30993, `000000328_lnorm` = 2.99877, `000000329_lnorm` = 1.741, `000000330_lnorm` = 1.88757, `000000331_lnorm` = 2.04144, `000000332_lnorm` = 1.25144, `000000333_lnorm` = 1.57907, `000000334_lnorm` = 1.00788, `000000335_lnorm` = 1.2126, `000000336_lnorm` = 1.9552, `000000337_lnorm` = 2.82747, `000000338_lnorm` = 1.90187, `000000339_lnorm` = 1.42327, `000000340_lnorm` = 1.43656, `000000341_lnorm` = 1.09695, `000000342_lnorm` = 1.33248,
`000000343_lnorm` = 1.19027, `000000344_lnorm` = 1.97184, `000000345_lnorm` = 1.77387, `000000346_lnorm` = 1.07525, `000000347_lnorm` = 2.13797, `000000348_lnorm` = 2.16009, `000000349_lnorm` = 2.2232, `000000350_lnorm` = 2.71378, `000000351_lnorm` = 1.83288, `000000352_lnorm` = 2.48059, `000000353_lnorm` = 1.04259, `000000354_lnorm` = 1.55659, `000000355_lnorm` = 2.4289, `000000356_lnorm` = 3.13694, `000000357_lnorm` = 1.00274, `000000358_lnorm` = 1.32141, `000000359_lnorm` = 1.9265, `000000360_lnorm` = 1.34318,
`000000361_lnorm` = 1.42568, `000000362_lnorm` = 1.01439, `000000363_lnorm` = 1.49849, `000000364_lnorm` = 2.22677, `000000365_lnorm` = 1.62129, `000000366_lnorm` = 2.04696, `000000367_lnorm` = 1.18602, `000000368_lnorm` = 1.20377, `000000369_lnorm` = 1.2206, `000000370_lnorm` = 1.90947, `000000371_lnorm` = 1.13543, `000000372_lnorm` = 1.6593, `000000373_lnorm` = 1.46798, `000000374_lnorm` = 1.57448, `000000375_lnorm` = 1.85693, `000000376_lnorm` = 1.4851, `000000377_lnorm` = 1.42378, `000000378_lnorm` = 1.59598,
Expand Down Expand Up @@ -46,7 +46,7 @@ average,0.05,1.68118,0.682856,0.916053,3.47924,1,parametric,1000,1,"c(`000000001
`000000793_lnorm` = 1.38939, `000000794_lnorm` = 1.73823, `000000795_lnorm` = 1.93236, `000000796_lnorm` = 2.27247, `000000797_lnorm` = 1.9506, `000000798_lnorm` = 2.79071, `000000799_lnorm` = 1.85945, `000000800_lnorm` = 1.697, `000000801_lnorm` = 1.20041, `000000802_lnorm` = 2.30994, `000000803_lnorm` = 2.28004, `000000804_lnorm` = 2.12277, `000000805_lnorm` = 1.40852, `000000806_lnorm` = 2.70247, `000000807_lnorm` = 0.952191, `000000808_lnorm` = 1.76159, `000000809_lnorm` = 1.55078, `000000810_lnorm` = 1.46163,
`000000811_lnorm` = 2.11149, `000000812_lnorm` = 1.11352, `000000813_lnorm` = 2.7389, `000000814_lnorm` = 1.51083, `000000815_lnorm` = 1.2664, `000000816_lnorm` = 1.60513, `000000817_lnorm` = 1.05833, `000000818_lnorm` = 1.68812, `000000819_lnorm` = 2.66027, `000000820_lnorm` = 1.65418, `000000821_lnorm` = 1.08778, `000000822_lnorm` = 1.33578, `000000823_lnorm` = 1.09943, `000000824_lnorm` = 1.50982, `000000825_lnorm` = 1.619, `000000826_lnorm` = 2.30469, `000000827_lnorm` = 0.855125, `000000828_lnorm` = 2.42884,
`000000829_lnorm` = 1.38089, `000000830_lnorm` = 4.4522, `000000831_lnorm` = 1.66964, `000000832_lnorm` = 1.85568, `000000833_lnorm` = 1.08886, `000000834_lnorm` = 0.921413, `000000835_lnorm` = 1.46622, `000000836_lnorm` = 2.73844, `000000837_lnorm` = 1.58314, `000000838_lnorm` = 1.38034, `000000839_lnorm` = 4.41954, `000000840_lnorm` = 0.943256, `000000841_lnorm` = 2.27984, `000000842_lnorm` = 0.912846, `000000843_lnorm` = 3.55196, `000000844_lnorm` = 1.1334, `000000845_lnorm` = 1.32162, `000000846_lnorm` = 1.15393,
`000000847_lnorm` = 1.98562, `000000848_lnorm` = 2.20511, `000000849_lnorm` = 1.54514, `000000850_lnorm` = 2.42929, `000000851_lnorm` = 4.14374, `000000852_lnorm` = 1.43422, `000000853_lnorm` = 1.86874, `000000854_lnorm` = 2.12603, `000000855_lnorm` = 1.61319, `000000856_lnorm` = 2.90886, `000000857_lnorm` = 1.78374, `000000858_lnorm` = 2.71821, `000000859_lnorm` = 2.36495, `000000860_lnorm` = 1.34749, `000000861_lnorm` = 2.34658, `000000862_lnorm` = 1.52777, `000000863_lnorm` = 0.600718, `000000864_lnorm` = 1.09026,
`000000847_lnorm` = 1.98562, `000000848_lnorm` = 2.20511, `000000849_lnorm` = 1.54514, `000000850_lnorm` = 2.42929, `000000851_lnorm` = 4.14374, `000000852_lnorm` = 1.43422, `000000853_lnorm` = 1.86874, `000000854_lnorm` = 2.12603, `000000855_lnorm` = 1.61319, `000000856_lnorm` = 2.90886, `000000857_lnorm` = 1.78374, `000000858_lnorm` = 2.71821, `000000859_lnorm` = 2.36495, `000000860_lnorm` = 1.34749, `000000861_lnorm` = 2.34658, `000000862_lnorm` = 1.52777, `000000863_lnorm` = 0.600719, `000000864_lnorm` = 1.09026,
`000000865_lnorm` = 2.03663, `000000866_lnorm` = 1.49139, `000000867_lnorm` = 1.12194, `000000868_lnorm` = 1.07614, `000000869_lnorm` = 1.8528, `000000870_lnorm` = 2.95831, `000000871_lnorm` = 2.98388, `000000872_lnorm` = 2.99172, `000000873_lnorm` = 2.63005, `000000874_lnorm` = 2.71377, `000000875_lnorm` = 2.88341, `000000876_lnorm` = 1.53379, `000000877_lnorm` = 1.38716, `000000878_lnorm` = 1.82626, `000000879_lnorm` = 2.14879, `000000880_lnorm` = 1.45224, `000000881_lnorm` = 2.03255, `000000882_lnorm` = 1.23025,
`000000883_lnorm` = 4.04123, `000000884_lnorm` = 1.87984, `000000885_lnorm` = 0.920501, `000000886_lnorm` = 1.39447, `000000887_lnorm` = 2.25379, `000000888_lnorm` = 1.17532, `000000889_lnorm` = 1.54539, `000000890_lnorm` = 1.16774, `000000891_lnorm` = 1.62573, `000000892_lnorm` = 0.973674, `000000893_lnorm` = 1.10345, `000000894_lnorm` = 1.55087, `000000895_lnorm` = 1.43027, `000000896_lnorm` = 0.962508, `000000897_lnorm` = 2.10172, `000000898_lnorm` = 1.45381, `000000899_lnorm` = 2.50912, `000000900_lnorm` = 0.829115,
`000000901_lnorm` = 1.49204, `000000902_lnorm` = 1.97533, `000000903_lnorm` = 1.08147, `000000904_lnorm` = 1.12325, `000000905_lnorm` = 1.646, `000000906_lnorm` = 0.996106, `000000907_lnorm` = 3.10322, `000000908_lnorm` = 1.11549, `000000909_lnorm` = 1.86724, `000000910_lnorm` = 1.93593, `000000911_lnorm` = 0.86112, `000000912_lnorm` = 2.97445, `000000913_lnorm` = 2.62286, `000000914_lnorm` = 3.12933, `000000915_lnorm` = 1.27296, `000000916_lnorm` = 1.42102, `000000917_lnorm` = 1.6307, `000000918_lnorm` = 3.45913,
Expand Down
Loading

0 comments on commit 49f4618

Please sign in to comment.