Summarize a gam model in a clean mixed effects style.

summary_gamm(model, digits = 3)

Arguments

model

The mgcv model

digits

number of digits to display

Value

Invisibly returns a list with the variance components via extract_vc and fixed effects parameter, labeled vc and fe respectively.

Details

This displays the variance components and fixed effects from a gam model. Assumes an mgcv model of the form gam(... + s(g, bs='re')), but should work with just about any gam with a smooth term.

See also

Examples

library(mgcv) library(lme4) lmer_model <- lmer(Reaction ~ Days + (Days || Subject), data = sleepstudy) ga_model <- gam(Reaction ~ Days + s(Subject, bs = "re") + s(Days, Subject, bs = "re"), data = sleepstudy, method = "REML" ) summary(lmer_model)
#> Linear mixed model fit by REML ['lmerMod'] #> Formula: Reaction ~ Days + ((1 | Subject) + (0 + Days | Subject)) #> Data: sleepstudy #> #> REML criterion at convergence: 1743.7 #> #> Scaled residuals: #> Min 1Q Median 3Q Max #> -3.9626 -0.4625 0.0204 0.4653 5.1860 #> #> Random effects: #> Groups Name Variance Std.Dev. #> Subject (Intercept) 627.57 25.051 #> Subject.1 Days 35.86 5.988 #> Residual 653.58 25.565 #> Number of obs: 180, groups: Subject, 18 #> #> Fixed effects: #> Estimate Std. Error t value #> (Intercept) 251.405 6.885 36.513 #> Days 10.467 1.560 6.712 #> #> Correlation of Fixed Effects: #> (Intr) #> Days -0.184
summary_gamm(ga_model)
#> #> Variance components:
#> group effect variance sd sd_2.5 sd_97.5 var_prop #> Subject Intercept 627.571 25.051 16.085 39.015 0.477 #> Subject Days 35.858 5.988 4.025 8.908 0.027 #> Residual 653.582 25.565 22.792 28.676 0.496
#> #> #> Fixed Effects:
#> Term Estimate Std. Error t value Pr(>|t|) #> (Intercept) 251.405 6.885 36.513 0.000 #> Days 10.467 1.560 6.712 0.000