Built matrix of interval logistic costs for held-out means. One indexed.

const_costs_logistic(y, w, min_seg, indices)

Arguments

y

NumericVector, 0/1 values to group in order (should be in interval [0,1]).

w

NumericVector, weights (should be positive).

min_seg

positive integer, minimum segment size (>=1).

indices

IntegerVector, order list of indices to pair.

Value

xcosts NumericMatix, for j>=i xcosts(i,j) is the cost of partition element [i,...,j] (inclusive).

Examples

const_costs_logistic(c(0.1, 0.1, 0.2, 0.2), c(1, 1, 1, 1), 1, 1:4)
#> [,1] [,2] [,3] [,4] #> [1,] 1.797693e+308 -6.501659e-01 -1.216764e+00 -1.721453e+00 #> [2,] -6.501659e-01 1.797693e+308 -9.065784e-01 -1.380651e+00 #> [3,] -1.216764e+00 -9.065784e-01 1.797693e+308 -1.000805e+00 #> [4,] -1.721453e+00 -1.380651e+00 -1.000805e+00 1.797693e+308