Learn R Programming

LogisticDx (version 0.3)

sig: Significance tests for a binary regression models fit with glm

Description

Significance tests for a binary regression models fit with glm

Usage

sig(x, ...)

# S3 method for glm sig(x, ..., test = c("var", "coef"))

Arguments

x

A regression model with class glm and x$family$family == "binomial".

...

Not used.

test

What to test.

  • If test="var" (the default), will test significance for each variable in the model. This includes the intercept, if present. This means factors are tested for all levels simultaneously.

  • If test="coef", will test significance for each coefficient in the model. This means the 'dummy variables' created from factors will be tested individually.

Value

A list of data.tables as follows:

Wald

The Wald test for each coefficient which is: $$W = \frac{\hat{\beta}}{\hat{SE_{\beta}}}$$ This should be normally distributed.

LR

The likelihood ratio test for each coefficient: $$LR = -2 \log{\frac{\mathrm{likelihood \phantom{+} without \phantom{+} variable}}{ \mathrm{likelihood \phantom{+} with \phantom{+} variable}}}$$ which is: $$LR = -2 \sum_{i=1}^n(y_i \log{\frac{P_i}{y_i}} + (1 - y_i) \log{\frac{1 - P_i}{1-y_i}})$$ When comparing a fitted model to a saturated model (i.e. \(P_i = y_i\) and likelihood \(=1\)), the \(LR\) is referred to as the model deviance, \(D\).

score

The score test, also known as the Rao, Cochran-Armitage trend and the Lagrange multiplier test. This removes a variable from the model, then assesses the change. For logistic regression this is based on: $$\bar{y} = \frac{\sum_{i=1}^n y_i}{n}$$ and $$\bar{x} = \frac{\sum_{i=1}^n x_i n_i}{n}$$ The statistic is: $$\mathrm{ST} = \frac{\sum_{i=1}^n y_i(x_i - \bar{x})}{ \sqrt{\bar{y}(1-\bar{y})\sum_{i=1}^n (x_i-\bar{x}^2)}}$$ If the value of the coefficient is correct, the test should follow a standard normal distribution.

See Also

?aod::wald.test

?statmod::glm.scoretest

For corrected score tests:

?mdscore::mdscore

Examples

Run this code
# NOT RUN {
data(ageChd)
## H&L 2nd ed. Table 1.3. Page 10.
summary(g1 <- glm(chd ~ age, data=ageChd, family=binomial))
sig(g1)
data(lbw)
## Table 2.2. Page 36.
summary(g2 <- glm(LOW ~ AGE + LWT + RACE + FTV,
                  data=lbw, family=binomial))
sig(g2)
## Table 2.3. Pages 38-39.
summary(g3 <- glm(LOW ~ LWT + RACE,
                  data=lbw, family=binomial))
sig(g3, test="coef")
## RACE is more significant when dropped as a factor
## 
sig(g3, test="var")
# }

Run the code above in your browser using DataLab