This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(gdata) | |
library(countrycode) | |
infile <- "IMFmultipliers.xls" | |
imf_rep <- read.xls(infile, sheet = 2, | |
skip = 3, | |
header=F) | |
names(imf_rep) <- c("Country", | |
"gdp_4cast_2011","gdp_4cast_2012", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Load libraries | |
library(mclogit) | |
library(reshape) | |
library(rjags) | |
library(R2WinBUGS) ## for write.model | |
## Load the data file from mclogit | |
data(Transport) | |
## Do the mclogit model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plyr) | |
library(zoo) | |
startyr <- 1992 | |
endyr <- 2012 | |
pg <- read.csv("http://www.parlgov.org/stable/static/data/stable-utf-8/view_cabinet.csv",as.is=T) | |
## Exclude GDR | |
pg <- pg[which(pg$country_name_short!="GDR"),] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Please note, this script is entirely derivative of work done | |
## by Simon Jackman for his article `Pooling the Polls...' | |
## Aust. J. Pol. Science, 40(4): 499-517 | |
## Libraries | |
library(reshape) | |
library(rjags) | |
library(R2WinBUGS) | |
library(ggplot2) | |
library(scales) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use Switch; | |
binmode STDOUT, ":utf8"; | |
use WWW::Mechanize; | |
use HTML::TokeParser; | |
use Data::Dumper; | |
my $start = 'http://www.sondaggipoliticoelettorali.it/'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Takes as input a Google Docs spreadsheet | |
### Outputs national and regional level estimates of support | |
### over time | |
### Load libraries | |
library(R2WinBUGS) | |
library(rjags) | |
library(RCurl) | |
library(reshape) | |
library(foreach) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Load libraries | |
library(sp) | |
library(RColorBrewer) | |
library(car) | |
library(stringdist) | |
## Read in the shapefile | |
shape <- readOGR("../shapefiles/",layer="Comuni_11") | |
shape$NOME <- iconv(shape$NOME, "latin1", "UTF8") | |
shape$NOME.lc <- tolower(shape$NOME) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dat <- read.csv("votazioni.csv",header=T) | |
## Exclude schede bianche, schede null | |
dat <- subset(dat,!is.element(Candidato,c("Schede bianche","Schede nulle","Voti dispersi"))) | |
## Iterate over years | |
for (my.year in unique(dat$Year)) { | |
my.subset <- subset(dat,Year == my.year) | |
## top eight candidates | |
max.per.candidate <- tapply(my.subset$Voti,my.subset$Candidato,max) | |
max.per.candidate <- sort(max.per.candidate,decreasing=TRUE)[1:8] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Assumes you have the Samuels/Shugart data from http://laderafrutal.com/academic/samuels-shugart.html | |
## and the CCP data from http://www.comparativeconstitutionsproject.org/ | |
library(countrycode) | |
library(foreign) | |
library(plyr) | |
library(pwt) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(foreign) | |
library(survival) | |
dat <- read.dta("delay.dta") | |
dat$bargainingdays [which(dat$bargainingdays == 0)] <- .01 | |
dat$post_legislative_parties <- dat$postelection * dat$legislative_parties | |
dat$post_polariz <- dat$postelection * dat$polarization | |
dat$post_positive <- dat$postelection * dat$positive_parl |
OlderNewer