glm: Fitting Generalized Linear Models

Description Usage Arguments Details Value Author(s) References See Also Examples

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

1
2
3
4
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

The arguments are identical to the arguments of the glm function provided in the ‘stats’ package with the exception of

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.

The following arguments are passed to the glm function:

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

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).

Value

See the return value for the glm function.

Author(s)

Kjell Konis kjell.konis@epfl.ch

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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)

Example output

Loading required package: lpSolveAPI

Attaching package: 'safeBinaryRegression'

The following object is masked from 'package:stats':

    glm

safeBinaryRegression documentation built on May 2, 2019, 4:45 p.m.