This file contains 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
moe = function(pct, N=1000, deff=c(1,2)){ | |
p.L = function(x, n) { | |
ifelse (x == 0,0,qbeta(0.025, x, n - x + 1)) | |
} | |
p.U = function(x, n) { | |
ifelse(x == n,1,qbeta(0.975, x + 1, n - x)) | |
} | |
N = rep(N,length(pct)) | |
lower = function(pct,deff){ |
This file contains 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
a1 <- c(4.2,3.2,11.1,1.3,2.2,2.0) | |
a2 <- c(3.9,3.2,10.0,0.8,3.1,3.1) | |
a3 <- c(6.3,2.5,9.8,0.9,2.2,2.4) | |
a4 <- c(4.4,3.1,9.8,0.8,3.3,2.7) | |
a5 <- c(4.8,3.0,9.9,0.7,3.3,2.4) | |
a6 <- c(4.0,3.4,10.5,0.7,3.3,2.1) | |
a <- rbind(a1,a2,a3,a4,a5,a6) | |
# Get data into tidy format, starting with a, defined above |
This file contains 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
source('https://raw.github.com/gist/1606595/269d61dfcc7930f5275a212e11f3c43771ab2591/GoogleReader.R') | |
rbloggers = getRSSFeed(feedURL="http://r-bloggers.com/feed", | |
email="GOOGLE READER EMAIL", | |
passwd="GOOGLE READER PASSWORD", | |
posts=5000) | |
entries = rbloggers[which(names(rbloggers) == "entry")] | |
length(entries) | |
saveXML(rbloggers, file='rbloggers.xml') |
This file contains 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
##read in the libraries and set the working directory | |
library(tm) | |
library(corrplot) | |
setwd("/path/to/") | |
##read in the data and subset it to the relevant categories | |
data <- read.csv("indvandringPolitikken.csv", fileEncoding = "latin1") | |
data <- data[data$kategori == "Politik" | data$kategori == "Debat" | data$kategori == "Kronikken" | data$kategori == "Leder", ] | |
##create the corpus and clean it |
This file contains 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
function h = plotDecision(dprime,sdnoise,criterion) | |
% h = plotDecision(dprime, sdnoise, criterion) | |
% | |
% plotDecision makes a plot of two Gaussian functions, inspired by signal | |
% detection theory. The inputs are given in terms of standard deviates of | |
% the signal distribution: | |
% | |
% dprime - d', the distance between the means of the Gaussians | |
% sdnoise - $\sigma$, the ratio of the standard deviation of the noise to | |
% the standard deviation of the signal. |
This file contains 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
###### Ordered Categorical DV: ##### | |
#This uses "importance of aid to blacks" as a DV and race of R as the indicator IV.# | |
library(MASS) | |
white <- c(1,1,0,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1, | |
1,1,0,1,1,1,1,1,1,1,1,1,0,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,0,1,1, | |
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,1,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0, | |
1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1, | |
0,1,1,0,1,1,1,1,1,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1, | |
1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, |
This file contains 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
################# | |
# Use R to recreate part of QMV the relative non-proportional hazard estimation graph (fig 2) from Licht (2011) | |
# Christopher Gandrud (http://christophergandrud.blogspot.com/) | |
# 4 October 2012 | |
################# | |
#### Set Up #### | |
# Load required libraries |
This file contains 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 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"),] |
OlderNewer