Skip to content

Instantly share code, notes, and snippets.

@inkhorn
Created May 2, 2012 00:40
Show Gist options
  • Save inkhorn/2572673 to your computer and use it in GitHub Desktop.
Save inkhorn/2572673 to your computer and use it in GitHub Desktop.
Scripted example of using chisq to mine for relations between nominal variables
testvars = c(6,7,9,10,11,12,13,14,16, 17,18,19,20,21,23,24,25,26,384,375,376,386,385,387,388)
resultlist = c()
for (i in testvars) {
xsq = chisq.test(big.dataset[,i], big.dataset$DV_3lvls)$statistic
varname = names(big.dataset)[i]
tab = xtabs(~DV_3lvls + big.dataset[,i], data=big.dataset)
resultlist = rbind(resultlist, list(chisq=xsq, testvar=varname, xtab=tab))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment