HLtest.Rsq: Goodness-of-fit tests for GLMs for binary data

Description Usage Arguments Details Value Author(s) References Examples

View source: R/discrimFuns.R

Description

Goodness-of-fit tests for GLMs for binary data including the Hosmer-Lemeshow decile test and X-squared test with normal approximation.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S3 method for class 'Rsq'
HLtest(object, method = c("deciles", "fixed"),
         decile.type = 8, ...)

## S3 method for class 'HLtest.Rsq'
print(x, digits = getOption("digits"), ...)

## S3 method for class 'Rsq'
X2GOFtest(x, ...)

## S3 method for class 'X2GOFtest.Rsq'
print(x, ...)

Arguments

object

An Rsq object

x

An HLtest.Rsq or an X2GOFtest.Rsq object

method

The type of Hosmer-Lemeshow test to be performed. The "deciles" method should be more accurate (Hosmer et al, 1997)

decile.type

The quantile computation method; see quantile for details

digits

the desired number of printed digits

...

currently not used

Details

These tests are known to have very low power. They are only appropriate when the fitted frequencies are very low and when the covariate pattern dictates strictly binary observations.

Value

For HLtest.Rsq an object of class HLtest.Rsq with components

expected

the expected frequencies in the 2 x 10 entries

observed

the observed frequencies in the 2 x 10 entries

resid

Pearson residuals

X2

the Pearson X-squared statistic

p.value

the p-value for the goodness-of-fit test

method

the method used for the test

For X2GOFtest an object of class X2GOFtest with components

p.value

the p-value for the goodness-of-fit test

z.score

the standardized z-score for the goodness-of-fit test

RSS

the residual sums of squares term

X2

the pearson chi-squared statistic

Author(s)

Rune Haubo B Christensen

References

Hosmer, D.W. and Lemeshow, S. (1980). Goodness of fit tests for the multiple logistic regression model. Communications in Statistics - Theory and Methods, A9(10), p. 1043-1069.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Lifted from example(predict.glm):
ldose <- rep(0:5, 2)
numdead <- c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16)
sex <- factor(rep(c("M", "F"), c(6, 6)))
SF <- cbind(numdead, numalive=20-numdead)
budworm.lg <- glm(SF ~ sex*ldose, family=binomial)
## summary(budworm.lg)

(Rsq.budworm <- Rsq(budworm.lg))

HLtest(Rsq.budworm)
HLtest(Rsq.budworm, method="fixed")
X2GOFtest(Rsq.budworm)

binomTools documentation built on May 29, 2017, 10:12 p.m.