@@ -14,9 +14,6 @@ bayestestR::equivalence_test
1414# ' @param ci Confidence Interval (CI) level. Default to `0.95` (`95%`).
1515# ' @param rule Character, indicating the rules when testing for practical
1616# ' equivalence. Can be `"bayes"`, `"classic"` or `"cet"`. See 'Details'.
17- # ' @param test Hypothesis test for computing contrasts or pairwise comparisons.
18- # ' See [`?ggeffects::test_predictions`](https://strengejacke.github.io/ggeffects/reference/test_predictions.html)
19- # ' for details.
2017# ' @param verbose Toggle warnings and messages.
2118# ' @param ... Arguments passed to or from other methods.
2219# ' @inheritParams model_parameters.glmmTMB
@@ -405,85 +402,6 @@ equivalence_test.parameters_model <- function(x,
405402}
406403
407404
408- # ' @rdname equivalence_test.lm
409- # ' @export
410- equivalence_test.ggeffects <- function (x ,
411- range = " default" ,
412- rule = " classic" ,
413- test = " pairwise" ,
414- verbose = TRUE ,
415- ... ) {
416- insight :: check_if_installed(" ggeffects" )
417-
418- # get attributes from ggeffects objects, so we have the original model and terms
419- focal <- attributes(x )$ original.terms
420- obj_name <- attributes(x )$ model.name
421- ci <- attributes(x )$ ci.lvl
422- dof <- attributes(x )$ df
423-
424- x <- .get_ggeffects_model(x )
425-
426- # validation check rope range
427- rule <- match.arg(tolower(rule ), choices = c(" bayes" , " classic" , " cet" ))
428- range <- .check_rope_range(x , range , verbose )
429-
430- out <- ggeffects :: test_predictions(
431- x ,
432- terms = focal ,
433- test = test ,
434- equivalence = range ,
435- verbose = verbose ,
436- ...
437- )
438-
439- out <- insight :: standardize_names(out )
440-
441- # we only have one type of CIs
442- conf_int <- conf_int2 <- as.data.frame(t(out [c(" CI_low" , " CI_high" )]))
443-
444- l <- Map(
445- function (ci_wide , ci_narrow ) {
446- .equivalence_test_numeric(
447- ci = ci ,
448- ci_wide ,
449- ci_narrow ,
450- range_rope = range ,
451- rule = rule ,
452- dof = dof ,
453- verbose = verbose
454- )
455- }, conf_int , conf_int2
456- )
457-
458- # bind to data frame
459- dat <- do.call(rbind , l )
460-
461- # remove old CIs, bind results from equivalence test
462- out $ CI_low <- out $ CI_high <- NULL
463- out $ CI <- ci
464- out <- cbind(out , dat )
465-
466- # standardize column order
467- cols <- c(
468- " Estimate" , " Contrast" , " Slope" , " Predicted" , " CI" , " CI_low" , " CI_high" ,
469- " SGPV" , " ROPE_low" , " ROPE_high" , " ROPE_Percentage" , " ROPE_Equivalence" , " p"
470- )
471-
472- # order of shared columns
473- shared_order <- intersect(cols , colnames(out ))
474- parameter_columns <- setdiff(colnames(out ), shared_order )
475- # add remaining columns, sort
476- out <- out [c(parameter_columns , shared_order )]
477-
478- attr(out , " object_name" ) <- obj_name
479- attr(out , " parameter_columns" ) <- parameter_columns
480- attr(out , " rule" ) <- rule
481- attr(out , " rope" ) <- range
482- class(out ) <- c(" equivalence_test_lm" , " see_equivalence_test_ggeffects" , " data.frame" )
483- out
484- }
485-
486-
487405# helper -------------------
488406
489407
0 commit comments