11# classes: .gam, .list
22
3-
43# ################### .gam ------
54
6-
75# ' @export
86model_parameters.gam <- model_parameters.cgam
97
@@ -14,10 +12,16 @@ ci.gam <- function(x, ci = 0.95, method = NULL, ...) {
1412}
1513
1614
15+ # ' @param re_test Logical, if `TRUE` (default), tests for random effects terms
16+ # ' are performed. Only applies to `mgcv::gam()` model. For large models these
17+ # ' tests can be computationally expensive, in which case it is recommended to
18+ # ' set this argument to `FALSE`.
19+ # ' @rdname standard_error
1720# ' @export
18- standard_error.gam <- function (model , ... ) {
19- p.table <- summary(model )$ p.table
20- s.table <- summary(model )$ s.table
21+ standard_error.gam <- function (model , re_test = TRUE , ... ) {
22+ summ <- summary(model , re.test = re_test )
23+ p.table <- summ $ p.table
24+ s.table <- summ $ s.table
2125 d1 <- d2 <- NULL
2226
2327 if (! is.null(p.table )) {
@@ -28,22 +32,21 @@ standard_error.gam <- function(model, ...) {
2832 )
2933 }
3034
31- if (! is.null(s.table )) {
32- d2 <- .data_frame(
33- Parameter = rownames(s.table ),
34- SE = NA ,
35- Component = " smooth_terms"
36- )
35+ if (! is.null(s.table ) && nrow(s.table ) > 0 ) {
36+ d2 <- .data_frame(Parameter = rownames(s.table ), SE = NA , Component = " smooth_terms" )
3737 }
3838
3939 insight :: text_remove_backticks(rbind(d1 , d2 ), verbose = FALSE )
4040}
4141
4242
43+ # ' @inheritParams standard_error.gam
44+ # ' @rdname p_value
4345# ' @export
44- p_value.gam <- function (model , ... ) {
45- p.table <- summary(model )$ p.table
46- s.table <- summary(model )$ s.table
46+ p_value.gam <- function (model , re_test = TRUE , ... ) {
47+ summ <- summary(model , re.test = re_test )
48+ p.table <- summ $ p.table
49+ s.table <- summ $ s.table
4750 d1 <- d2 <- NULL
4851
4952 if (! is.null(p.table )) {
@@ -54,7 +57,7 @@ p_value.gam <- function(model, ...) {
5457 )
5558 }
5659
57- if (! is.null(s.table )) {
60+ if (! is.null(s.table ) && nrow( s.table ) > 0 ) {
5861 d2 <- .data_frame(
5962 Parameter = rownames(s.table ),
6063 p = as.vector(s.table [, 4 ]),
@@ -68,7 +71,9 @@ p_value.gam <- function(model, ...) {
6871
6972# ' @export
7073simulate_model.gam <- function (model , iterations = 1000 , ... ) {
71- if (is.null(iterations )) iterations <- 1000
74+ if (is.null(iterations )) {
75+ iterations <- 1000
76+ }
7277
7378 beta <- stats :: coef(model )
7479 varcov <- insight :: get_varcov(model , component = " all" , ... )
@@ -83,7 +88,6 @@ simulate_model.gam <- function(model, iterations = 1000, ...) {
8388
8489# ################### .list ------
8590
86-
8791# ' @export
8892model_parameters.list <- function (model , ... ) {
8993 if (" gam" %in% names(model )) {
@@ -94,7 +98,9 @@ model_parameters.list <- function(model, ...) {
9498 model <- model $ pamobject
9599 model_parameters(model , ... )
96100 } else {
97- insight :: format_error(" We don't recognize this object of class `list`. Please raise an issue." )
101+ insight :: format_error(
102+ " We don't recognize this object of class `list`. Please raise an issue."
103+ )
98104 }
99105}
100106
0 commit comments