Get an estimate of the policy \(\pi_B(X_i)\) at a spend level B. \(\pi_B(X_i)\) is a K-dimensional vector where the k-th element is 1 if assigning the k-th arm to unit i is optimal at a given spend B, and 0 otherwise (with all entries 0 if the control arm is assigned). Depending on the value of B, \(\pi_B(X_j)\) might be fractional for at most one unit j. There are two such cases - the first one is when there is not sufficient budget left to assign j an initial arm. The second is if there is not sufficient budget to upgrade unit j from arm k to k'. In these cases \(\pi_B(X_j)\) takes on one, or two fractional values, respectively, representing an assignment probability of a given arm.

# S3 method for maq
predict(object, spend, type = c("matrix", "vector"), ...)

Arguments

object

A maq object.

spend

The spend level B.

type

If "matrix" (Default), then return a matrix where the i-th entry equals \(\pi_B(X_i)\) as described above. If "vector", then \(\pi_B(X_i)\) is instead encoded taking values in the set {0, 1, ..., K}. If the allocation is fractional at the given B, this option returns the policy corresponding to the previous/lower value of the spend path, at which point the policy is integer-valued, but incurs a cost less than B in expectation.

...

Additional arguments (currently ignored).

Value

A matrix with row i equal to \(\pi_B(X_i)\). If type = "vector" then an n-length vector with elements equal to the arm (from 0 to K) that is assigned at the given spend B (note: if the treatment allocation contains a fractional entry at the given B, then the returned vector is the policy at the nearest spend B' in the solution path where the allocation is integer-valued but incurs a cost B' < B).

Examples

# \donttest{ # Generate some toy data and fit a solution path. n <- 10 K <- 4 reward <- matrix(rnorm(n * K), n, K) cost <- matrix(runif(n * K), n, K) DR.scores <- reward + rnorm(n) path <- maq(reward, cost, DR.scores) # Get the treatment allocation matrix pi.mat <- predict(path, 0.1) pi.mat
#> [,1] [,2] [,3] [,4] #> [1,] 0 1 0 0.000000 #> [2,] 0 0 0 0.000000 #> [3,] 0 0 0 0.922959 #> [4,] 0 0 0 0.000000 #> [5,] 0 0 0 0.000000 #> [6,] 0 0 0 1.000000 #> [7,] 0 0 0 0.000000 #> [8,] 0 0 0 0.000000 #> [9,] 0 0 0 0.000000 #> [10,] 0 0 0 0.000000
# pi.mat might have fractional entries for a single unit but satisfies # the budget in expectation exactly. sum(cost * pi.mat) / n
#> [1] 0.1
# Get the treatment allocation instead encoded in the set {0, 1, ..., K}. pi.vec <- predict(path, 0.1, type = "vector") pi.vec
#> [1] 2 0 0 0 0 4 0 0 0 0
# If a unit has a fractional entry, then pi.vec will incur a cost slightly # lower than 0.1. sum(cost[cbind(1:n, pi.vec)]) / n
#> [1] 0.06295773
# Retrieve the underlying solution path. data.path <- summary(path) # If we predict at a spend level on this grid, say entry 5, # then the policy is integer-valued: spend <- data.path$spend[5] predict(path, spend)
#> [,1] [,2] [,3] [,4] #> [1,] 0 1 0 0 #> [2,] 0 0 0 0 #> [3,] 0 0 0 1 #> [4,] 0 0 0 0 #> [5,] 1 0 0 0 #> [6,] 0 0 0 1 #> [7,] 0 1 0 0 #> [8,] 0 0 0 0 #> [9,] 0 0 0 0 #> [10,] 0 0 0 0
predict(path, spend, type = "vector")
#> [1] 2 0 4 0 1 4 2 0 0 0
# }