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

Description Usage Arguments Value Note See Also Examples

View source: R/sig.R

Description

Significance tests for a binary regression models fit with glm

Usage

1
2
3
4
sig(x, ...)

## S3 method for class '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 = B / SE[B]

This should be normally distributed.

LR

The likelihood ratio test for each coefficient:

LR = -2 * log(likelihood without / likelihood with variable)

which is:

LR = -2 * SUM(y * log(P / y) + (1 - y) * log((1 - P) / (1 - y)))

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:

ybar = (SUM y[i]) / n

and

xbar = (SUM x[i] * n[i]) / n

The statistic is:

ST = SUM x[i](y[i] - ybar) / (ybar(1 - ybar) SUM (x[i] - xbar)^2)^0.5

If the value of the coefficient is correct, the test should follow a standard normal distribution.

Note

The result has the class "sig.glm". The print method for this class shows only the model coefficients and p values.

See Also

?aod::wald.test
?statmod::glm.scoretest
For corrected score tests:
?mdscore::mdscore

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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")

dardisco/LogisticDx documentation built on Dec. 26, 2021, 8:11 p.m.