Skip to contents

Audits supplied weights independently of their estimator.

Usage

audit_calibration(M, target, raw = NULL, final = NULL, converged = NA,
  tolerance = 1e-6, case_id = NULL, margin = NULL, level = NULL,
  lower = 0, upper = 1, target_num = NULL, target_den = NULL,
  concentration = TRUE)

Arguments

M

Numeric or logical binary matrix with margin cells as rows and tasks as columns.

target

Target fractions, one per row; roundoff just above one within two machine epsilons is corrected with a warning.

raw

Optional nonnegative finite weights with positive finite sum.

final

Optional post-processed weights in the same column order.

converged

Optional logical upstream convergence flag; unknown is NA.

tolerance

Positive absolute proportion-scale tolerance.

case_id

Optional nonmissing case identifier for each task.

margin,level

Optional row labels; a complete one-hot margin with inconsistent target total generates a warning when margin labels are supplied. Unlabelled rows do not trigger this check.

lower,upper

Normalized per-task box bounds for the feasibility model; scalar or one per column.

concentration

Logical; compute the optional minimum maximum-weight diagnostic.

target_num,target_den

Optional explicit integer target numerators and common denominator matching target.

Details

Feasibility is over the normalized simplex with optional box bounds. LP witnesses are repaired and evaluated in floating point; the resulting numerical bounds are not exact certificates. An unrestricted rational certificate is attempted when eligible targets are provided. Near-threshold or unsuccessful solves remain unresolved. The raw and final residuals are evaluated separately from the upstream convergence flag.

Value

A list of feasibility diagnostics, unsupported margin rows and target fractions, convergence flag, and raw and optional final summaries. Each summary contains a residual ledger, task ESS and optional case-collapsed ESS.

Examples

audit_calibration(rbind(c(1,0),c(0,1)),c(.8,.2),c(.8,.2))
#> $feasibility
#> $feasibility$status
#> [1] "attainable_to_tolerance"
#> 
#> $feasibility$scope
#> [1] "unrestricted_simplex"
#> 
#> $feasibility$lower
#> [1] 0
#> 
#> $feasibility$upper
#> [1] 0
#> 
#> $feasibility$exact
#> [1] FALSE
#> 
#> $feasibility$primal_status
#> [1] 0
#> 
#> $feasibility$pattern_indices
#> [1] 1 2
#> 
#> $feasibility$pattern_counts
#> [1] 1 1
#> 
#> $feasibility$dual_status
#> [1] 0
#> 
#> $feasibility$gap
#> [1] 0
#> 
#> $feasibility$weight_witness
#> [1] 0.8 0.2
#> 
#> $feasibility$dual_witness
#> [1] 0 0
#> 
#> $feasibility$comparison_guard
#> [1] 1e-12
#> 
#> $feasibility$numerical_status
#> [1] "attainable_to_tolerance"
#> 
#> $feasibility$min_max_weight
#> [1] 0.8
#> 
#> $feasibility$concentration_status
#> [1] 0
#> 
#> 
#> $numerical_converged
#> [1] NA
#> 
#> $tolerance
#> [1] 1e-06
#> 
#> $unsupported_rows
#> integer(0)
#> 
#> $unsupported_target
#> numeric(0)
#> 
#> $raw
#> $raw$gap
#> [1] 0
#> 
#> $raw$balanced
#> [1] TRUE
#> 
#> $raw$within_weight_bounds
#> [1] TRUE
#> 
#> $raw$bound_violation
#> [1] 0
#> 
#> $raw$task_ess
#> [1] 1.470588
#> 
#> $raw$case_ess
#> NULL
#> 
#> $raw$zero_weights
#> [1] 0
#> 
#> $raw$input_total
#> [1] 1
#> 
#> $raw$ledger
#>   margin level target achieved residual
#> 1   <NA>     1    0.8      0.8        0
#> 2   <NA>     2    0.2      0.2        0
#> 
#> 
#> $final
#> NULL
#>