# R code for Schleef et al. (2011) Polish L2 English (ing) study, from 
# Gorman and Johnson in press

source('ky.R')
library(lme4)
options(contrasts = c('contr.sum', 'contr.poly'))

london <- read.csv('london.csv')

# fixed-effects model
m0 <- glm(response ~ preceding + gramcat + proficiency + logfreq + gender + network, data=london, family=binomial)
drop1(m0, test='Chisq')
sum.coef(m0)

# mixed-effects model
m1 <- lmer(response ~ preceding + gramcat + proficiency + logfreq + gender + network + (1 | id) + (1 | word), data=london, family=binomial)
sum.coef(m1)
summary(m1)
# to compute the p-values for the factor groups quickly, use Rbrul
