# NOT RUN {
data(dative)
# analysis with CART tree
library(rpart)
# ---- initial tree
dative.rp = rpart(RealizationOfRecipient ~ .,
data = dative[ ,-c(1, 3)]) # exclude the columns with subjects, verbs
plot(dative.rp, compress = TRUE, branch = 1, margin = 0.1)
text(dative.rp, use.n = TRUE, pretty = 0)
# ---- pruning the initial tree
plotcp(dative.rp)
dative.rp1 = prune(dative.rp, cp = 0.041)
plot(dative.rp1, compress = TRUE, branch = 1, margin = 0.1)
text(dative.rp1, use.n = TRUE, pretty = 0)
# analysis with logistic regression
# ---- logistic regression with the rms package
library(rms)
dative.dd = datadist(dative)
options(datadist = 'dative.dd')
dative.lrm = lrm(RealizationOfRecipient ~
AccessOfTheme + AccessOfRec + LengthOfRecipient + AnimacyOfRec +
AnimacyOfTheme + PronomOfTheme + DefinOfTheme + LengthOfTheme+
SemanticClass + Modality, data = dative)
anova(dative.lrm)
plot(Predict(dative.lrm))
# ---- mixed-effects logistic regression with the lme4 package
require(lme4)
require(lmerTest)
require(optimx)
dative.lmer = glmer(RealizationOfRecipient ~ AccessOfTheme +
AccessOfRec + LengthOfRecipient + AnimacyOfRec +
AnimacyOfTheme + PronomOfTheme + DefinOfTheme + LengthOfTheme +
SemanticClass + Modality + (1|Verb),
control=glmerControl(optimizer="optimx",optCtrl=list(method="nlminb")),
data = dative, family = "binomial")
summary(dative.lmer)
# multiple comparisons for Accessibility of Theme
require(multcomp)
par(mar=c(5,8,3,1))
AcOfTheme.glht <- glht(dative.lmer, linfct = mcp(AccessOfTheme = "Tukey"))
plot(AcOfTheme.glht)
abline(v=0)
summary(AcOfTheme.glht)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab