| compare_models | R Documentation |
Compare two models using the debiased score test
compare_models(fit.0, ...)
fit.0 |
A fitted null-model object. Methods are provided for
|
... |
Additional arguments passed to the dispatched method,
notably the alternative-model fit |
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.
Dhawan, A., Guo, F. R. and Shah, R. D. (2026). The debiased score test: hunt-and-test for semiparametric hypotheses. arXiv:2607.28861. https://arxiv.org/abs/2607.28861
compare_models.glm, compare_models.lm,
compare_models.gam,
gof_test, dScoreTest
set.seed(42)
n <- 500
dat <- data.frame(x1 = rnorm(n), x2 = rnorm(n), x3 = rnorm(n))
dat$x3 <- dat$x3 + (dat$x1 + dat$x2) / 3
dat$y <- 5 * exp(dat$x1 + dat$x3) + rnorm(n) * 3
fit.0 <- glm(y ~ x1 + x3, family = gaussian(link = "log"),
data = dat, start = rep(1, 3))
fit.1 <- glm(y ~ x1 + x2 + x3, family = gaussian(link = "log"),
data = dat, start = rep(1, 4))
# test fit.0 against fit.1: should not be rejected
compare_models(fit.0, fit.1)
compare_models(fit.0, fit.1, hunt.style="wls")
anova(fit.0, fit.1)
# test a misspecified null model: should be rejected
fit.00 <- glm(y ~ x2, family = gaussian(link = "log"),
data = dat, start = rep(1, 2))
compare_models(fit.00, fit.1)
plot(compare_models(fit.00, fit.1))
compare_models(fit.00, fit.1, hunt.style="wls")
plot(compare_models(fit.00, fit.1, hunt.style="wls"))
anova(fit.00, fit.1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.