Skip to contents

Validates and processes a utility matrix and optional respondent weights, zero-centers the utilities per respondent, and bundles everything into an S3 object of class "turf_reach_weighted".

Usage

prepare_turf_reach_weighted(mat, weights = NULL)

Arguments

mat

A numeric matrix of utilities (rows = respondents, cols = items). Row names must be unique respondent IDs.

weights

Optional data.frame with columns id (matching rownames(mat)) and weight, a numeric vector. If NULL, equal weights are assumed.

Value

An object of class "turf_reach_weighted", which is a list containing:

uc

The zero-centered utility matrix.

w

A numeric weight vector aligned to rownames(mat).

Examples

mat <- matrix(rnorm(6), 3, 2,
  dimnames = list(paste0("R", 1:3), c("X", "Y"))
)
prep <- prepare_turf_reach_weighted(mat, NULL)
class(prep)
#> [1] "turf_reach_weighted"