Regress.LogisticRegress Method

Overload List

#SignatureDescription
1function LogisticRegress(const y: TVec; const A: TMtx; const B: TVec; const Theta: TVec; const StdErr: TVec; out FMin: Double; out StopReason: TOptStopReason; MaxIter: Integer; Tolerance: Double; AutoInitEstimates: Boolean): Integer;Ordinal logistic regression.
2procedure LogisticRegress(const y: TVec; const n: TVec; const b: TVec; const A: TMtx; Offset: Double; const YCalc: TVec; const BStd: TVec; Tolerance: Double);Logistic regression.

Overload 1: function LogisticRegress(const y: TVec; const A: TMtx; const B: TVec; const Theta: TVec; const StdErr: TVec; out FMin: Double; out StopReason: TOptStopReason; MaxIter: Integer; Tolerance: Double; AutoInitEstimates: Boolean): Integer;

Ordinal logistic regression.

#NameDescription
1yResponse levels.
2AMatrix of independent variables. It is assumed to have full column rank.
3BSet it to define initial estimates for B. After the call to LogisticRegress returns regression parameter estimates for B.
4ThetaSet it to define initial estimates for Theta. After the call to LogisticRegress returns regression parameter estimates for Theta.
5FMinReturns logistic log-likehood function, evaluated at minimum.
6StopReasonReturns why the internal Marquardt optimization method stopped.
7MaxIterMaximum number of allowed iterations in main optimisation loop.
8ToleranceDesired tolerance for optimisation minimum.
9StdErrReturns Theta and B coefficients standard error. This is an estimate of the precision of the Theta and B estimates. The covariance matrix is obtained by inverting the observed information matrix evaluated at the maximum likelihood estimates. The standard errors are the square roots of the diagonal elements of this covariance matrix.
10AutoInitEstimatesIf true then B and Theta initial estimates will be calculated. If false then you must specify initial values for B and Theta.

Returns: Int32 - number of iterations needed to converge to solution with Tolerance precision.

Remarks:

Performs logistic or ordinal logistic regression. Suppose y takes values in k ordered categories, and let p_ij be the cumulative probability that y(i) falls in the j'th category or higher. The ordinal logistic regression model is defined as:

logit(p_ij) = theta(j) + A_i'B , i = 1,..,length(Y), j = 1,..,k-1,

where A_i is the i'th row of A . The number of ordinal categories k is taken to be the number of distinct values of int)y. If k is 2 the model is ordinary logistic regression[1].

Examples
Uses Math387, MtxExp, Regress, Optimization;
procedure Example;
var y, b, theta, StdErr: Vector;
A: Matrix;
FMin: double;
StopReason: TOptStopReason;
begin
    y.SetIt(false,[1,1,2,1,3,2,3,2,3,3]);
    A.SetIt(false,10,1,[1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9,
    10]);
    LogisticRegress(y,A,b,theta,StdErr,FMin,StopReason);
    // b = (0.801), theta=(2.779,5.366)
end;

Overload 2: procedure LogisticRegress(const y: TVec; const n: TVec; const b: TVec; const A: TMtx; Offset: Double; const YCalc: TVec; const BStd: TVec; Tolerance: Double);

Logistic regression.

#NameDescription
1yresponse vector containing binomial counts.
2nnumber of trials for each count. Y is assumed to be binomial(p,N).
3Amatrix of covariates, including the constant vector if required.
4Offsetoffset if required.
5bregression parameter estimates.
6YCalcfitted values.
7BStdRegression parameter estimates errors.This is an estimate of the precision of the B estimates.
8ToleranceDefault precision for reweighted LQR.

Result: stored in self (calling object)

Remarks:

Fit logistic regression model.

Examples
Uses MtxExpr, Regress;
procedure Example;
var y,n,B: Vector;
begin
    y.SetIt(false,[2,0,3,1,5,5,6,9,5,9]);
    n.Size(y);
    n.SetVal(10.0);

    LogisticRegress(y,n,B);
end;