Title: | Cooperative Game Theory |
---|---|
Description: | Implementation of a common set of punctual solutions for Cooperative Game Theory. |
Authors: | Sebastian Cano-Berlanga |
Maintainer: | Sebastian Cano-Berlanga <[email protected]> |
License: | GPL (>= 2) |
Version: | 2.7.1 |
Built: | 2024-10-31 19:57:28 UTC |
Source: | CRAN |
Implementation of a common set of punctual solutions for Cooperative Game Theory.
Package: | GameTheory |
Type: | Package |
Version: | 1.0 |
Date: | 2015-02-04 |
License: | GPL (>= 2) |
Sebastian Cano-Berlanga <[email protected]>
Aumann, R.J. and Maschler, M., (1985) "Game Theoretic Analysis of a bankruptcy from the Talmud." Journal of Economic Theory 36, pp.195–213.
O'Neill B. (1982). "A problem of rights arbitration from the Talmud." Mathematical Social Sciences, 2(4), pp.345–371.
Shapley L, Shubik M (1954). "A Method for Evaluating the Distribution of Power in a Committee System." The American Political Science Review, 48(3), 787–792.
Shapley L (1953). A value for n-person games. In Tucker A, Kuhn H (Eds.), Contributions to the theory of games II (pp. 307–317). Princeton University Press: Princeton NJ.
Schmeidler D (1969). "The Nucleolus of a characteristic function game." SIAM Journal of Applied Mathematics, 17, 1163–1170.
### TRANSFERABLE UTILITY ## 3 PLAYER SHAPLEY VALUE # Begin defining the game COALITIONS <- c(46125,17437.5,5812.5,69187.5,53812.5,30750,90000) LEMAIRE<-DefineGame(3,COALITIONS) summary(LEMAIRE) # End defining the game NAMES <- c("Investor 1","Investor 2","Investor 3") LEMAIRESHAPLEY <- ShapleyValue(LEMAIRE,NAMES) summary(LEMAIRESHAPLEY) # 3 PLAYER NUCLEOLUS OF A GAINS GAME LEMAIRENUCLEOLUS<-Nucleolus(LEMAIRE) summary(LEMAIRENUCLEOLUS) # 4 PLAYER SHAPLEY VALUE COALITIONS <- c(26,27,55,57,53,81,83,82,84,110,108,110,110,110,110) AIR<-DefineGame(4,COALITIONS) NAMES <- c("Airline 1","Airline 2","Airline 3","Airline 4") AIRSHAPLEY<-ShapleyValue(AIR,NAMES) summary(AIRSHAPLEY) # 4 PLAYER NUCLEOLUS OF A COST GAME AIRNUCLEOLUS<-Nucleolus(AIR,type="Cost") summary(AIRNUCLEOLUS) ## SHAPLEY - SHUBIK POWER INDEX # 2003 Elections SEATS<-c(46,42,23,15,9) PARTIES<-c("CiU","PSC","ERC","PP","ICV") E2003<-ShapleyShubik(68,SEATS,PARTIES) summary(E2003) # 2006 Elections SEATS<-c(48,37,21,14,12,3) PARTIES<-c("CiU","PSC","ERC","PP","ICV","C's") E2006<-ShapleyShubik(68,SEATS,PARTIES) summary(E2006) # 2012 Elections SEATS<-c(50,20,21,19,13,9,3) PARTIES<-c("CiU","PSC","ERC","PP","ICV","C's","CUP") E2012<-ShapleyShubik(68,SEATS,PARTIES) summary(E2012) ## CONFLICTING CLAIMS PROBLEM ## replication of Gallastegui et al. (2003), Table 7. CLAIMS <- c(158,299,927,2196,4348,6256,13952) COUNTRIES <- c("Germany","Netherlands","Belgium","Ireland","UK","Spain","France") INARRA <- AllRules(13500,CLAIMS,COUNTRIES) summary(INARRA) plot(INARRA,5) ## Display allocations for UK LorenzRules(INARRA) ## Inequality graph
### TRANSFERABLE UTILITY ## 3 PLAYER SHAPLEY VALUE # Begin defining the game COALITIONS <- c(46125,17437.5,5812.5,69187.5,53812.5,30750,90000) LEMAIRE<-DefineGame(3,COALITIONS) summary(LEMAIRE) # End defining the game NAMES <- c("Investor 1","Investor 2","Investor 3") LEMAIRESHAPLEY <- ShapleyValue(LEMAIRE,NAMES) summary(LEMAIRESHAPLEY) # 3 PLAYER NUCLEOLUS OF A GAINS GAME LEMAIRENUCLEOLUS<-Nucleolus(LEMAIRE) summary(LEMAIRENUCLEOLUS) # 4 PLAYER SHAPLEY VALUE COALITIONS <- c(26,27,55,57,53,81,83,82,84,110,108,110,110,110,110) AIR<-DefineGame(4,COALITIONS) NAMES <- c("Airline 1","Airline 2","Airline 3","Airline 4") AIRSHAPLEY<-ShapleyValue(AIR,NAMES) summary(AIRSHAPLEY) # 4 PLAYER NUCLEOLUS OF A COST GAME AIRNUCLEOLUS<-Nucleolus(AIR,type="Cost") summary(AIRNUCLEOLUS) ## SHAPLEY - SHUBIK POWER INDEX # 2003 Elections SEATS<-c(46,42,23,15,9) PARTIES<-c("CiU","PSC","ERC","PP","ICV") E2003<-ShapleyShubik(68,SEATS,PARTIES) summary(E2003) # 2006 Elections SEATS<-c(48,37,21,14,12,3) PARTIES<-c("CiU","PSC","ERC","PP","ICV","C's") E2006<-ShapleyShubik(68,SEATS,PARTIES) summary(E2006) # 2012 Elections SEATS<-c(50,20,21,19,13,9,3) PARTIES<-c("CiU","PSC","ERC","PP","ICV","C's","CUP") E2012<-ShapleyShubik(68,SEATS,PARTIES) summary(E2012) ## CONFLICTING CLAIMS PROBLEM ## replication of Gallastegui et al. (2003), Table 7. CLAIMS <- c(158,299,927,2196,4348,6256,13952) COUNTRIES <- c("Germany","Netherlands","Belgium","Ireland","UK","Spain","France") INARRA <- AllRules(13500,CLAIMS,COUNTRIES) summary(INARRA) plot(INARRA,5) ## Display allocations for UK LorenzRules(INARRA) ## Inequality graph
This function calculates how to distribute a given endowment by the Adjusted Proportional rule.
AdjustedProportional(E, C, Names = NULL)
AdjustedProportional(E, C, Names = NULL)
E |
Endowment |
C |
Claims of the agents |
Names |
Labels of the agents |
In order to calculate the rule properly, input the claims of the agents in ascending order.
Sebastian Cano-Berlanga <[email protected]>
Curiel, I. J., Maschler, M., & Tijs, S. H. (1987). "Bankruptcy games." Zeitschrift fur Operations Research, 31(5), A143-A159.
This function runs simultaneously all conflicting claims rules available in the package. It also calculates the Gini Index to check inequality among them.
AllRules(E, C, Names = NULL, pct = 0, r = 2)
AllRules(E, C, Names = NULL, pct = 0, r = 2)
E |
Endowment |
C |
Claims |
Names |
Labels of the agents |
pct |
Format of the results. If |
r |
Decimals of the table |
In order to calculate the rule properly, input the claims of the agents in ascending order.
Sebastian Cano-Berlanga <[email protected]>
Gallastegui M, Inarra E, Prellezo R (2003). "Bankruptcy of Fishing Resources: The Northern European Anglerfish Fishery." Marine Resource Economics, 17, 291–307.
## replication of Gallastegui et al. (2003), Table 7. CLAIMS <- c(158,299,927,2196,4348,6256,13952) COUNTRIES <- c("Germany","Netherlands","Belgium","Ireland","UK","Spain","France") INARRA <- AllRules(13500,CLAIMS,COUNTRIES) summary(INARRA) plot(INARRA,5) ## Display allocations for UK LorenzRules(INARRA) ## Inequality graph
## replication of Gallastegui et al. (2003), Table 7. CLAIMS <- c(158,299,927,2196,4348,6256,13952) COUNTRIES <- c("Germany","Netherlands","Belgium","Ireland","UK","Spain","France") INARRA <- AllRules(13500,CLAIMS,COUNTRIES) summary(INARRA) plot(INARRA,5) ## Display allocations for UK LorenzRules(INARRA) ## Inequality graph
This function calculates how to distribute a given endowment by the Alphamin rule.
AlphaMin(E, C, Names = NULL)
AlphaMin(E, C, Names = NULL)
E |
Endowment |
C |
Claims of the agents |
Names |
Labels of the agents |
For each endowment and each claim, the rule ensures an equal division of the endowment among the claimants as far as the smallest claim is totally honoured; then, the remainig endowment is distributed proportionally among the revised claims.
In order to calculate the rule properly, input the claims of the agents in ascending order.
Maria Jose Solis-Baltodano <[email protected]>
Gimenez-Gomez J.M., & Peris J.E. (2014). "A proportional approach to claims problems with a guaranteed minimun." European Journal of Operational Research, 232(1), pp.109–116.
CLAIMS<-c(10,20,30,40) AGENTS<-c("Paul","John","George","Ringo") AlphaMin(67,CLAIMS,AGENTS)->ALPHA summary(ALPHA) # Assignment according to the Alpha-min Rule rule for an Endowment of 67 # Claims Amin # Paul 10 10.0 # John 20 14.5 # George 30 19.0 # Ringo 40 23.5
CLAIMS<-c(10,20,30,40) AGENTS<-c("Paul","John","George","Ringo") AlphaMin(67,CLAIMS,AGENTS)->ALPHA summary(ALPHA) # Assignment according to the Alpha-min Rule rule for an Endowment of 67 # Claims Amin # Paul 10 10.0 # John 20 14.5 # George 30 19.0 # Ringo 40 23.5
This function calculates how to distribute a given endowment by the CEA rule.
CEA(E, C, Names = NULL)
CEA(E, C, Names = NULL)
E |
Endowment |
C |
Claims of the agents |
Names |
Labels of the agents |
The constrained equal awards (CEA) rule (Maimonides, 12th century), proposes equal awards to all agents subject to no one receiving more than his claim.
In order to calculate the rule properly, input the claims of the agents in ascending order.
Sebastian Cano-Berlanga <[email protected]>
Aumann, R.J. and Maschler, M., (1985) "Game Theoretic Analysis of a bankruptcy from the Talmud." Journal of Economic Theory 36, pp.195–213.
This function calculates how to distribute a given endowment by the CEL rule.
CEL(E, C, Names = NULL)
CEL(E, C, Names = NULL)
E |
Endowment |
C |
Claims of the agents |
Names |
Labels of the agents |
The constrained equal losses (CEL) rule (Maimonides, 12th century and Aumann, 1985), chooses the awards vector at which all agents incur equal losses, subject to no one receiving a negative amount
In order to calculate the rule properly, input the claims of the agents in ascending order.
Sebastian Cano-Berlanga <[email protected]>
Aumann, R.J. and Maschler, M., (1985) "Game Theoretic Analysis of a bankruptcy from the Talmud." Journal of Economic Theory 36, pp.195–213.
Definition of a Transferable-Utility Game
DefineGame(n, V)
DefineGame(n, V)
n |
Number of agents |
V |
Coalition values in lexicographic order |
Sebastian Cano-Berlanga <[email protected]>
Lemaire<-DefineGame(3,c(46125,17437.5,5812.5,69187.5,53812.5,30750,90000)) summary(Lemaire) # Characteristic form of the game # Number of agents: 3 # Coaliton Value(s) # v(i) # 1 46125.0 # 2 17437.5 # 3 5812.5 # 12 69187.5 # 13 53812.5 # 23 30750.0 # 123 90000.0
Lemaire<-DefineGame(3,c(46125,17437.5,5812.5,69187.5,53812.5,30750,90000)) summary(Lemaire) # Characteristic form of the game # Number of agents: 3 # Coaliton Value(s) # v(i) # 1 46125.0 # 2 17437.5 # 3 5812.5 # 12 69187.5 # 13 53812.5 # 23 30750.0 # 123 90000.0
Displays a graph with a Lorenz curve for each confliciting claims rule.
LorenzRules(x)
LorenzRules(x)
x |
Output object from |
## replication of Gallastegui et al. (2003), Table 7. CLAIMS <- c(158,299,927,2196,4348,6256,13952) COUNTRIES <- c("Germany","Netherlands","Belgium","Ireland","UK","Spain","France") INARRA <- AllRules(13500,CLAIMS,COUNTRIES) summary(INARRA) plot(INARRA,5) ## Display allocations for UK LorenzRules(INARRA) ## Inequality graph
## replication of Gallastegui et al. (2003), Table 7. CLAIMS <- c(158,299,927,2196,4348,6256,13952) COUNTRIES <- c("Germany","Netherlands","Belgium","Ireland","UK","Spain","France") INARRA <- AllRules(13500,CLAIMS,COUNTRIES) summary(INARRA) plot(INARRA,5) ## Display allocations for UK LorenzRules(INARRA) ## Inequality graph
This function computes the nucleolus solution of a game with a maximum of 4 agents.
Nucleolus(x, type = "Gains")
Nucleolus(x, type = "Gains")
x |
Object of class Game |
type |
Specify if the game refers to Gains or Cost |
The nucleolus looks for an individually rational distribution of the worth of the grand coalition in which the maximum dissatisfaction is minimized. The nucleolus selects the element in the core, if this is nonempty, that lexicographically minimizes the vector of non-increasing ordered excesses of coalitions. In order to compute this solution we consider a sequence of linear programs, which looks for an imputation that minimizes the maximum excess among all coalitions.
The command returns a table with the following elements:
v(S) |
Individual value of player i |
x(S) |
Nucleolus solution of the player i |
Ei |
Excess of the player i |
Sebastian Cano-Berlanga <[email protected]>
Lemaire J (1991). "Cooperative game theory and its insurance applications." Astin Bulletin, 21(01), 17–40.
Schmeidler D (1969). "The Nucleolus of a characteristic function game." SIAM Journal of Applied Mathematics, 17, pp.1163–1170.
## EXAMPLE FROM LEMAIRE (1991) # Begin defining the game COALITIONS <- c(46125,17437.5,5812.5,69187.5,53812.5,30750,90000) LEMAIRE<-DefineGame(3,COALITIONS) # End defining the game LEMAIRENUCLEOLUS<-Nucleolus(LEMAIRE) summary(LEMAIRENUCLEOLUS) # Gains Game, the excess should be negative
## EXAMPLE FROM LEMAIRE (1991) # Begin defining the game COALITIONS <- c(46125,17437.5,5812.5,69187.5,53812.5,30750,90000) LEMAIRE<-DefineGame(3,COALITIONS) # End defining the game LEMAIRENUCLEOLUS<-Nucleolus(LEMAIRE) summary(LEMAIRENUCLEOLUS) # Gains Game, the excess should be negative
This function computes the per capita nucleolus solution of a gains game with a maximum of 4 agents.
NucleolusCapita(x, type = "Gains")
NucleolusCapita(x, type = "Gains")
x |
Object of class Game |
type |
Specify if the game refers to Gains or Cost |
The per capita nucleolus represents a measure of dissatisfaction per capita of such a coalition. It is also an individually rational distribution of the worth of the grand coalition in which the maximum per capita dissatisfaction is minimized. Formally, is defined like the nucleolus but taking into the account the per capita excess.
The command returns a table with the following elements:
v(S) |
Individual value of player i |
x(S) |
Nucleolus solution of the player i |
Ei |
Excess of the player i |
Sebastian Cano-Berlanga <[email protected]>
Lemaire J (1991). "Cooperative game theory and its insurance applications." Astin Bulletin, 21(01), 17–40.
Schmeidler D (1969). "The Nucleolus of a characteristic function game." SIAM Journal of Applied Mathematics, 17, pp.1163–1170.
## DATA FROM LEMAIRE (1991) # Begin defining the game COALITIONS <- c(46125,17437.5,5812.5,69187.5,53812.5,30750,90000) LEMAIRE<-DefineGame(3,COALITIONS) # End defining the game LEMAIRENUCLEOLUS<-NucleolusCapita(LEMAIRE) summary(LEMAIRENUCLEOLUS)
## DATA FROM LEMAIRE (1991) # Begin defining the game COALITIONS <- c(46125,17437.5,5812.5,69187.5,53812.5,30750,90000) LEMAIRE<-DefineGame(3,COALITIONS) # End defining the game LEMAIRENUCLEOLUS<-NucleolusCapita(LEMAIRE) summary(LEMAIRENUCLEOLUS)
Plot results of every rule for a given player.
## S3 method for class 'ClaimsRules' plot(x, y, ...)
## S3 method for class 'ClaimsRules' plot(x, y, ...)
x |
Object of class ClaimsRules |
y |
Agent |
... |
Other graphical parameters |
Sebastian Cano-Berlanga <[email protected]>
## replication of Gallastegui et al. (2003), Table 7. CLAIMS <- c(158,299,927,2196,4348,6256,13952) COUNTRIES <- c("Germany","Netherlands","Belgium","Ireland","UK","Spain","France") INARRA <- AllRules(13500,CLAIMS,COUNTRIES) summary(INARRA) plot(INARRA,5) ## Display allocations for UK LorenzRules(INARRA) ## Inequality graph
## replication of Gallastegui et al. (2003), Table 7. CLAIMS <- c(158,299,927,2196,4348,6256,13952) COUNTRIES <- c("Germany","Netherlands","Belgium","Ireland","UK","Spain","France") INARRA <- AllRules(13500,CLAIMS,COUNTRIES) summary(INARRA) plot(INARRA,5) ## Display allocations for UK LorenzRules(INARRA) ## Inequality graph
This function calculates how to distribute a given endowment by the Proportional rule.
Proportional(E, C, Names = NULL)
Proportional(E, C, Names = NULL)
E |
Endowment |
C |
Claims of the agents |
Names |
Labels of the agents |
In order to calculate the rule properly, input the claims of the agents in ascending order.
Sebastian Cano-Berlanga <[email protected]>
This function calculates how to distribute a given endowment by the Random Arrival rule.
RandomArrival(E, C, Names = NULL)
RandomArrival(E, C, Names = NULL)
E |
Endowment |
C |
Claims of the agents |
Names |
Labels of the agents |
The random arrival rule (O'Neill, 1982) works in the following fashion: suppose that each claim is fully honored until the endowment runs out following the order of the claimants arrival. In order to remove the unfairness of the first-come first-serve scheme associated with any particular order of arrival, the rule proposes to take the average of the awards vectors calculated in this way when all orders are equally probable.
In order to calculate the rule properly, input the claims of the agents in ascending order.
Sebastian Cano-Berlanga <[email protected]>
O'Neill B. (1982). "A problem of rights arbitration from the Talmud." Mathematical Social Sciences, 2(4), pp.345–371.
This function computes Shapley - Shubik Power Index of a coalition.
ShapleyShubik(quota, y, Names = NULL)
ShapleyShubik(quota, y, Names = NULL)
quota |
Minimum amount of votes to pass a vote |
y |
Seats of every party |
Names |
Labels of the parties |
The Shapley and Shubik index works as follows. There is a group of individuals all willing to vote on a proposal. They vote in order and as soon as a majority has voted for the proposal, it is declared passed and the member who voted last is given credit for having passed it. Let us consider that the members are voting randomly. Then we compute the frequency with which an individual is the one that gets the credit for passing the proposal. That measures the number of times that the action of that individual joining the coalition of their predecessors makes it a winning coalition. Note that if this index reaches the value of 0, then it means that this player is a dummy. When the index reaches the value of 1, the player is a dictator.
Sebastian Cano-Berlanga <[email protected]>
Shapley L, Shubik M (1954). "A Method for Evaluating the Distribution of Power in a Committee System." The American Political Science Review, 48(3), 787–792.
## SHAPLEY - SHUBIK POWER INDEX APPLIED TO THE CATALAN PARLIAMENT # 2012 Elections SEATS<-c(50,20,21,19,13,9,3) PARTIES<-c("CiU","PSC","ERC","PP","ICV","C's","CUP") E2012<-ShapleyShubik(68,SEATS,PARTIES) summary(E2012) # Results for 2012 elections # CiU PSC ERC PP ICV C's CUP # Votes 50.000 20.000 21.000 19.000 13.0000 9.0000 3.0000 # Votes (R) 0.370 0.148 0.156 0.141 0.0963 0.0667 0.0222 # Shapley-Shubik 0.533 0.133 0.133 0.133 0.0333 0.0333 0.0000
## SHAPLEY - SHUBIK POWER INDEX APPLIED TO THE CATALAN PARLIAMENT # 2012 Elections SEATS<-c(50,20,21,19,13,9,3) PARTIES<-c("CiU","PSC","ERC","PP","ICV","C's","CUP") E2012<-ShapleyShubik(68,SEATS,PARTIES) summary(E2012) # Results for 2012 elections # CiU PSC ERC PP ICV C's CUP # Votes 50.000 20.000 21.000 19.000 13.0000 9.0000 3.0000 # Votes (R) 0.370 0.148 0.156 0.141 0.0963 0.0667 0.0222 # Shapley-Shubik 0.533 0.133 0.133 0.133 0.0333 0.0333 0.0000
Calculates the Shapley value for a N-agent cooperative game.
ShapleyValue(x, Names = NULL)
ShapleyValue(x, Names = NULL)
x |
object of class Game |
Names |
Labels of the agents |
Please check ShapleyShubik
for an extension to voting power index.
Sebastian Cano-Berlanga <[email protected]>
Shapley L (1953). A value for n-person games. In Tucker A, Kuhn H (Eds.), Contributions to the theory of games II (pp. 307-317). Princeton University Press: Princeton NJ.
# Begin defining the game COALITIONS <- c(46125,17437.5,5812.5,69187.5,53812.5,30750,90000) LEMAIRE<-DefineGame(3,COALITIONS) # End defining the game NAMES <- c("Investor 1","Investor 2","Investor 3") LEMAIRESHAPLEY <- ShapleyValue(LEMAIRE,NAMES) summary(LEMAIRESHAPLEY)
# Begin defining the game COALITIONS <- c(46125,17437.5,5812.5,69187.5,53812.5,30750,90000) LEMAIRE<-DefineGame(3,COALITIONS) # End defining the game NAMES <- c("Investor 1","Investor 2","Investor 3") LEMAIRESHAPLEY <- ShapleyValue(LEMAIRE,NAMES) summary(LEMAIRESHAPLEY)
summary
method for class "ClaimsRule"
.
## S3 method for class 'ClaimsRule' summary(object, ...)
## S3 method for class 'ClaimsRule' summary(object, ...)
object |
an object of class |
... |
Other parameters passed down to |
Summary methods for a ClaimsRules Object
## S3 method for class 'ClaimsRules' summary(object, ...)
## S3 method for class 'ClaimsRules' summary(object, ...)
object |
A |
... |
Other parameters passed down to |
Summary methods for a Game Object
## S3 method for class 'Game' summary(object, ...)
## S3 method for class 'Game' summary(object, ...)
object |
A |
... |
Other parameters passed down to |
Summary methods for a Nucleolus Object
## S3 method for class 'Nucleolus' summary(object, ...)
## S3 method for class 'Nucleolus' summary(object, ...)
object |
A |
... |
Other parameters passed down to |
Summary methods for a ShapleyShubik Object
## S3 method for class 'ShapleyShubik' summary(object, ...)
## S3 method for class 'ShapleyShubik' summary(object, ...)
object |
A |
... |
Other parameters passed down to |
Prints the summary of the Shapley values solution for a given game.
## S3 method for class 'ShapleyValue' summary(object, ...)
## S3 method for class 'ShapleyValue' summary(object, ...)
object |
A |
... |
Other parameters passed down to |
This function calculates how to distribute a given endowment by the Talmud rule.
Talmud(E, C, Names = NULL)
Talmud(E, C, Names = NULL)
E |
Endowment |
C |
Claims of the agents |
Names |
Labels of the agents |
The Talmud rule (Aumann 1985) proposes to apply the constrained equal awards rule, if the endowment is not enough to satisfy the half-sum of the claims. Otherwise, each agent receives the half of her claim and the constrained equal losses rule is applied to distribute the remaining endowment.
In order to calculate the rule properly, input the claims of the agents in ascending order.
Sebastian Cano-Berlanga <[email protected]>
Aumann, R.J. and Maschler, M., (1985) Game Theoretic Analysis of a bankruptcy from the Talmud. Journal of Economic Theory 36, pp.195–213.