Skip to content

Instantly share code, notes, and snippets.

@vanatteveldt
Created May 23, 2016 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanatteveldt/505aa5693a6daa129832e218c088a0dc to your computer and use it in GitHub Desktop.
Save vanatteveldt/505aa5693a6daa129832e218c088a0dc to your computer and use it in GitHub Desktop.
x = 2+2
y = c(1,1,1,1,1,1,1,2,3,4)
resp = data.frame(id=1:5, name=c("piet", "jan", "klaas", "marie", "klaas"), iq=90:94)
topd = read.csv("data/income_topdecile.csv")
summary(topd)
mean(topd$France, na.rm = T)
topd
topd = topd[!is.na(topd$France), ]
topd = na.omit(topd)
topd
postwar = topd[topd$Year > 1945, c("Year", "France")]
goodyears = topd$Year > 1945
postwar = topd[goodyears, c("Year", "France")]
topd$Germany[topd$Year == 1980] = NA
pwm = mean(topd$Germany[topd$Year > 1945], na.rm = T)
topd$Germany[is.na(topd$Germany)] = pwm
postwar = topd[topd$Year > 1945,](
with(topd[topd$Year > 1945,], t.test(France, U.S., paired=T))
with(topd, t.test(France, U.S., paired=T))
t.test(postwar$France, postwar$U.S., paired = T)
topd
sdswe = sd(topd$Sweden)
# first row is measurement error
resp = resp[-1, ]
# remove outliers based on Z>1
threshold = mean(topd$Sweden) + sd(topd$Sweden)
topd$Sweden[topd$Sweden > threshold] = NA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment