Skip to content

Instantly share code, notes, and snippets.

View jwbowers's full-sized avatar
🎯
Focusing

Jake Bowers jwbowers

🎯
Focusing
View GitHub Profile
(eval-when-compile
(require 'color-theme))
(defun color-theme-solarized (mode)
"Color theme by Ethan Schoonover, created 2011-03-24.
Ported to Emacs by Greg Pfeil, http://ethanschoonover.com/solarized."
(interactive "Slight or dark? ")
(let ((base03 "#002b36")
(base02 "#073642")
(base01 "#586e75")
@jwbowers
jwbowers / Installing R on dreamhost
Created March 13, 2012 19:46 — forked from widged/Installing R on dreamhost
Installing R on dreamhost
## First do the unix account setup http://wiki.dreamhost.com/Unix_account_setup
cd ${HOME}
# create the first level directories (and log/setup)
mkdir -pv soft run www log log/setup backup data
# create the second level directories within run (our own FHS)
for subdir in bin etc include lib man share
do
mkdir -pv run/${subdir}
done
# symlink so that man pages stay all in the same place
@jwbowers
jwbowers / bowers-nbp-functions.R
Created July 31, 2012 13:41
Helper functions for nbpMatching
## This file contains functions that I've found useful when working
## with the nbpMatching package. Context for the examples can be seen
## in Appendix E in
## http://jakebowers.org/PAPERS/WongRacialContext2012.pdf
## (forthcoming in the Journal of Politics).
## Make matrices of absolute distances
scalar.dist<-function(var){
## Utility function to make n x n abs dist matrices
## Cribbed from older versions of optmatch
@jwbowers
jwbowers / eeniemeenie.R
Last active December 18, 2015 13:28
Predicting the outcome of eenie meenie miney mo ... you are not it!
## Eenie meenie miney mo,
## Catch a tiger by its toe
## If it hollers let it go,
## eenie meenie miney mo.
## My mom says that
## you are not it.
## The poem is 24 beats long (4 counts per line, 6 lines).
## The aim of the poem is to eliminate people from consideration as "it".
@jwbowers
jwbowers / ps230classwork5.R
Last active December 22, 2015 22:18
PS 230 classwork 5 code pieces
library(car)
#
#
#
gss$dem<-recode(gss$partyid, "c('strong democrat','not str democrat','ind,near dem')=1 ; c('independent','other party')=NA ; NA=NA ; else=0")
#
#
#
@jwbowers
jwbowers / ps230classwork6.R
Last active December 23, 2015 06:19
PS 230 Classwork 6
## ##Load a small version of Dr. Page Fortna's data. I've stripped it of the missing values to make our lives easier.
## load(url("http://jakebowers.org/PS230/pk.df.rda")) ##The name of the dataframe or dataset is pk.df.
## library(mosaic) ## the mosaic library might be useful
## Run these next lines
## First get rid of missing data to make life easier in class
pk.good<-na.omit(subset(pk.df,select=c('ridp','wardur','id')))
lm1<-lm(ridp~wardur,data=pk.good) ## fit the model
coef(lm1) ## print coeficients
##Load a small version of Fortna's data.
load(url("http://jakebowers.org/PS230/pk2.df.rda"))
## Make a new dataframe with no missing values and adding UNpk (UN
## peacekeeping) and year the civil war started
pk.good<-na.omit(subset(pk.df,select=c('ridp','wardur','warstart.yr','warstart.hist.yr','UNpk','id')))
## Load the mosaic library for plotting etc
library(mosaic)
lm1<-lm(ridp~warstart.hist.yr,data=pk.good) ## fit the model
@jwbowers
jwbowers / ps230classwork8.R
Last active December 23, 2015 20:19
Code to copy and paste for class 8.
##Load a small version of Fortna's data.
load(url("http://jakebowers.org/PS230Data/pk2.df.rda"))
## Make a new dataframe with no missing values and adding UNpk (UN
## peacekeeping) and year the civil war started
pk.good<-na.omit(subset(pk.df,select=c('ridp','wardur','warstart.yr','warstart.hist.yr','UNpk','id')))
## Load the mosaic library for plotting etc
library(mosaic)
##Recall that
lm3<-lm(ridp~UNpk,data=pk.good)
##Load a small version of Fortna's data.
load(url("http://jakebowers.org/PS230/pk2.df.rda"))
## Make a new dataframe with no missing values at all
pk.good<-na.omit(pk.df)
## Load the mosaic library for plotting etc
library(mosaic)
ssr <- function(intercept,slope,thedata=pk.good){
the.model.values <- with(thedata, intercept + (slope * wardur)) ## calc model values from model function
##Load a small version of Fortna's data.
load(url("http://jakebowers.org/PS230/pk2.df.rda"))
## Make a new dataframe with no missing values at all
pk.good<-na.omit(pk.df)
## Load the mosaic library for plotting etc
library(mosaic)
with(pk.good,table(UNpk,pkopF))
## First just recode whether any peacekeeping happened