rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWLogRegModelSelector< F > Class Template Reference
[Model Selection]

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 >

List of all members.

Public Member Functions

 RWLogRegModelSelector ()
 RWLogRegModelSelector (const RWLogRegModelSelector< F > &rhs)
 RWLogRegModelSelector (const RWLogisticRegression &reg, RWSearchMethod s)
RWLogRegModelSelector< F > & operator= (const RWLogRegModelSelector< F > &rhs)

Detailed Description

template<class F>
class RWLogRegModelSelector< F >

RWLogRegModelSelector<F> 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>

 RWLogisticRegression lr;
 RWLogRegModelSelector<RWGPValueFunctor>
                 modelSelector( lr, rwForwardSelection );

Examples

 #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]";
   RWMathVec<bool> obsData(5, rwUninitialized );
   obsData[0] = obsData[3] = obsData[4] = true;
   obsData[1] = obsData[2] = false;

   RWLogisticRegression lr(predData, obsData,
                           RWLogisticLevenbergMarquardt());
   RWLogRegModelSelector<RWGPValueFunctor> selector( lr,
                          rwForwardSelection );

   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.

 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.