16 inline void remove_incomplete(std::vector<double>& x,
17 std::vector<double>& y,
18 std::vector<double>& w)
21 size_t last = x.size() - 1;
22 for (
size_t i = 0; i < last + 1; i++) {
23 bool row_has_nan = (std::isnan(x[i]) | std::isnan(y[i]));
25 row_has_nan = (row_has_nan | std::isnan(w[i]));
28 std::swap(w[i], w[last]);
29 std::swap(x[i], x[last]);
30 std::swap(y[i--], y[last--]);
40 inline bool any_nan(
const std::vector<double>& x) {
41 for (
size_t i = 0; (i < x.size()); i++) {
49 inline std::string preproc(std::vector<double>& x,
50 std::vector<double>& y,
51 std::vector<double>& weights,
55 size_t min_nobs = (method ==
"hoeffding") ? 5 : 2;
57 utils::remove_incomplete(x, y, weights);
58 if (x.size() < min_nobs)
61 std::stringstream msg;
62 if (utils::any_nan(x) | utils::any_nan(y) | utils::any_nan(weights)) {
63 msg <<
"there are missing values in the data; " <<
64 "try remove_missing = TRUE";
65 }
else if (x.size() < min_nobs) {
66 msg <<
"need at least " << min_nobs <<
"observations.";
68 if (!msg.str().empty())
69 throw std::runtime_error(msg.str());
Weighted dependence measures.
Definition: bbeta.hpp:11