Description Functions Demos Psuedocode
The kMajorityRule package enables the simulation of various kMajority Rule scenarios. It allows for the examination of the code use in "An Expected Utility Analysis of the Optimal k-majority rule"
The major fucntions in the package are:
aKMajorityRuleSimulation
: Runs a series of proposals for J iterations, for all possible k-majority rules.
iterations
: Runs numberOfIterations of seriesOfProposals() with the same set of initial parameters. Stores all of the input parameters, generated values and output for further analysis.
updateVoterLevelDataFrame
: Takes an existing voter level data frame and a group level data frame that has had it's parameters changed and outputs a new voter level data frame.
seriesOfProposals
: Runs a series of votes/multiple alternatives following a follows a "successive" voting procedure. Stores all of the input parameters, generated values and output for further analysis.
genVoterLevelDataFrame
: Takes the information from a group level data frame generated by genGroupLevelDataframe(), and draws ui and ei for the groups of voters based on it.
genGroupLevelDataFrame
: Creates a data.frame to hold the group level data for the simulation.
drawNormalValues
: Draws ui or ei values from N(groupMean, groupStandardDeviation).
plotExpectedUtilityTotalCost
: Plots the Total Cost, Decision Cost and Expected Utility measures for the voters of interest, in the round the proposal passed, for each of the kMajority rules.
plotNumberOfRounds
: Plots the mean number of rounds it took for the status quo to be defeated for each k-majority rule, across all the iterations.
plotOnlyExpectedUtility
: Plots the expected utility measures for the voters of interest, in the round the proposal passed, for each of the kMajority rules.
plotPareto
: Plot the number of rounds (y-axis) where a Pareto preferred proposal failed by k-majority (x-axis).
Each function has detailed documentation that can be accessed using ?functionName
. For example ?iterations
with show the documentation for the iterations()
function.
Each of the Figures can be replicated by calling its coresponding demo()
at the console prompt.
demo(demoFigure4A)
demo(demoFigure4B)
demo(demoFigure4C)
demo(demoFigure4D)
demo(demoFigure6A)
demo(demoFigure6B)
demo(demoFigure7A)
demo(demoFigure7B)
demo(demoFigure8A)
demo(demoFigure8B)
The appendix to the paper contais extensive psuedo code that explains the basic logic of the code.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.