| gof_test.gam | R Documentation |
Debiased score test for goodness of fit of an mgcv::gam fit.
## S3 method for class 'gam'
gof_test(
object,
hunt.style = "optimal",
hunt.method = "grf",
hunt_fun = NULL,
trim.outlier.hunt = TRUE,
X.cols.exclude = NULL,
splits = c(0.5, 0.5),
arg.hunt_fun = NULL,
predict_fun_hunt = NULL,
verbose = FALSE,
...
)
object |
Fitted |
hunt.style |
Hunting algorithm with the following options.
|
hunt.method |
Built-in method for hunting. Currently available:
When this is set to any other value, arguments |
hunt_fun |
Default |
trim.outlier.hunt |
If |
X.cols.exclude |
Columns in |
splits |
Numeric vector of length 2 or 3 giving the relative sizes
of the sample splits; rescaled internally to sum to one.
Default is |
arg.hunt_fun |
Extra arguments (default |
predict_fun_hunt |
When a customized |
verbose |
Default |
... |
Unused; present for S3 generic/method consistency. |
Only the numeric predictors appearing in stats::model.frame(object)
are exposed to the hunt; X.cols.exclude indexes into these
predictor variables (not basis columns). Factor-by smooths and other
non-numeric predictors are not currently supported. Formulas using
offset() terms, a weights argument, or a multi-column
response (e.g. cbind(succ, fail) ~ ...) are also not supported.
An object of class "dScoreTest": a list whose key elements
are the debiased test statistic t.stat and the one-sided p-value
p.val (right tail of the standard normal), along with the test-set
score residuals, the hunted direction, and the call. It has
print,
summary and
plot methods.
set.seed(42)
dat <- mgcv::gamSim(eg=1, n=500, dist="normal", scale=2, verbose = FALSE)
dat.0 <- dat[,1:5]
# well-specified
fit.0 <- mgcv::gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat.0)
test.0 <- gof_test(fit.0)
# f3=0, also well-specified
fit.1 <- mgcv::gam(y~s(x0)+s(x1)+s(x2),data=dat.0)
test.1 <- gof_test(fit.1)
plot(test.1)
# misspecified
dat.1 <- dat.0
dat.1$y <- dat.1$y * dat$f0
fit.2 <- mgcv::gam(y~s(x0)+s(x1)+s(x2)+s(x3), data=dat.1)
test.2 <- gof_test(fit.2)
plot(test.2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.