vdtest.glm: Test for Varying Dispersion Parameter in Generalized Linear...

View source: R/glms.R

vdtest.glmR 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 gaussian, Gamma or inverse.gaussian.

varformula

an (optional) formula expression of the form ~ z1 + z2 + ... + zq describing only the potential explanatory variables for the dispersion. By default, the same explanatory variables are taken as in the model for the mean.

verbose

an (optional) logical switch indicating if should the report of results be printed. By default, verbose is set to be TRUE.

...

further arguments passed to or from other methods.

Details

From the generalized lineal 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 then 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 (S),
df number of degrees of freedom (q),
p.value p-value of the test,

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

vdtest.lm

Examples

###### Example 1: Fuel consumption of automobiles
Auto <- ISLR::Auto
fit1 <- glm(mpg ~ weight*horsepower, family=inverse.gaussian("log"), data=Auto)
vdtest(fit1)

###### Example 2: Hill races in Scotland
data(races)
fit2 <- glm(rtime ~ log(distance) + cclimb, family=Gamma("log"), data=races)
vdtest(fit2)

###### Example 3: Mammal brain and body weights
data(brains)
fit3 <- glm(BrainWt ~ log(BodyWt), family=Gamma("log"), data=brains)
vdtest(fit3)

glmtoolbox documentation built on Oct. 10, 2023, 9:06 a.m.