Skip to content

Instantly share code, notes, and snippets.

@octonion
Created February 8, 2015 02:44
Show Gist options
  • Save octonion/2d087e27f8199f0dd122 to your computer and use it in GitHub Desktop.
Save octonion/2d087e27f8199f0dd122 to your computer and use it in GitHub Desktop.
California Public vs Private Schools and Personal Belief Exemptions
library(lme4)
rates <- read.csv("data/cakd1314.csv", header=TRUE)
head(rates)
summary(rates)
colnames(rates)
rates$SCHOOL <- paste(rates$COUNTY, ":" , rates$CITY, ":", rates$SCHOOL.NAME, sep="")
rates$CITY <- paste(rates$COUNTY, ":" , rates$CITY, sep="")
# Should be equivalent to:
#fit <- glmer(cbind(PBE.,ENROLLMENT-PBE.) ~ (1|COUNTY/CITY/SCHOOL) + PUBLIC.PRIVATE, data=rates, family="binomial")
model0 <- cbind(PBE.,ENROLLMENT-PBE.) ~ (1|COUNTY) + (1|CITY) + (1|SCHOOL)
model1 <- cbind(PBE.,ENROLLMENT-PBE.) ~ (1|COUNTY) + (1|CITY) + (1|SCHOOL) + PUBLIC.PRIVATE
fit0 <- glmer(model0, data=rates, family="binomial")
fit1 <- glmer(model1, data=rates, family="binomial")
anova(fit0)
anova(fit1)
anova(fit0,fit1)
summary(fit1)
fixef(fit1)
ranef(fit1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment