Regress.LogisticRegress Method

Overload List

#SignatureDescription
1Int32 LogisticRegress(TVec y, TMtx A, TVec B, TVec Theta, TVec StdErr, ref Double FMin, ref TOptStopReason StopReason, Int32 MaxIter, Double Tolerance, Boolean AutoInitEstimates)Ordinal logistic regression.
2void LogisticRegress(TVec y, TVec n, TVec b, TMtx A, Double Offset, TVec YCalc, TVec BStd, Double Tolerance)Logistic regression.

Overload 1: Int32 LogisticRegress(TVec y, TMtx A, TVec B, TVec Theta, TVec StdErr, ref Double FMin, ref TOptStopReason StopReason, Int32 MaxIter, Double Tolerance, Boolean AutoInitEstimates)

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
using Dew.Math;
using Dew.Stats;
using Dew.Stats.Units;
namespace Dew.Examples
{
    private void Example()
    {
        Vector y = new Vector(0);
        Vector b = new Vector(0);
        Vector theta = new Vector(0);
        Vector se = new Vector(0);

        Matrix A = new Matrix(0,0,false);
        double min;
        TOptStopReason stopreason;
        y.SetIt(false,new double[] {1,1,2,1,3,2,3,2,3,3});
        A.SetIt(false,10,1,new double[] {1,2,3,4,5,6,7,8,9,10});
        Regression.LogisticRegress(y,A,b,theta,se,out min, out stopreason,
            100,1.0e-8,true);
        // b = (0.801), theta=(2.779,5.366)
    }
}

Overload 2: void LogisticRegress(TVec y, TVec n, TVec b, TMtx A, Double Offset, TVec YCalc, TVec BStd, Double Tolerance)

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
using Dew.Math;
using Dew.Stats;
using Dew.Math.Units;
using Dew.Stats.Units;
namespace Dew.Examples
{
    private void Example()
    {
        Vector y = new Vector(0);
        Vector n = new Vector(0);
        Vector B = new Vector(0);
        y.SetIt(false, new double[] { 2, 0, 3, 1, 5, 5, 6, 9, 5, 9 });
        n.Size(y);
        n.SetVal(10.0);

        Regress.LogisticRegress(y, n, B, null,0,null,null, Math387.EPS);
    }
}