SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWLogisticRegression Class Reference

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 >

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)
 
RWLogisticRegressionoperator= (const RWLogisticRegression &rhs)
 
RWGenMat< double > paramDispersionMatrix () const
 
RWTValVector< RWLogisticRegressionParamparameterEstimates () const
 
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
 
- Public Member Functions inherited from RWRegression< double, bool >
void addInterceptParameter ()
 
void addObservation (const RWMathVec< double > &, bool)
 
void addObservations (const RWGenMat< double > &, const RWMathVec< bool > &)
 
void addPredictor (const RWMathVec< double > &)
 
void addPredictors (const RWGenMat< double > &)
 
const RWRegressionCalc< double, bool > & calcMethod () const
 
bool fail () const
 
bool hasInterceptParameter () const
 
size_t numObservations () const
 
size_t numParameters () const
 
size_t numPredictors () const
 
const RWMathVec< bool > observationVector () const
 
RWMathVec< bool > observationVector ()
 
const RWMathVec< double > parameters () const
 
const RWGenMat< double > predictorMatrix () const
 
RWGenMat< double > predictorMatrix ()
 
void reCalculateParameters ()
 
const RWGenMat< double > regressionMatrix () const
 
void removeInterceptParameter ()
 
void removeObservations (size_t startingIndex, size_t numToRemove)
 
void removePredictors (size_t startingIndex, size_t numToRemove)
 
void setCalcMethod (const RWRegressionCalc< double, bool > &c, bool recalculate=true)
 
void setRegressionData (const RWGenMat< double > &r, const RWMathVec< bool > &o, InterceptOption interceptOpt=addIntercept)
 

Additional Inherited Members

- Public Types inherited from RWRegression< double, bool >
enum  InterceptOption
 

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>
Example
#include <rw/analytics/logregress.h>
#include <iostream>
int main()
{
RWGenMat<double> predData = "5x2
[1 234 2 431 3 333 4 654 5 788]";
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

RWLogisticRegression& RWLogisticRegression::operator= ( const RWLogisticRegression rhs)
inline

Assigns rhs to self.

RWGenMat<double> RWLogisticRegression::paramDispersionMatrix ( ) const

Returns the parameter variance-covariance matrix.

RWTValVector<RWLogisticRegressionParam> RWLogisticRegression::parameterEstimates ( ) const

Returns the list of estimated parameters.

RWMathVec<double> RWLogisticRegression::predictedProbSuccess ( ) const

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

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

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

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::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) \).

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.