3 ms·
http://news.ycombinator.com/formatdoc http://news.ycombinator.com/formatdoc
by mattyb 17y ago
http://news.ycombinator.com/formatdoc http://news.ycombinator.com/formatdoc
- earl 17y agoOh thanks! I suck for missing that... Code for above: d <- read.csv(file='~/stuff/earlh/Iran_2009.csv', header=T, sep=',') lastDigit <- function(v){ v - 10*floor(v/10) } digits <- lastDigit( c(d$Ahmadinejad, d$Karroubi, d$Mousavi, d$Rezaee)) hist(digits, breaks=10) #chi2 gof tab <- table(digits) n <- length(digits) model <- chisq.test(x=tab, p=rep(0.1, 10)) model # hand generated -- check our work above ts <- 0 for(i in 1:length(tab)){ ts <- ts + ( tab[[i]] - 0.1*n)^2 / (0.1*n) } qchisq(p=1-0.076, df=9)