vdtest.glm {glmtoolbox} | R Documentation |
Test for Varying Dispersion Parameter in Generalized Linear Models
Description
Performs Rao's score test for varying dispersion parameter in weighted and unweighted generalized linear models in which the response distribution is assumed to be Gaussian, Gamma, or inverse Gaussian.
Usage
## S3 method for class 'glm'
vdtest(model, varformula, verbose = TRUE, ...)
Arguments
model |
an object of the class glm where the distribution of the response
variable is assumed to be |
varformula |
an (optional) |
verbose |
an (optional) logical switch indicating if should the report of results be printed. As default, |
... |
further arguments passed to or from other methods. |
Details
From the generalized linear model with varying dispersion in which
, where
is the dispersion parameter of the distribution used to describe the
response variable, the Rao's score test (denoted here as
) to assess the
hypothesis
versus
is computed,
where
. The corresponding p-value is
computed from the chi-squared distribution with
degrees of freedom,
that is, p-value = Prob
. If the object
model
corresponds to an unweighted generalized linear model, this test assesses assumptions
of constant variance and constant coefficient of variation on models in which the
response distribution is assumed to be Gaussian and Gamma, respectively.
Value
a list list with components including
statistic | value of the Rao's score test ( ), |
df | number of degrees of freedom ( ), |
p.value | p-value of the test, |
vars | names of explanatory variables for the dispersion parameter, |
References
Wei B.-C., Shi, J.-Q., Fung W.-K., Hu Y.-Q. (1998) Testing for Varying Dispersion in Exponential Family Nonlinear Models. Annals of the Institute of Statistical Mathematics 50, 277–294.
See Also
Examples
###### Example 1: Fuel consumption of automobiles
Auto <- ISLR::Auto
fit1 <- glm(mpg ~ weight*horsepower, family=inverse.gaussian("log"), data=Auto)
vdtest(fit1)
vdtest(fit1,varformula= ~ weight + horsepower)
vdtest(fit1,varformula= ~ log(weight) + log(horsepower))
###### Example 2: Hill races in Scotland
data(races)
fit2 <- glm(rtime ~ log(distance) + cclimb, family=Gamma("log"), data=races)
vdtest(fit2)
vdtest(fit2,varformula= ~ distance + cclimb)
vdtest(fit2,varformula= ~ log(distance) + log(cclimb))
###### Example 3: Mammal brain and body weights
data(brains)
fit3 <- glm(BrainWt ~ log(BodyWt), family=Gamma("log"), data=brains)
vdtest(fit3)
vdtest(fit3,varformula= ~ BodyWt)