Learn R Programming

TUvalues (version 0.1.0)

shapley: Shapley value

Description

Calculate the Shapley value

Usage

shapley(characteristic_func, method = "exact", n_rep = 10000, n_players = 0)

Value

The Shapley value for each player.

Arguments

characteristic_func

The valued function defined on the subsets of the number of players.

method

Method used to calculate the Shapley value. Valid methods are: exact for the exact calculation or appro for approximated polynomial calculation based on sampling.

n_rep

Only used if method is appro. The number of iterations to perform in the approximated calculation.

n_players

Only used if characteristic_func is a function. The number of players in the game.

Examples

Run this code
n <- 3
v <- c(1,1,2,1,2,2,2)
shapley(v, method = "exact")
shapley(v, method = "appro", n_rep = 4000)

Run the code above in your browser using DataLab