Learn R Programming

socialranking

The package socialranking offers functions to represent ordinal information of coalitions and calculate the power relation between elements or players.

Installation

Install the package directly from CRAN with:

install.packages("socialranking")

You can also install the development version of socialranking from GitHub with:

# install.packages("devtools")
devtools::install_github("jassler/socialranking")

Usage

The package socialranking offers functions to represent ordinal information of coalitions and calculate the power relation between elements or players.

Once installed, call library(socialranking) to load the package into your current environment.

PowerRelation() and as.PowerRelation() creates a PowerRelation object. createPowerset() is a convenient function to generate a PowerRelation() or as.PowerRelation() function call for all possible coalitions.

library(socialranking)
if(interactive()) {
  createPowerset(1:3, copyToClipboard = TRUE)
}

# pasted, rearranged, adjusted comparators
as.PowerRelation("
  123
  > 12
  ~ 13
  > 2
  ~ 23
  > 1
  > 3
")
#> 123 > (12 ~ 13) > (2 ~ 23) > 1 > 3

# equivalent
pr <- as.PowerRelation(
  list(c(1,2,3), c(1,2), c(1,3), c(2), c(2,3), c(1), c(3)),
  comparators = c(">", "~", ">", "~", ">", ">")
)

# equivalent
pr <- as.PowerRelation("123 > 12 ~ 13 > 2 ~ 23 > 1 > 3")
pr
#> 123 > (12 ~ 13) > (2 ~ 23) > 1 > 3

pr$elements
#> [1] 1 2 3
pr$eqs[[2]]
#> [[1]]
#> [1] 1 2
#> 
#> [[2]]
#> [1] 1 3

The functions used to analyze power relations can be grouped into comparison functions, score functions and ranking solutions. Ranking solutions produce a SocialRankingSolution object.

Comparison FunctionsScore FunctionsRanking Solutions
dominates()
cumulativelyDominates()cumulativeScores()
cpMajorityComparison()^1copelandScores()copelandRanking()
kramerSimpsonScores()kramerSimpsonRanking()
ordinalBanzhafScores()ordinalBanzhafRanking()
lexcelScores()lexcelRanking()
dualLexcelRanking()
L1Scores()L1Ranking()
LPScores()LPRanking()
LPSScores()LPSRanking()

^1 cpMajorityComparisonScore() is a faster alternative to cpMajorityComparison(), but it produces less data.

dominates(pr, 1, 2)
#> [1] FALSE

copelandRanking(pr)
#> 1 ~ 2 > 3

lexcelScores(pr, 1)
#> $`1`
#> [1] 1 2 0 1 0
#> 
#> attr(,"class")
#> [1] "LexcelScores"

PowerRelation objects can be turned into relations objects from the relations package using powerRelationMatrix() or as.relation().

Use browseVignettes("socialranking") for further information.

License

This package is licensed under GPL-3.

Copy Link

Version

Install

install.packages('socialranking')

Monthly Downloads

173

Version

1.2.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Felix Fritz

Last Published

May 16th, 2024

Functions in socialranking (1.2.0)

cumulativeScores

Cumulative scores
cpMajorityComparison

CP-Majority relation
lexcelScores

Lexicographical Excellence
doRanking

Create a SocialRanking object
kramerSimpsonScores

Kramer-Simpson-like method
dominates

Dominance
makePowerRelationMonotonic

Make Power Relation monotonic
createPowerset

Create powerset
equivalenceClassIndex

Get index of equivalence class containing a coalition
elementLookup

Element lookup
testRelation

Test relation between two elements
newPowerRelationFromString

New PowerRelation object
powerRelationMatrix

Create relation matrix
powerRelationGenerator

Generate power relations
transitiveClosure

Transitive Closure
socialranking-package

socialranking: A package for constructing ordinal power relations and evaluating social ranking solutions
ordinalBanzhafScores

Ordinal Banzhaf ranking
newPowerRelation

New Power Relation
L1Scores

L1 Ranking
SocialRanking

SocialRanking object
LPScores

LP Ranking
LPSScores

LP* Ranking
coalitionsAreIndifferent

Are coalitions indifferent
copelandScores

Copeland-like method
as.PowerRelation

Create PowerRelation object
appendMissingCoalitions

Append missing coalitions
L2Scores

L2 Ranking
PowerRelation

PowerRelation object