rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWLogisticRegression Class Reference
[Regression]

Performs basic logistic regression on a matrix of predictor variables and a vector of observations. More...

#include <rw/analytics/logregress.h>

Inheritance diagram for RWLogisticRegression:
RWRegression< double, bool >

List of all members.

Public Member Functions

 RWLogisticRegression ()
 RWLogisticRegression (const RWLogisticRegression &rhs)
 RWLogisticRegression (const RWGenMat< double > predictorData, const RWMathVec< bool > obsVector, InterceptOption interceptOpt=addIntercept)
 RWLogisticRegression (const RWGenMat< double > predictorData, const RWMathVec< bool > obsVector, const RWRegressionCalc< double, bool > &calcObject, InterceptOption interceptOpt=addIntercept)
RWMathVec< double > predictedProbSuccess () const
RWMathVec< double > predictedProbSuccess (const RWGenMat< double > &m) const
double predictedProbSuccess (const RWMathVec< double > &v) const
RWMathVec< double > residuals () const
RWMathVec< double > variance () const
RWGenMat< double > paramDispersionMatrix () const
RWTValVector
< RWLogisticRegressionParam
parameterEstimates () const

Detailed Description

RWLogisticRegression is the class for performing basic logistic regression, described in the Business Analysis Module User's Guide. RWLogisticRegression receives data input in the form of a matrix of values for the predictor variables, and a vector of values for the observations. In addition, an intercept option must be specified. The interception option is an enumeration type defined in the RWRegression class. It can have three possible values:

For a more detailed discussion of the intercept option, see the Business Analysis Module User's Guide.

Synopsis

 #include <rw/analytics/logregress.h>
 RWMathVec<bool> o;
 RWGenMat<double> p;
 RWLogisticRegression lr(p, o);

Examples

 #include <rw/analytics/logregress.h>
 #include <iostream>

 int main()
 {
   RWGenMat<double> predData = "5x2
                               [1 234 2 431 3 333 4 654 5 788]";
   RWMathVec<bool> obsData(5, rwUninitialized );
   obsData[0] = obsData[3] = obsData[4] = true;
   obsData[1] = obsData[2] = false;

   // Create a logistic regression object.
   RWLogisticRegression model(predData, obsData);

   if ( model.fail() )
   {
     std::cout << "Parameter calculation failed" << std::endl;
   }
   else
   {
     // Print parameters from the full model.
     std::cout << "Model parameters: " << model.parameters()
               << std::endl;
   }

   return 0;
 }

Constructor & Destructor Documentation

RWLogisticRegression::RWLogisticRegression (  )  [inline]

Constructs an empty logistic regression object. Behavior is undefined.

RWLogisticRegression::RWLogisticRegression ( const RWLogisticRegression rhs  )  [inline]

Constructs a copy of rhs.

RWLogisticRegression::RWLogisticRegression ( const RWGenMat< double >  predictorData,
const RWMathVec< bool >  obsVector,
InterceptOption  interceptOpt = addIntercept 
) [inline]

Constructs a regression object with predictor matrix predictorData and observation vector obsVector. The interceptOpt parameter indicates whether or not the model contains an intercept parameter. The default parameter calculation method is iterative least squares.

RWLogisticRegression::RWLogisticRegression ( const RWGenMat< double >  predictorData,
const RWMathVec< bool >  obsVector,
const RWRegressionCalc< double, bool > &  calcObject,
InterceptOption  interceptOpt = addIntercept 
) [inline]

Constructs a regression object with predictor matrix predictorData and observation vector obsVector. The interceptOpt parameter indicates whether or not the model contains an intercept parameter. Parameter calculation is done using the method calcObject. Methods currently available include iterative least squares and an algorithm based on the Levenberg-Marquardt approach.


Member Function Documentation

RWGenMat<double> RWLogisticRegression::paramDispersionMatrix (  )  const

Returns the parameter variance-covariance matrix.

RWTValVector<RWLogisticRegressionParam> RWLogisticRegression::parameterEstimates (  )  const

Returns the list of estimated parameters.

double RWLogisticRegression::predictedProbSuccess ( const RWMathVec< double > &  v  )  const

Returns the success probabilities predicted for the predictor data used to construct the model.

RWMathVec<double> RWLogisticRegression::predictedProbSuccess ( const RWGenMat< double > &  m  )  const

Returns the model's predicted success probabilities for the input predictor data.

RWMathVec<double> RWLogisticRegression::predictedProbSuccess (  )  const

Returns the model's predicted success probabilities for the input predictor data.

RWMathVec<double> RWLogisticRegression::residuals (  )  const

Returns the vector of differences between the probabilities of success predicted by the model and those predicted by the observed value.

RWMathVec<double> RWLogisticRegression::variance (  )  const [inline]

Returns the variance estimate for each observation. If $ p_i $ is the predicted probability of success for the ith observation, then $ var(i) = p_i * (1-p_i) $.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.