Skip to content

Commit

Permalink
Confidence intervals for ICC, it seems that none of the ci_methods …
Browse files Browse the repository at this point in the history
…work (neither default, `boot` or `analytical`).

Fixes #745
  • Loading branch information
strengejacke committed Jul 11, 2024
1 parent db8ab03 commit aa555c3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion R/helpers.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# small wrapper around this commonly used try-catch
.safe <- function(code, on_error = NULL) {
if (getOption("easystats_erros", FALSE) && is.null(on_error)) {
if (isTRUE(getOption("easystats_erros", FALSE) && is.null(on_error))) {
code
} else {
tryCatch(code, error = function(e) on_error)
Expand Down
12 changes: 10 additions & 2 deletions R/icc.R
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,11 @@ print.icc_decomposed <- function(x, digits = 2, ...) {
.boot_icc_fun <- function(data, indices, model, tolerance) {
d <- data[indices, ] # allows boot to select sample
fit <- suppressWarnings(suppressMessages(stats::update(model, data = d)))
vars <- .compute_random_vars(fit, tolerance, verbose = FALSE)
vars <- .compute_random_vars(
fit,
tolerance,
verbose = isTRUE(getOption("easystats_erros", FALSE))
)
if (is.null(vars) || all(is.na(vars))) {
return(c(NA, NA))
}
Expand All @@ -604,7 +608,11 @@ print.icc_decomposed <- function(x, digits = 2, ...) {

# bootstrapping using "lme4::bootMer"
.boot_icc_fun_lme4 <- function(model) {
vars <- .compute_random_vars(model, tolerance = 1e-05, verbose = FALSE)
vars <- .compute_random_vars(
model,
tolerance = 1e-10,
verbose = isTRUE(getOption("easystats_erros", FALSE))
)
if (is.null(vars) || all(is.na(vars))) {
return(c(NA, NA))
}
Expand Down
12 changes: 10 additions & 2 deletions R/r2_nakagawa.R
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,11 @@ print.r2_nakagawa <- function(x, digits = 3, ...) {
.boot_r2_fun <- function(data, indices, model, tolerance) {
d <- data[indices, ] # allows boot to select sample
fit <- suppressWarnings(suppressMessages(stats::update(model, data = d)))
vars <- .compute_random_vars(fit, tolerance, verbose = FALSE)
vars <- .compute_random_vars(
fit,
tolerance,
verbose = isTRUE(getOption("easystats_erros", FALSE))
)
if (is.null(vars) || all(is.na(vars))) {
return(c(NA, NA))
}
Expand All @@ -298,7 +302,11 @@ print.r2_nakagawa <- function(x, digits = 3, ...) {

# bootstrapping using "lme4::bootMer"
.boot_r2_fun_lme4 <- function(model) {
vars <- .compute_random_vars(model, tolerance = 1e-05, verbose = FALSE)
vars <- .compute_random_vars(
model,
tolerance = 1e-10,
verbose = isTRUE(getOption("easystats_erros", FALSE))
)
if (is.null(vars) || all(is.na(vars))) {
return(c(NA, NA))
}
Expand Down

0 comments on commit aa555c3

Please sign in to comment.