Skip to contents

This function saves the GAM model as RData (.rda) file. Optionally, it will save the model summary as a text (.txt) file, the mgcv::gam.check figures as a PNG (.png), and the mgcv::k.check output as a text (.txt) file.

Usage

save_gam(gam_model, output_file, model_summary = TRUE, model_check = FALSE)

Arguments

gam_model

GAM model object to be saved as an RData file.

output_file

RData output file name. Accepted a file extensions: .RData, .Rdata, .rdata, or .rda.

model_summary

A logical indicating whether the model summary output should be saved as a text file. Default: TRUE

model_check

A logical indicating whether the model check reports should be saved. Default: FALSE

Details

If model_summary is TRUE, the output of summary(gam_model) will be captured and saved in a text file with the following naming convention "<output_file>_Summary.txt".

If model_check is TRUE, the outputs of mgcv::gam.check will be captured and saved. mgcv::gam.check consists of two components:

  1. GAM model diagnostic plots, implemented through gratia::appraise. The output will be saved with following naming convention: "<output_file>_GamCheck.png"

  2. Smoothing basis dimension checks, implemented through mgcv::k.check. The output will be saved with the following naming convention: "<output_file>_GamCheck.txt"

Examples

if (FALSE) { # \dontrun{
save_gam(
  gam_model   = model_fit, 
  output_file = "output.rda"
)} # }