scale_maq: Scale a Qini curve.

View source: R/maq.R

scale_maqR Documentation

Scale a Qini curve.

Description

Remaps the policy value and budget to application-specific units. This convenience function is typically useful for plots.

Usage

scale_maq(object, scale = 1)

Arguments

object

A maq object.

scale

A numeric value to scale by.

Value

A maq object with policy values and budget rescaled by the given factor.

Examples


# Generate some single-arm toy data.
n <- 1500
K <- 1
reward <- matrix(1 + runif(n * K), n, K)
scores <- reward + 5 * matrix(rnorm(n * K), n, K)
cost <- 1

# Fit a Qini curve.
qini <- maq(reward, cost, scores, R = 200)

# Plot the policy values as we vary the fraction treated.
plot(qini, xlab = "Fraction treated")

# Plot the policy values for a maximum allocation of, for example, 500 units.
plot(scale_maq(qini, 500), xlab = "Units treated")

# With R 4.1.0 or later, the native pipe can be used to chain scaling and plotting.
# scale_maq(qini, 500) |>
#   plot(xlab = "Units treated")


maq documentation built on April 15, 2025, 1:35 a.m.

Related to scale_maq in maq...