Description Usage Arguments Value Note References Examples
This program simulates election outcomes for the Alternative Vote System using the actual First-Past-The-Post votes. It takes a wide table with the election results and returns a csv
file with simulations for further analysis.
1 |
data |
A flat table or data frame containing FPTP votes for each district. |
link |
A link function containing a structure for candidates/parties relations. |
A text file (csv)
containing simulated electoral results for each district.
Unfortunately, this function is not so flexible regarding the data supplied. For it to work properly, the input table should have the same format (flat table) as the example data provided within this package. Namely, the same structure with an Id column, the name of the constituencies in another column, and each party achievements distributed in columns. Besides the dataset, a "link" structure for party/candidates' relations is also necessary.
Marcelino, Daniel (2013). SciencesPo: A Tool Set for Analyzing Political Behaviour Data. Available at SSRN: http://dx.doi.org/10.2139/ssrn.2320547
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #Feeding data:
data(ge2010)
# Let's take a small portion of the data.
IR <-ge2010[ge2010$Region=="Northern Ireland",]
# First, we create vectors for parties/candidates link
# For simplicity, I'm considering only parties which received some votes.
APNI<- c("SF", "DUP", "SDLP", "TUV", "UCUNF")
BNP<-c("Ch P", "Con", "CPA", "NF", "UKIP");
Ch_P<-c("BNP", "CPA", "Con", "ED")
Con<-c("LD", "UKIP", "ED", "Ch P", "CPA")
CPA<-c("BNP", "Ch P", "Con", "ED")
DUP<-c("SDLP", "TUV", "UCUNF", "APNI")
ED<-c("Con", "BNP", "NF", "CPA", "Ch P")
Grn<-c("LD", "Lab", "SDLP", "PC", "SSP", "TUSC", "TUV")
Lab<-c("LD", "Grn", "SDLP", "Soc", "SSP", "TUSC", "TUV")
LD<-c("Lab", "Con", "Grn", "PC", "SDLP")
MRLP<-c("Con", "Lab", "LD", "Grn", "PC", "SDLP", "SNP", "SSP", "UKIP")
NF<-c("BNP", "Con", "ED", "UKIP")
PC<-c("Con", "Lab", "LD")
Respect<-c("Con", "Lab", "LD")
SDLP<-c("Grn", "Lab", "LD")
SF<-c("APNI", "USUNF")
Soc<-c("Lab", "SSP", "SDLP", "TUSC", "TUV")
SNP<-c("Ch P", "CPA", "UKIP")
SSP<-c("Grn", "Lab", "LD", "SDLP", "TUSC", "TUV")
TUSC<-c("SDLP", "Soc", "SSP", "TUV")
TUV<-c("SDLP", "Soc", "SSP", "TUSC")
UCUNF<-c("APNI", "SF", "DUP")
UKIP<-c("BNP", "NF", "Con")
## vector with party/candidate relations:
party_chains <-structure(list(APNI,BNP,Ch_P,Con,CPA,DUP,ED,
Grn, Lab,LD,MRLP,NF,PC,Respect,SDLP,SF,Soc,SNP,SSP,TUSC,TUV,UCUNF,
UKIP), .Names = c("APNI","BNP","Ch_P","Con","CPA","DUP","ED","Grn",
"Lab","LD","MRLP","NF","PC","Respect","SDLP","SF","Soc","SNP","SSP",
"TUSC", "TUV","UCUNF","UKIP" ));
## Run the algorithm
## Not run: fptp2av(data=IR, link=party_chains)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.