wdm Namespace Reference

Weighted dependence measures. More...

Classes

class  Indep_test
 

Functions

double wdm (std::vector< double > x, std::vector< double > y, std::string method, std::vector< double > weights=std::vector< double >(), bool remove_missing=true, std::vector< int > seeds=std::vector< int >())
 
double wdm (const Eigen::VectorXd &x, const Eigen::VectorXd &y, std::string method, Eigen::VectorXd weights=Eigen::VectorXd(), bool remove_missing=true, std::vector< int > seeds=std::vector< int >())
 
Eigen::MatrixXd wdm (const Eigen::MatrixXd &x, std::string method, Eigen::VectorXd weights=Eigen::VectorXd(), bool remove_missing=true, std::vector< int > seeds=std::vector< int >())
 

Detailed Description

Weighted dependence measures.

Function Documentation

◆ wdm() [1/3]

Eigen::MatrixXd wdm::wdm ( const Eigen::MatrixXd &  x,
std::string  method,
Eigen::VectorXd  weights = Eigen::VectorXd(),
bool  remove_missing = true,
std::vector< int >  seeds = std::vector<int>() 
)
inline

Calculates all pairwise dependence measures between matrix columns.

Parameters
xmatrix with observations in rows and variables in columns.
methodany method name accepted by the vector overload.
weightsoptional case weights for the rows.
remove_missingwhether each pair should remove rows containing a NaN.
seedsoptional seeds for random Chatterjee predictor-tie breaking.
Returns
A matrix of pairwise dependence measures. Chatterjee matrices are generally asymmetric; all other supported measures produce symmetric matrices.
Exceptions
std::runtime_errorif x has exactly one column or a pairwise call rejects its inputs.

◆ wdm() [2/3]

double wdm::wdm ( const Eigen::VectorXd &  x,
const Eigen::VectorXd &  y,
std::string  method,
Eigen::VectorXd  weights = Eigen::VectorXd(),
bool  remove_missing = true,
std::vector< int >  seeds = std::vector<int>() 
)
inline

Calculates a dependence measure for two Eigen vectors.

Parameters
x,yinput vectors of equal length.
methodany method name accepted by the std::vector overload.
weightsoptional case weights subject to the same validation as the std::vector overload.
remove_missingwhether to remove rows containing a NaN.
seedsoptional seeds for random Chatterjee predictor-tie breaking.
Returns
The result of the corresponding std::vector overload.
Exceptions
std::runtime_errorunder the same conditions as that overload.

◆ wdm() [3/3]

double wdm::wdm ( std::vector< double >  x,
std::vector< double >  y,
std::string  method,
std::vector< double >  weights = std::vector<double>(),
bool  remove_missing = true,
std::vector< int >  seeds = std::vector<int>() 
)
inline

Calculates a weighted or unweighted dependence measure.

Parameters
x,yinput vectors of equal length. For Chatterjee's xi, x is the predictor and y is the response.
methodthe dependence measure; see details for possible values.
weightsoptional case weights. Nonempty weights must match the input length, be finite and nonnegative, and have a positive sum. Their scale does not affect the result, and zero-weight rows are ignored.
remove_missingif true, rows containing a NaN are removed; otherwise a NaN raises an exception.
seedsoptional seeds for random Chatterjee predictor-tie breaking.

Available methods:

  • "pearson", "prho", "cor": Pearson correlation
  • "spearman", "srho", "rho": Spearman's \( \rho \)
  • "kendall", "ktau", "tau": Kendall's \( \tau \)
  • "blomqvist", "bbeta", "beta": Blomqvist's \( \beta \)
  • "hoeffding", "hoeffd", "d": Hoeffding's \( D \)
  • "chatterjee", "cxi", "xi": Chatterjee's \( \xi \)
Note
Chatterjee's xi is asymmetric. Predictor ties are broken without consulting the response; use seeds for a reproducible ordering.
Returns
The requested estimate, or NaN if missing-value removal leaves fewer than two observations (five for Hoeffding's D).
Exceptions
std::runtime_errorfor size mismatches, invalid weights, unknown methods, disallowed missing or insufficient input, or an undefined Chatterjee estimate with a constant response.