p_value.glm {glmglrt} | R Documentation |
Computing p-values of hypothesis tests on coefficients of Generalized Linear Models and other
Description
This S3 method is a specialization of parameters::p_value
for stats::glm
models.
By default, it computes Wald's P-values that are known to be more biased than LRT P-values,
but the behavior can be overriden by the method="LRT" argument.
This is for compatibility with the default method of parameters::p_value
.
Usage
## S3 method for class 'glm'
p_value(
model,
method = NULL,
parm = NULL,
alternative = c("two.sided", "less", "greater"),
H0 = 0,
debuglevel = 1,
force = FALSE,
...
)
Arguments
model |
glm object; as obtained by calling |
method |
character value; may either be "LRT" (synonym "Chisq"), "Rao", "wald" (default value, synonym "Wald" and "F"). |
parm |
integer or character vector or NULL; specify coefficients to test, by name or indexes. the default parm=NULL outputs all coefficients. |
alternative |
a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter. |
H0 |
numeric vector of length 1 or of the same length as parm; the value of the coefficient under the null hypothesis. Zero by default. |
debuglevel |
integer value; set to 0 (default) to disable warnings, 1 to enable warnings and 2 to enable warnings and notes. |
force |
logical; if TRUE, force computation of P-values in case of convergence problems. |
... |
Ignored arguments. Allows compatibility with the generic |
Value
a data.frame with two columns; the first column, Parameter represents the name of the coefficient and p (second column) represents the P-value of the hypothesis test against H0
Examples
require("parameters")
mod = glm(family="poisson", c(2,30) ~ c(0,1), offset=log(c(8,30)))
# Wald's tests (biased)
p_value(mod)
# Rao score tests (biased)
p_value(mod, method="Rao")
# LRT tests (less biased)
p_value(mod, method="LRT")
# only test slope (faster since only one test is performed)
p_value(mod, method="LRT", parm=2)
# is slope greater than log(2) ?
p_value(mod, method="LRT", parm=2, H0=log(2), alternative="greater")