vdtest.glm | R Documentation |
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.
## S3 method for class 'glm'
vdtest(model, varformula, verbose = TRUE, ...)
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. |
From the generalized linear model with varying dispersion in which
\log(\phi)=\gamma_0 + \gamma_1z_1 + \gamma_2z_2 + ... + \gamma_qz_q
, where
\phi
is the dispersion parameter of the distribution used to describe the
response variable, the Rao's score test (denoted here as S
) to assess the
hypothesis H_0: \gamma=0
versus H_1: \gamma\neq 0
is computed,
where \gamma=(\gamma_1,\ldots,\gamma_q)
. The corresponding p-value is
computed from the chi-squared distribution with q
degrees of freedom,
that is, p-value = Prob[\chi^2_{q} > S]
. 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.
a list list with components including
statistic | value of the Rao's score test (S ), |
df | number of degrees of freedom (q ), |
p.value | p-value of the test, |
vars | names of explanatory variables for the dispersion parameter, |
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.
vdtest.lm, vdtest.gnm
###### 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.