bpp-core3  3.0.0
bpp::CorrespondenceAnalysis Class Reference

This class allows to perform a correspondence analysis. More...

#include <Bpp/Numeric/Stat/Mva/CorrespondenceAnalysis.h>

+ Inheritance diagram for bpp::CorrespondenceAnalysis:
+ Collaboration diagram for bpp::CorrespondenceAnalysis:

Public Member Functions

 CorrespondenceAnalysis (const Matrix< double > &data, unsigned int nbAxes, double tol=0.0000001, bool verbose=true)
 Build a new CorrespondenceAnalysis object. More...
 
virtual ~CorrespondenceAnalysis ()
 
CorrespondenceAnalysisclone () const
 Create a copy of this object and send a pointer to it. More...
 
double getSumOfAllValues () const
 
void setData (const Matrix< double > &matrix, const std::vector< double > &rowWeights, const std::vector< double > &colWeights, unsigned int nbAxes, double tol=0.0000001, bool verbose=true)
 Set the data and perform computations. More...
 
std::vector< double > computeVariancePercentagePerAxis ()
 
size_t getNbOfKeptAxes () const
 
const std::vector< double > getRowWeights () const
 
const std::vector< double > getColumnWeights () const
 
const std::vector< double > & getEigenValues () const
 
const RowMatrix< double > & getRowCoordinates () const
 
const RowMatrix< double > & getColCoordinates () const
 
const RowMatrix< double > & getPrincipalAxes () const
 
const RowMatrix< double > & getPrincipalComponents () const
 

Private Member Functions

void check_ (const Matrix< double > &matrix, const std::vector< double > &rowWeights, const std::vector< double > &colWeights, unsigned int nbAxes)
 
void compute_ (const Matrix< double > &matrix, double tol, bool verbose)
 

Private Attributes

double n_
 
std::vector< double > rowWeights_
 
std::vector< double > colWeights_
 
size_t nbAxes_
 
std::vector< double > eigenValues_
 
RowMatrix< double > eigenVectors_
 
RowMatrix< double > rowCoord_
 
RowMatrix< double > colCoord_
 
RowMatrix< double > ppalAxes_
 
RowMatrix< double > ppalComponents_
 

Detailed Description

This class allows to perform a correspondence analysis.

All values in the input table have to be non-negative. The DualityDiagram class, core class of a multivariate analysis, is called internally.

The code of this class is deeply inspired from the R code of the dudi.coa function available in the ade4 package.

Definition at line 59 of file CorrespondenceAnalysis.h.

Constructor & Destructor Documentation

◆ CorrespondenceAnalysis()

CorrespondenceAnalysis::CorrespondenceAnalysis ( const Matrix< double > &  data,
unsigned int  nbAxes,
double  tol = 0.0000001,
bool  verbose = true 
)

Build a new CorrespondenceAnalysis object.

Parameters
dataThe input data (a RowMatrix) to analyse.
nbAxesThe number of kept axes during the analysis.
tolTolerance threshold for null eigenvalues (a value less than tol times the first one is considered as null)
verboseShould warnings be dispayed.
Exceptions
Exceptionif an error occured.

Definition at line 50 of file CorrespondenceAnalysis.cpp.

References bpp::Matrix< Scalar >::getNumberOfColumns(), bpp::Matrix< Scalar >::getNumberOfRows(), bpp::MatrixTools::hadamardMult(), n_, bpp::MatrixTools::scale(), and bpp::DualityDiagram::setData().

Referenced by clone().

◆ ~CorrespondenceAnalysis()

virtual bpp::CorrespondenceAnalysis::~CorrespondenceAnalysis ( )
inlinevirtual

Definition at line 81 of file CorrespondenceAnalysis.h.

Member Function Documentation

◆ check_()

void DualityDiagram::check_ ( const Matrix< double > &  matrix,
const std::vector< double > &  rowWeights,
const std::vector< double > &  colWeights,
unsigned int  nbAxes 
)
privateinherited

◆ clone()

CorrespondenceAnalysis* bpp::CorrespondenceAnalysis::clone ( ) const
inlinevirtual

Create a copy of this object and send a pointer to it.

Returns
A pointer toward the copy object.

Implements bpp::Clonable.

Definition at line 83 of file CorrespondenceAnalysis.h.

References CorrespondenceAnalysis().

◆ compute_()

◆ computeVariancePercentagePerAxis()

std::vector<double> bpp::DualityDiagram::computeVariancePercentagePerAxis ( )
inherited

◆ getColCoordinates()

const RowMatrix<double>& bpp::DualityDiagram::getColCoordinates ( ) const
inlineinherited

Definition at line 146 of file DualityDiagram.h.

References bpp::DualityDiagram::colCoord_.

◆ getColumnWeights()

const std::vector<double> bpp::DualityDiagram::getColumnWeights ( ) const
inlineinherited

Definition at line 143 of file DualityDiagram.h.

References bpp::DualityDiagram::colWeights_.

◆ getEigenValues()

const std::vector<double>& bpp::DualityDiagram::getEigenValues ( ) const
inlineinherited

Definition at line 144 of file DualityDiagram.h.

References bpp::DualityDiagram::eigenValues_.

◆ getNbOfKeptAxes()

size_t bpp::DualityDiagram::getNbOfKeptAxes ( ) const
inlineinherited

Definition at line 141 of file DualityDiagram.h.

References bpp::DualityDiagram::nbAxes_.

◆ getPrincipalAxes()

const RowMatrix<double>& bpp::DualityDiagram::getPrincipalAxes ( ) const
inlineinherited

Definition at line 147 of file DualityDiagram.h.

References bpp::DualityDiagram::ppalAxes_.

◆ getPrincipalComponents()

const RowMatrix<double>& bpp::DualityDiagram::getPrincipalComponents ( ) const
inlineinherited

Definition at line 148 of file DualityDiagram.h.

References bpp::DualityDiagram::ppalComponents_.

◆ getRowCoordinates()

const RowMatrix<double>& bpp::DualityDiagram::getRowCoordinates ( ) const
inlineinherited

Definition at line 145 of file DualityDiagram.h.

References bpp::DualityDiagram::rowCoord_.

◆ getRowWeights()

const std::vector<double> bpp::DualityDiagram::getRowWeights ( ) const
inlineinherited

Definition at line 142 of file DualityDiagram.h.

References bpp::DualityDiagram::rowWeights_.

◆ getSumOfAllValues()

double bpp::CorrespondenceAnalysis::getSumOfAllValues ( ) const
inline

Definition at line 86 of file CorrespondenceAnalysis.h.

References n_.

◆ setData()

void DualityDiagram::setData ( const Matrix< double > &  matrix,
const std::vector< double > &  rowWeights,
const std::vector< double > &  colWeights,
unsigned int  nbAxes,
double  tol = 0.0000001,
bool  verbose = true 
)
inherited

Set the data and perform computations.

Parameters
matrixThe input data to analyse.
rowWeightsA vector of values specifying the weights of rows.
colWeightsA vector of values specifying the weights of columns.
nbAxesThe number of kept axes during the analysis.
tolTolerance threshold for null eigenvalues (a value less than tol times the first one is considered as null)
verboseShould warnings be dispayed.
Exceptions
Exceptionif an error occured.

Definition at line 101 of file DualityDiagram.cpp.

References bpp::DualityDiagram::check_(), bpp::DualityDiagram::colWeights_, bpp::DualityDiagram::compute_(), bpp::DualityDiagram::nbAxes_, and bpp::DualityDiagram::rowWeights_.

Referenced by CorrespondenceAnalysis(), and bpp::PrincipalComponentAnalysis::PrincipalComponentAnalysis().

Member Data Documentation

◆ colCoord_

RowMatrix<double> bpp::DualityDiagram::colCoord_
privateinherited

◆ colWeights_

std::vector<double> bpp::DualityDiagram::colWeights_
privateinherited

◆ eigenValues_

std::vector<double> bpp::DualityDiagram::eigenValues_
privateinherited

◆ eigenVectors_

RowMatrix<double> bpp::DualityDiagram::eigenVectors_
privateinherited

Definition at line 66 of file DualityDiagram.h.

Referenced by bpp::DualityDiagram::compute_().

◆ n_

double bpp::CorrespondenceAnalysis::n_
private

Definition at line 63 of file CorrespondenceAnalysis.h.

Referenced by CorrespondenceAnalysis(), and getSumOfAllValues().

◆ nbAxes_

size_t bpp::DualityDiagram::nbAxes_
privateinherited

◆ ppalAxes_

RowMatrix<double> bpp::DualityDiagram::ppalAxes_
privateinherited

◆ ppalComponents_

RowMatrix<double> bpp::DualityDiagram::ppalComponents_
privateinherited

◆ rowCoord_

RowMatrix<double> bpp::DualityDiagram::rowCoord_
privateinherited

◆ rowWeights_

std::vector<double> bpp::DualityDiagram::rowWeights_
privateinherited

The documentation for this class was generated from the following files: