# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.regression.linear.logistic

## Class LogisticRegression

• java.lang.Object
• com.numericalmethod.suanshu.stats.regression.linear.logistic.LogisticRegression
• All Implemented Interfaces:
LinearModel

public class LogisticRegression
extends Object
implements LinearModel
A logistic regression (sometimes called the logistic model or logit model) is used for prediction of the probability of occurrence of an event by fitting data to a logit function logistic curve. It is a generalized linear model used for binomial regression.

This particular implementation works with binary data (y).

• Wikipedia: Logistic regression
• P. J. MacCullagh and J. A. Nelder, "pp.114, Section 4.4, Likelihood functions for binary data," in Generalized Linear Models, 2nd ed."
• ### Constructor Summary

Constructors
Constructor and Description
LogisticRegression(LMProblem problem)
Constructs a Logistic instance.
LogisticRegression(LogisticProblem problem)
Constructs a Logistic instance.
• ### Method Summary

All Methods
Modifier and Type Method and Description
double AIC()
Gets the AIC.
LogisticBeta beta()
Gets $$\hat{\beta}$$ and statistics.
double Ey(Vector x)
Calculates the probability of occurrence (y = 1).
static RealScalarFunction logLikelihood(LogisticProblem problem)
Constructs the log-likelihood function for a logistic regression problem.
double ML()
Gets the maximum log-likelihood.
LogisticResiduals residuals()
Gets the residual analysis of an OLS regression.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### LogisticRegression

public LogisticRegression(LogisticProblem problem)
Constructs a Logistic instance.
Parameters:
problem - the logistic regression problem to be solved
• #### LogisticRegression

public LogisticRegression(LMProblem problem)
Constructs a Logistic instance.
Parameters:
problem - the logistic regression problem to be solved
• ### Method Detail

• #### logLikelihood

public static RealScalarFunction logLikelihood(LogisticProblem problem)
Constructs the log-likelihood function for a logistic regression problem.
Returns:
the log-likelihood function
• #### Ey

public double Ey(Vector x)
Calculates the probability of occurrence (y = 1).
Specified by:
Ey in interface LinearModel
Parameters:
x - the independent variables
Returns:
the probability of occurrence
• #### beta

public LogisticBeta beta()
Description copied from interface: LinearModel
Gets $$\hat{\beta}$$ and statistics.
Specified by:
beta in interface LinearModel
Returns:
$$\hat{\beta}$$ and statistics
• #### residuals

public LogisticResiduals residuals()
Description copied from interface: LinearModel
Gets the residual analysis of an OLS regression.
Specified by:
residuals in interface LinearModel
Returns:
the residual analysis
• #### ML

public double ML()
Gets the maximum log-likelihood.
Returns:
the maximum log-likelihood
• #### AIC

public double AIC()
Gets the AIC.
Returns:
the AIC