vdtest.lm | R Documentation |
Performs Rao's score test for varying dispersion parameter in weighted and unweighted normal linear models.
## S3 method for class 'lm'
vdtest(model, varformula, verbose = TRUE, ...)
model |
an object of the class lm. |
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 heteroskedastic normal linear model in which
\log(\sigma^2)=\gamma_0 + \gamma_1z_1 + \gamma_2z_2 + ...+ \gamma_qz_q
, where
\sigma^2
is the dispersion parameter of the distribution of the
random errors, 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 normal linear model, then the
test assess the assumption of constant variance, which coincides with the
non-studentized Breusch-Pagan test against heteroskedasticity.
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, |
Breusch T.S., Pagan A.R. (1979) A simple test for heteroscedasticity and random coefficient variation. Econometrica 47, 1287–1294.
Cook R.D., Weisberg S. (1983) Diagnostics for heteroscedasticity in regression. Biometrika 70, 1–10.
vdtest.glm
###### Example 1: Fuel consumption of automobiles
fit1 <- lm(mpg ~ log(hp) + log(wt), data=mtcars)
vdtest(fit1)
vdtest(fit1,varformula = ~ hp + wt)
vdtest(fit1,varformula = ~ hp + wt + hp*wt)
###### Example 2: Species richness in plots
data(richness)
fit2 <- lm(Species ~ Biomass + pH, data=richness)
vdtest(fit2)
### The test conclusions change when the outlying observations are excluded
fit2a <- lm(Species ~ Biomass + pH, data=richness, subset=-c(1,3,18,20))
vdtest(fit2a)
###### Example 3: Gas consumption in a home before and after insulation
whiteside <- MASS::whiteside
fit3 <- lm(Gas ~ Temp + Insul + Temp*Insul, data=whiteside)
vdtest(fit3)
### The test conclusions change when the outlying observations are excluded
fit3a <- lm(Gas ~ Temp + Insul + Temp*Insul, data=whiteside, subset=-c(8,9,36,46,55))
vdtest(fit3a)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.