When applying gam.check
in the mgcv
package, R
produces some residual plots and basis dimension output. Is there a way to only produce the plots and not the printed output?
library(mgcv)
set.seed(0)
dat <- gamSim(1,n=200)
b <- gam(y~s(x0)+s(x1)+s(x2)+s(x3), data=dat)
plot(b, pages=1)
gam.check(b, pch=19, cex=.3)
There are four plots, from top left, moving down and across we have:
In the code below, I assume
b
contains your fitted model, as per your example. First some things we needNote the last two lines are applying the
NA
handling method used when the model was fitted to the information on thelinear.predictors
andy
, the stored copy of the response data.The above code and that shown below is all given in the first 10 or so lines of the
gam.check()
source. To view this, just enterat the R prompt.
Each plot is produced as follows:
QQ plot
This is produced via
qq.gam()
:Histogram of residuals
This is produced using
Residuals vs linear predictor
This is produced using
Observed vs fitted values
This is produced using