Overload List
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.
| # | Name | Description |
|---|---|---|
| 1 | y | Response levels. |
| 2 | A | Matrix of independent variables. It is assumed to have full column rank. |
| 3 | B | Set it to define initial estimates for B. After the call to LogisticRegress returns regression parameter estimates for B. |
| 4 | Theta | Set it to define initial estimates for Theta. After the call to LogisticRegress returns regression parameter estimates for Theta. |
| 5 | FMin | Returns logistic log-likehood function, evaluated at minimum. |
| 6 | StopReason | Returns why the internal Marquardt optimization method stopped. |
| 7 | MaxIter | Maximum number of allowed iterations in main optimisation loop. |
| 8 | Tolerance | Desired tolerance for optimisation minimum. |
| 9 | 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. |
| 10 | AutoInitEstimates | If 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.
| # | Name | Description |
|---|---|---|
| 1 | y | response vector containing binomial counts. |
| 2 | n | number of trials for each count. Y is assumed to be binomial(p,N). |
| 3 | A | matrix of covariates, including the constant vector if required. |
| 4 | Offset | offset if required. |
| 5 | b | regression parameter estimates. |
| 6 | YCalc | fitted values. |
| 7 | BStd | Regression parameter estimates errors.This is an estimate of the precision of the B estimates. |
| 8 | Tolerance | Default 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;