SourcePro® API Reference Guide

 
List of all members | Public Member Functions

Calculates the G statistic for a logistic model in comparison to the intercept-only model. More...

#include <rw/analytics/gpvalfun.h>

Inherits RWGStatisticFunctor.

Public Member Functions

 RWGPValueFunctor ()
 
virtual double operator() (const RWGenMat< double > &predictorData, const RWMathVec< bool > &obsData, const RWMathVec< double > &calc) const
 

Detailed Description

Class RWGPValueFunctor calculates the G statistic for a logistic model in comparison to the intercept only model. This value has approximately a chi-squared distribution with p degrees of freedom, where p is the number of predictor variables. The P-value of the G statistic is returned.

This class may be used as the template parameter for the class RWLogRegModelSelector.

Synopsis
#include <rw/analytics/gpvalfun.h>
RWGPValueFunctor GstatPValue;
Example
#include <rw/analytics/lgmodsel.h>
#include <rw/analytics/logregress.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]";
obsData[0] = obsData[3] = obsData[4] = true;
obsData[1] = obsData[2] = false;
RWLogisticRegression lr(predData, obsData);
cout << "Searching using forward selection---------------" <<
endl;
cout << "selected parameter indices: " <<
selector.selectedParamIndices() << endl;
cout << "model criterion value: " <<
selector.evalFunctionForSelected() << endl;
return 0;
}

Constructor & Destructor Documentation

RWGPValueFunctor::RWGPValueFunctor ( )
inline

Constructs an evaluation function object.

Member Function Documentation

virtual double RWGPValueFunctor::operator() ( const RWGenMat< double > &  predictorData,
const RWMathVec< bool > &  obsData,
const RWMathVec< double > &  calc 
) const
virtual

Given regression data, computes the G statistic by comparing the p predictor variables in the model with the intercept only model. It returns the P-value of this statistic according to a chi-squared distribution with p degrees of freedom.

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