Built matrix of interval deviance costs for held-out logistic models. Fits are evaluated in-sample. One indexed.

lin_costs_logistic(x, y, w, min_seg, indices)

Arguments

x

NumericVector, x-coords of values to group.

y

NumericVector, 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, ordered list of indices to pair.

Value

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

Examples


lin_costs_logistic(c(1, 2, 3, 4, 5, 6, 7), c(0, 0, 1, 0, 1, 1, 0), c(1, 1, 1, 1, 1, 1, 1), 3, 1:7)
#>               [,1]          [,2]          [,3]          [,4]          [,5]
#> [1,] 1.797693e+308 1.797693e+308 1.797693e+308  4.223965e+00  4.843934e+00
#> [2,] 1.797693e+308 1.797693e+308 1.797693e+308 1.797693e+308  5.343718e+00
#> [3,] 1.797693e+308 1.797693e+308 1.797693e+308 1.797693e+308 1.797693e+308
#> [4,]  4.223965e+00 1.797693e+308 1.797693e+308 1.797693e+308 1.797693e+308
#> [5,]  4.843934e+00  5.343718e+00 1.797693e+308 1.797693e+308 1.797693e+308
#> [6,]  4.955974e+00  5.798465e+00  5.245330e+00 1.797693e+308 1.797693e+308
#> [7,]  8.961938e+00  8.280076e+00  7.094090e+00  5.545177e+00 1.797693e+308
#>               [,6]          [,7]
#> [1,]  4.955974e+00  8.961938e+00
#> [2,]  5.798465e+00  8.280076e+00
#> [3,]  5.245330e+00  7.094090e+00
#> [4,] 1.797693e+308  5.545177e+00
#> [5,] 1.797693e+308 1.797693e+308
#> [6,] 1.797693e+308 1.797693e+308
#> [7,] 1.797693e+308 1.797693e+308