@@ -605,32 +605,31 @@ model_parameters.default <- function(model,
605605 )
606606
607607 # extract model parameters table, as data frame
608- out <- tryCatch(
609- .model_parameters_generic(
610- model = model ,
611- ci = ci ,
612- ci_method = ci_method ,
613- bootstrap = bootstrap ,
614- iterations = iterations ,
615- merge_by = " Parameter" ,
616- standardize = standardize ,
617- exponentiate = exponentiate ,
618- p_adjust = p_adjust ,
619- include_info = include_info ,
620- keep_parameters = keep ,
621- drop_parameters = drop ,
622- vcov = vcov ,
623- vcov_args = vcov_args ,
624- verbose = verbose ,
625- ...
626- ),
627- error = function (e ) {
628- fail <- NA
629- attr(fail , " error" ) <- gsub(" " , " " , gsub(" \\ n" , " " , e $ message ), fixed = TRUE )
630- fail
631- }
608+ out <- .model_parameters_generic(
609+ model = model ,
610+ ci = ci ,
611+ ci_method = ci_method ,
612+ bootstrap = bootstrap ,
613+ iterations = iterations ,
614+ merge_by = " Parameter" ,
615+ standardize = standardize ,
616+ exponentiate = exponentiate ,
617+ p_adjust = p_adjust ,
618+ include_info = include_info ,
619+ keep_parameters = keep ,
620+ drop_parameters = drop ,
621+ vcov = vcov ,
622+ vcov_args = vcov_args ,
623+ verbose = verbose ,
624+ ...
632625 )
633626
627+ attr(out , " object_name" ) <- insight :: safe_deparse_symbol(substitute(model ))
628+ out
629+ }
630+
631+
632+ .fail_error_message <- function (out , model ) {
634633 # tell user if something went wrong...
635634 if (length(out ) == 1 && isTRUE(is.na(out ))) {
636635 insight :: format_error(
@@ -650,14 +649,9 @@ model_parameters.default <- function(model,
650649 )
651650 )
652651 }
653-
654- attr(out , " object_name" ) <- insight :: safe_deparse_symbol(substitute(model ))
655- out
656652}
657653
658654
659-
660-
661655# helper function for the composition of the parameters table,
662656# including a bunch of attributes required for further processing
663657# (like printing etc.)
@@ -682,79 +676,91 @@ model_parameters.default <- function(model,
682676 ... ) {
683677 dots <- list (... )
684678
685- # ==== 1. first step, extracting (bootstrapped) model parameters -------
686-
687- # Processing, bootstrapped parameters
688- if (bootstrap ) {
689- # set default method for bootstrapped CI
690- if (is.null(ci_method ) || missing(ci_method )) {
691- ci_method <- " quantile"
692- }
693-
694- fun_args <- list (
695- model ,
696- iterations = iterations ,
697- ci = ci ,
698- ci_method = ci_method
699- )
700- fun_args <- c(fun_args , dots )
701- params <- do.call(" bootstrap_parameters" , fun_args )
679+ out <- tryCatch(
680+ {
681+ # ==== 1. first step, extracting (bootstrapped) model parameters -------
682+
683+ # Processing, bootstrapped parameters
684+ if (bootstrap ) {
685+ # set default method for bootstrapped CI
686+ if (is.null(ci_method ) || missing(ci_method )) {
687+ ci_method <- " quantile"
688+ }
689+
690+ fun_args <- list (
691+ model ,
692+ iterations = iterations ,
693+ ci = ci ,
694+ ci_method = ci_method
695+ )
696+ fun_args <- c(fun_args , dots )
697+ params <- do.call(" bootstrap_parameters" , fun_args )
698+
699+ # Processing, non-bootstrapped parameters
700+ } else {
701+ # set default method for CI
702+ if (is.null(ci_method ) || missing(ci_method )) {
703+ ci_method <- " wald"
704+ }
705+
706+ fun_args <- list (
707+ model ,
708+ ci = ci ,
709+ component = component ,
710+ merge_by = merge_by ,
711+ standardize = standardize ,
712+ effects = effects ,
713+ ci_method = ci_method ,
714+ p_adjust = p_adjust ,
715+ keep_parameters = keep_parameters ,
716+ drop_parameters = drop_parameters ,
717+ verbose = verbose ,
718+ vcov = vcov ,
719+ vcov_args = vcov_args
720+ )
721+ fun_args <- c(fun_args , dots )
722+ params <- do.call(" .extract_parameters_generic" , fun_args )
723+ }
724+
725+
726+ # ==== 2. second step, exponentiate -------
727+
728+ # exponentiate coefficients and SE/CI, if requested
729+ params <- .exponentiate_parameters(params , model , exponentiate )
730+
731+
732+ # ==== 3. third step, add information as attributes -------
733+
734+ # add further information as attributes
735+ params <- .add_model_parameters_attributes(
736+ params ,
737+ model ,
738+ ci ,
739+ exponentiate ,
740+ bootstrap ,
741+ iterations ,
742+ ci_method = ci_method ,
743+ p_adjust = p_adjust ,
744+ include_info = include_info ,
745+ verbose = verbose ,
746+ ...
747+ )
702748
703- # Processing, non-bootstrapped parameters
704- } else {
705- # set default method for CI
706- if (is.null(ci_method ) || missing(ci_method )) {
707- ci_method <- " wald"
749+ class(params ) <- c(" parameters_model" , " see_parameters_model" , class(params ))
750+ params
751+ },
752+ error = function (e ) {
753+ fail <- NA
754+ attr(fail , " error" ) <- gsub(" " , " " , gsub(" \\ n" , " " , e $ message ), fixed = TRUE )
755+ fail
708756 }
709-
710- fun_args <- list (
711- model ,
712- ci = ci ,
713- component = component ,
714- merge_by = merge_by ,
715- standardize = standardize ,
716- effects = effects ,
717- ci_method = ci_method ,
718- p_adjust = p_adjust ,
719- keep_parameters = keep_parameters ,
720- drop_parameters = drop_parameters ,
721- verbose = verbose ,
722- vcov = vcov ,
723- vcov_args = vcov_args
724- )
725- fun_args <- c(fun_args , dots )
726- params <- do.call(" .extract_parameters_generic" , fun_args )
727- }
728-
729-
730- # ==== 2. second step, exponentiate -------
731-
732- # exponentiate coefficients and SE/CI, if requested
733- params <- .exponentiate_parameters(params , model , exponentiate )
734-
735-
736- # ==== 3. third step, add information as attributes -------
737-
738- # add further information as attributes
739- params <- .add_model_parameters_attributes(
740- params ,
741- model ,
742- ci ,
743- exponentiate ,
744- bootstrap ,
745- iterations ,
746- ci_method = ci_method ,
747- p_adjust = p_adjust ,
748- include_info = include_info ,
749- verbose = verbose ,
750- ...
751757 )
752758
753- class(params ) <- c(" parameters_model" , " see_parameters_model" , class(params ))
754- params
755- }
756-
759+ # check if everything is ok
760+ .fail_error_message(out , model )
757761
762+ out
763+ }
758764
759765
760766# ################### .glm ----------------------
0 commit comments