22 arma::mat
pava(arma::vec y,
25 unsigned n = y.n_elem;
29 throw std::range_error(
"Wrong length of predictor variable 'x'");
33 for (
unsigned i=0; i < n; i++) w[i]=1;
36 throw std::range_error(
"Wrong length of weights variable 'weights'");
38 std::vector<unsigned> poolEnd(n);
40 for (
unsigned i=0; i < n; i++) poolEnd[i] = i;
47 unsigned nviolators = 0;
49 unsigned pos = i+nviolators;
50 poolEnd[i] = poolEnd[pos];
51 poolEnd[i+1] = poolEnd[pos+1];
57 y[i2] = (w[i1]*y[i1]+w[i2]*y[i2])/w0;
59 poolEnd[i] = poolEnd[i+1];
70 for (
unsigned i=0; i < nb; i++) {
71 res(i, 0) = y[poolEnd[i]];
74 for (
unsigned i=0; i < (nb-1); i++) {
75 res(i+1, 1) = poolEnd[i]+1;
Various utility functions and constants.
arma::mat pava(arma::vec y, const arma::vec &x=arma::vec(), arma::vec w=arma::vec())
Weighted Pooled Adjacent Violator Algorithm.