You are here: Symbol Reference > Regress Namespace > Functions > Regress.LogisticRegress Function
Stats Master VCL
ContentsIndex
PreviousUpNext
Regress.LogisticRegress Function

Ordinal logistic regression.

Pascal
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 = 100; Tolerance: double = SQRTEPS; AutoInitEstimates: boolean = true): integer; overload;
Parameters 
Description 
Response levels. 
Matrix of independent variables. It is assumed to have full column rank. 
Set it to define initial estimates for B. After the call to LogisticRegress returns regression parameter estimates for B. 
Theta 
Set it to define initial estimates for Theta. After the call to LogisticRegress returns regression parameter estimates for Theta. 
StdErr 
Returns 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. 
FMin 
Returns logistic log-likehood function, evaluated at minimum. 
StopReason 
Returns why the internal Marquardt optimization method stopped. 
MaxIter 
Maximum number of allowed iterations in main optimisation loop. 
Tolerance 
Desired tolerance for optimisation minimum. 
AutoInitEstimates 
If true then B and Theta initial estimates will be calculated. If false then you must specify initial values for B and Theta. 

number of iterations needed to converge to solution with Tolerance precision.

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

The following example performs ordinal logistic regression. There are three levels of response and two intercepts in the output to distinguish the three levels.

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;
#include "MtxExpr.hpp"
#include "Regress.hpp"
#include "Math387.hpp"
void __fastcall Example()
{
  sMatrix A;
  sVector y,b,theta,se;
  double min;
  TOptStopReason stopreason;

  y.SetIt(false,OPENARRAY(double,(1,1,2,1,3,2,3,2,3,3)));
  A.SetIt(10,1,false,OPENARRAY(double,(1,2,3,4,5,6,7,8,9,10)));
  LogisticRegress(y,A,b,theta,se,min,stopreason);
  // b = (0.801), theta=(2.779,5.366)
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!