wdm::Indep_test Class Reference

#include <wdm.hpp>

Public Member Functions

 Indep_test (std::vector< double > x, std::vector< double > y, std::string method, std::vector< double > weights=std::vector< double >(), bool remove_missing=true, std::string alternative="two-sided", std::vector< int > seeds=std::vector< int >(), bool y_continuous=true)
 
std::string method () const
 Returns the requested method name.
 
std::string alternative () const
 Returns the requested alternative hypothesis.
 
double n_eff () const
 Returns Kish's effective sample size after missing-value removal.
 
double estimate () const
 Returns the estimated dependence measure.
 
double statistic () const
 Returns the method-specific transformed test statistic.
 
double p_value () const
 Returns the asymptotic p-value.
 

Detailed Description

Asymptotic independence test based on a dependence measure.

The test stores the estimate, transformed test statistic, effective sample size, and p-value. Weighted transformations use Kish's effective sample size. The approximation must have enough effective observations for the selected method.

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 \)

Hoeffding's D supports only the two-sided alternative. Other methods support "two-sided", "less", and "greater".

Note
Weighted analytic inference for Chatterjee's xi assumes that the weights are fixed or depend only on x, the normalized weights are diffuse, and y is continuous. The weighted estimate remains available when y is tied, but analytic inference with unequal weights does not. For a continuous response, estimate() reports the general denominator-corrected coefficient while statistic() standardizes the analytically covered approximation \(1 - 3 A\).

Constructor & Destructor Documentation

◆ Indep_test()

wdm::Indep_test::Indep_test ( std::vector< double >  x,
std::vector< double >  y,
std::string  method,
std::vector< double >  weights = std::vector<double>(),
bool  remove_missing = true,
std::string  alternative = "two-sided",
std::vector< int >  seeds = std::vector<int>(),
bool  y_continuous = true 
)
inline

Constructs and evaluates an independence test.

Parameters
x,yinput vectors of equal length.
methodthe dependence measure; see class details for possible values.
weightsoptional finite, nonnegative case weights with positive total weight.
remove_missingif true, rows containing a NaN are removed; otherwise a NaN raises an exception.
alternativeindicates the alternative hypothesis and must be one of "two-sided", "greater" or "less"; "greater" corresponds to positive association, "less" to negative association. For Hoeffding's \( D \), only "two-sided" is allowed. The natural one-sided alternative for Chatterjee's xi is "greater".
seedsoptional seeds for random Chatterjee predictor-tie breaking.
y_continuouswhether the Chatterjee response distribution is known to be continuous. Set this to false for a discrete response even if the sample has no observed response ties. Observed ties always override this value.
Exceptions
std::runtime_errorfor invalid inputs, method or alternative names, unsupported Hoeffding alternatives, or unavailable weighted Chatterjee inference for a discrete or tied response.

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