Learn R Programming

mgcViz (version 0.2.0)

check.gamViz: Some diagnostics for a fitted gam model

Description

Takes a fitted GAM model and produces some diagnostic information about the fitting procedure and results. The default is to produce 4 residual plots, some information about the convergence of the smoothness selection optimization, and to run diagnostic tests of whether the basis dimension choises are adequate.

Usage

# S3 method for gamViz
check(
  obj,
  type = c("auto", "deviance", "pearson", "response", "tunif", "tnormal"),
  k.sample = 5000,
  k.rep = 200,
  maxpo = 10000,
  a.qq = list(),
  a.hist = list(),
  a.respoi = list(),
  ...
)

Value

An object of class checkGam, which is simply a list of ggplot objects.

Arguments

obj

an object of class gamViz, the output of a getViz() call.

type

type of residuals, see residuals.gamViz, used in all plots.

k.sample

above this k testing uses a random sub-sample of data.

k.rep

how many re-shuffles to do to get p-value for k testing.

maxpo

maximum number of residuals points that will be plotted in the scatter-plots. If number of datapoints > maxpo, then a subsample of maxpo points will be plotted.

a.qq

list of arguments to be passed to qq.gamViz. See qq.gamViz.

a.hist

list of arguments to be passed to ggplot2::geom_histogram.

a.respoi

list of arguments to be passed to ggplot2::geom_point.

...

currently not used.

Details

This is a essentially a re-write of mgcv::gam.check using ggplot2. See mgcv::gam.check for details.

Examples

Run this code
library(mgcViz)
set.seed(0)
dat <- gamSim(1, n = 200)
b <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat)
b <- getViz(b)

# Checks using default options
check(b)

# Change some algorithmic and graphical parameters
check(b,
      a.qq = list(method = "tnorm", 
                  a.cipoly = list(fill = "light blue")), 
      a.respoi = list(size = 0.2), 
      a.hist = list(bins = 10))

Run the code above in your browser using DataLab