SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWLogRegModelSelector< F > Class Template Reference

For a logistic regression model, selects a subset of predictor variables that accounts for the variation in the regression model's observation variable. More...

#include <rw/analytics/lgmodsel.h>

Inheritance diagram for RWLogRegModelSelector< F >:
RWRegressionModelSelector< double, bool, F >

Public Member Functions

 RWLogRegModelSelector ()
 
 RWLogRegModelSelector (const RWLogRegModelSelector< F > &rhs)
 
 RWLogRegModelSelector (const RWLogisticRegression &reg, RWSearchMethod s)
 
RWLogRegModelSelector< F > & operator= (const RWLogRegModelSelector< F > &rhs)
 
- Public Member Functions inherited from RWRegressionModelSelector< double, bool, F >
 RWRegressionModelSelector ()
 
 RWRegressionModelSelector (const RWRegressionModelSelector< double, bool, F > &rhs)
 
 RWRegressionModelSelector (const RWRegression< double, bool > &reg, RWSearchMethod s)
 
virtual ~RWRegressionModelSelector ()
 
const RWRegressionCalc< double, bool > & calcMethod () const
 
double evalFunctionForSelected () const
 
bool fail () const
 
RWCString failMessage () const
 
RWRegressionModelSelector< double, bool, F > & operator= (const RWRegressionModelSelector< double, bool, F > &rhs)
 
RWSearchMethod searchMethod () const
 
const RWBitVecselectedParamIndices (RWSearchMethod s)
 
const RWBitVecselectedParamIndices () const
 
const RWMathVec< double > & selectedParamValues () const
 
void setCalcMethod (const RWRegressionCalc< double, bool > &c)
 
void setRegression (const RWRegression< double, bool > &r)
 
void setSearchMethod (RWSearchMethod s)
 

Detailed Description

template<class F>
class RWLogRegModelSelector< F >

RWLogRegModelSelector is the class for logistic regression model selection. Provided with a logistic regression model containing a set of candidate predictor variables, the RWLogRegModelSelector class selects a subset of predictor variables that still accounts well for the variation in the regression model's observation variable. The criteria for selecting one predictor subset over another are determined by the template parameter F. Class F is a function object that returns a numerical value whenever it is given a regression matrix, an observation vector, and parameter estimates.

To be used as a template parameter for RWLogRegModelSelector, a class F must implement the following interface:

class F
{
public:
double operator()(const RWGenMat<double>& regressionMatrix,
const RWMathVec<bool>& observationVector,
const RWMathVec<double>& parameterEstimates);
};
Synopsis
#include <rw/analytics/gpvalfun.h>
#include <rw/analytics/lgmodsel.h>
#include <rw/analytics/logregress.h>
modelSelector( lr, rwForwardSelection );
Example
#include <rw/analytics/lgmodsel.h>
#include <rw/analytics/logregress.h>
#include <rw/analytics/loglevbg.h>
#include <rw/analytics/gpvalfun.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;
RWLogisticRegression lr(predData, obsData,
std::cout << "Searching using forward selection---------------"
<< std::endl;
std::cout << "selected parameter indices: "
<< selector.selectedParamIndices() << std::endl;
std::cout << "model criterion value: "
<< selector.evalFunctionForSelected() << std::endl;
std::cout << "Searching using backward selection--------------"
<< std::endl;
selector.setSearchMethod( rwBackwardSelection );
std::cout << "selected parameter indices: "
<< selector.selectedParamIndices() << std::endl;
std::cout << "model criterion value: "
<< selector.evalFunctionForSelected() << std::endl;
return 0;
}

Constructor & Destructor Documentation

template<class F>
RWLogRegModelSelector< F >::RWLogRegModelSelector ( )
inline

Default constructor. Behavior undefined.

template<class F>
RWLogRegModelSelector< F >::RWLogRegModelSelector ( const RWLogRegModelSelector< F > &  rhs)
inline

Copy constructor.

template<class F>
RWLogRegModelSelector< F >::RWLogRegModelSelector ( const RWLogisticRegression reg,
RWSearchMethod  s 
)
inline

Constructs a model selector using the search method s.

Member Function Documentation

template<class F>
RWLogRegModelSelector<F>& RWLogRegModelSelector< F >::operator= ( const RWLogRegModelSelector< F > &  rhs)
inline

Assignment operator.

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