is_separable: Are the two classes linearly separable?

View source: R/is_separable.R

is_separableR Documentation

Are the two classes linearly separable?

Description

The function is_separable determines if the two classes Y=1 and Y=-1 are linearly separable using columns of X.

Usage

is_separable(X, Y, add_intercept = FALSE)

Arguments

X

Covariate matrix. Each row of X corresponds to one observation.

Y

A vector of +1 and -1 representing the two classes. Y has the same length as the number of rows in X.

add_intercept

If TRUE, add an intercept to the matrix X. Set to FALSE by default.

Details

The two classes are separable if there exists a non-zero vector b that satisfies

y_i x_i^\top b \leq 0

for every observation i.

Value

Returns 1 if the data is separable and 0 otherwise.

References

The phase transition for the existence of the maximum likelihood estimate in high-dimensional logistic regression Emmanuel J. Candes and Pragya Sur, Ann. Statist., Volume 48, Number 1 (2020), 27-42.

Linear programming algorithms for detecting separated data in binary logistic regression models, Kjell Konis, Ph.D. thesis, Univ. Oxford.

See Also

glm

Examples

## Not run: 
n <- 1000; p <- 400
X <- matrix(rnorm(n*p, 0, 1), n, p)
Y <- 2 * rbinom(n, 1, 0.5) - 1
is_separable(X, Y, add_intercept = TRUE)

## End(Not run)

zq00/glmhd documentation built on April 7, 2023, 7:45 a.m.