MCPcopy Create free account
hub / github.com/apache/madlib / stateToResult

Function stateToResult

src/modules/regress/logistic.cpp:1028–1065  ·  view source on GitHub ↗

* @brief Compute the diagnostic statistics * * This function wraps the common parts of computing the results for both the * CG and the IRLS method. */

Source from the content-addressed store, hash-verified

1026 * CG and the IRLS method.
1027 */
1028AnyType stateToResult(
1029 const Allocator &inAllocator,
1030 const HandleMap<const ColumnVector, TransparentHandle<double> > &inCoef,
1031 const Matrix & hessian,
1032 const double &logLikelihood,
1033 int status,
1034 const uint64_t &numRows) {
1035
1036 SymmetricPositiveDefiniteEigenDecomposition<Matrix> decomposition(
1037 hessian, EigenvaluesOnly, ComputePseudoInverse);
1038
1039 const Matrix &inverse_of_X_transp_AX = decomposition.pseudoInverse();
1040 const ColumnVector &diagonal_of_X_transp_AX = inverse_of_X_transp_AX.diagonal();
1041
1042 MutableNativeColumnVector stdErr(
1043 inAllocator.allocateArray<double>(inCoef.size()));
1044 MutableNativeColumnVector waldZStats(
1045 inAllocator.allocateArray<double>(inCoef.size()));
1046 MutableNativeColumnVector waldPValues(
1047 inAllocator.allocateArray<double>(inCoef.size()));
1048 MutableNativeColumnVector oddsRatios(
1049 inAllocator.allocateArray<double>(inCoef.size()));
1050
1051 for (Index i = 0; i < inCoef.size(); ++i) {
1052 stdErr(i) = std::sqrt(diagonal_of_X_transp_AX(i));
1053 waldZStats(i) = inCoef(i) / stdErr(i);
1054 waldPValues(i) = 2. * prob::cdf( prob::normal(),
1055 -std::abs(waldZStats(i)));
1056 oddsRatios(i) = std::exp( inCoef(i) );
1057 }
1058
1059 // Return all coefficients, standard errors, etc. in a tuple
1060 AnyType tuple;
1061 tuple << inCoef << logLikelihood << stdErr << waldZStats << waldPValues
1062 << oddsRatios << inverse_of_X_transp_AX
1063 << sqrt(decomposition.conditionNo()) << status << numRows;
1064 return tuple;
1065}
1066
1067// ---------------------------------------------------------------------------
1068// Robust Logistic Regression States

Callers 1

runMethod · 0.70

Calls 3

conditionNoMethod · 0.80
cdfFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected