ssd_gof and predict give errors for left censored data
Closed this issue · 3 comments
beckyfisher commented
example_dat <- ssddata::ccme_boron |>
dplyr::mutate(left=Conc, right=Conc)
left_censored_example <- example_dat
left_censored_example$left[c(3,6,8)] <- NA
ssd_gof(left_censored_dists)
predict(left_censored_dists, ci = TRUE)
joethorley commented
This is what I'm getting. Your reprex seems to have a coding error ie left_censored_dists
isn't defined.
library(ssdtools)
example_dat <- ssddata::ccme_boron |>
dplyr::mutate(left=Conc, right=Conc)
left_censored_example <- example_dat
left_censored_example$left[c(3,6,8)] <- NA
left_censored_dists <- ssdtools::ssd_fit_dists(left_censored_example)
ssd_gof(left_censored_dists)
#> # 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.440 0.117 0.0554 238. 238. 240. 0.005 0.357
#> 2 lgumbel 0.829 0.158 0.134 244. 245. 247. 6.56 0.013
#> 3 llogis 0.487 0.0994 0.0595 241. 241. 244. 3.39 0.066
#> 4 lnorm 0.507 0.107 0.0703 239. 240. 242. 1.40 0.177
#> 5 lnorm_lnorm 0.320 0.116 0.0414 240. 243. 247. 4.98 0.03
#> 6 weibull 0.434 0.117 0.0542 238. 238. 240. 0 0.357
predict(left_censored_dists, ci = TRUE, nboot = 10)
#> Warning: One or more pboot values less than 0.95 (decrease min_pboot with
#> caution).
#> # A tibble: 99 × 11
#> dist proportion est se lcl ucl wt method nboot pboot samples
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <dbl> <dbl> <I<lis>
#> 1 average 0.01 0.267 NA NA NA 1 paramet… 10 0.8 <dbl>
#> 2 average 0.02 0.531 NA NA NA 1 paramet… 10 0.8 <dbl>
#> 3 average 0.03 0.783 NA NA NA 1 paramet… 10 0.8 <dbl>
#> 4 average 0.04 1.02 NA NA NA 1 paramet… 10 0.8 <dbl>
#> 5 average 0.05 1.26 NA NA NA 1 paramet… 10 0.8 <dbl>
#> 6 average 0.06 1.48 NA NA NA 1 paramet… 10 0.8 <dbl>
#> 7 average 0.07 1.71 NA NA NA 1 paramet… 10 0.8 <dbl>
#> 8 average 0.08 1.93 NA NA NA 1 paramet… 10 0.8 <dbl>
#> 9 average 0.09 2.16 NA NA NA 1 paramet… 10 0.8 <dbl>
#> 10 average 0.1 2.38 NA NA NA 1 paramet… 10 0.8 <dbl>
#> # ℹ 89 more rows
Created on 2024-04-02 with reprex v2.1.0
beckyfisher commented
Apologies for the missing line. I retested this using the CRAN version and dev from poissonconsulting and cannot reproduce the error, so it must by an issue only on my fork.
joethorley commented
library(ssddata)
library(ssdtools)
example_dat <- ssddata::ccme_boron |>
dplyr::mutate(left=Conc, right=Conc)
left_censored_example <- example_dat
left_censored_example$left[c(3,6,8)] <- NA
left_censored_dists <- ssd_fit_dists(left_censored_example, left = "left", right = "right")
ssd_gof(left_censored_dists)
#> Error in if (glance$nobs[1] < 8) {: missing value where TRUE/FALSE needed
Created on 2024-04-03 with reprex v2.1.0