Learn R Programming

safeBinaryRegression (version 0.1-3)

glm: Fitting Generalized Linear Models

Description

This function overloads the glm function so that a check for the existence of the maximum likelihood estimate is computed before fitting a ‘glm’ with a binary response.

Usage

glm(formula, family = gaussian, data, weights, subset, na.action, start = NULL, etastart, mustart, offset, control = glm.control(...), model = TRUE, method = "glm.fit", x = FALSE, y = TRUE, contrasts = NULL, ..., separation = c("find", "test"))

Arguments

separation
either “find” or “test”. Both options prevent the model from being fit to binary data when the maximum likelihood estimate does not exist. Additionally, when separation = "find", the terms separating the sample points are identified when the maximum likelihood estimate is found not to exist.
formula
see glm
family
see glm
data
see glm
weights
see glm
subset
see glm
na.action
see glm
start
see glm
etastart
see glm
mustart
see glm
offset
see glm
control
see glm
model
see glm
method
see glm
x
see glm
y
see glm
contrasts
see glm
...
see glm

Value

See the return value for the glm function.

Details

This function checks for the existence of the maximum likelihood estimate before the ‘glm’ function is used to fit binary regression models by solving the linear program proposed in Konis (2007).

References

Kjell Konis (2007). Linear programming algorithms for detecting separated data in binary logistic regression models. DPhil, University of Oxford http://ora.ouls.ox.ac.uk/objects/uuid:8f9ee0d0-d78e-4101-9ab4-f9cbceed2a2a

See Also

glm.

Examples

Run this code
## A set of 4 completely separated sample points ##
x <- c(-2, -1, 1, 2)
y <- c(0, 0, 1, 1)

## Not run: glm(y ~ x, family = binomial)


## A set of 4 quasicompletely separated sample points ##
x <- c(-2, 0, 0, 2)
y <- c(0, 0, 1, 1)

## Not run: glm(y ~ x, family = binomial)

Run the code above in your browser using DataLab