>
Data Types | |
RWSearchMethod |
Member Functions | |||
calcMethod() evalFunctionForSelected() fail() |
failMessage() operator=() searchMethod() |
selectedParamIndices() selectedParamValues() setCalcMethod() |
setRegression() setSearchMethod() |
>#include <rw/analytics/gpvalfun.h> #include <rw/analytics/lgmodsel.h> #include <rw/analytics/logregress.h> RWLogisticRegression lr; RWLogRegModelSelector<RWGPValueFunctor>
modelSelector( lr, rwForwardSelection );
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 { double operator()(const RWGenMat<double>& regressionMatrix, const RWMathVec<RWBoolean>& observationVector, const RWMathVec<double>& parameterEstimates); }>
#include <rw/analytics/lgmodsel.h> #include <rw/analytics/logregress.h> #include <rw/analytics/loglevbg.h> #include <rw/analytics/gpvalfun.h> #include <rw/rstream.h> int main() { RWGenMat<double> predData = "5x2 [1 234 2 431 3 333 4 654 5 788]"; RWMathVec<RWBoolean> 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 ); cout << "Searching using forward selection---------------" << endl; cout << "selected parameter indices: " << selector.selectedParamIndices() << endl; cout << "model criterion value: " << selector.evalFunctionForSelected() << endl; cout << "Searching using backward selection--------------" << endl; selector.setSearchMethod( rwBackwardSelection ); cout << "selected parameter indices: " << selector.selectedParamIndices() << endl; cout << "model criterion value: " << selector.evalFunctionForSelected() << endl; return 0; }>
RWLogRegModelSelector();
Default constructor. Behavior undefined.
RWLogRegModelSelector(const RWLogRegModelSelector<F>&);
Copy constructor.
RWLogRegModelSelector(const RWLogisticRegression& reg, RWSearchMethod s);
Constructs a model selector using the search method s.
const RWRegressionCalc<T,S>& calcMethod() const;
Returns the parameter estimate calculation method currently in use by the model selector.
double evalFunctionForSelected() const;
Returns the value of the evaluation function, F, for the selected parameters.
RWBoolean fail() const;
Returns TRUE if the search failed.
RWCString failMessage() const;
Returns an error message if the search fails, that is, if fail() returns true.
RWSearchMethod searchMethod() const;
Returns the search method currently in use by the model selector.
const RWBitVec& selectedParamIndices() const;
Returns the indices of the currently selected parameters.
const RWBitVec& selectedParamIndices(RWSearchMethod s);
Returns the parameters selected by the models selector using the search method s.
const RWMathVec<T>& selectedParamValues() const;
Returns the currently selected parameter estimates.
void setCalcMethod(const RWRegressionCalc<T,S>& c);
Sets the calculation method used to calculate parameter estimates for the models searched.
void setRegression(const RWLogisticRegression&);
Sets the full regression model from which the subset of predictors is selected.
void setSearchMethod(RWSearchMethod s);
Sets the search method used.
RWLogRegModelSelector<F>& operator=(const RWLogRegModelSelector<F>& ms);
Assignment operator.
enum RWSearchMethod {rwForwardSelection, rwBackwardSelection, rwStepwiseSelection, rwExhaustiveSelection}
Designates the search method.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.