# NOT RUN {
data(etymology)
# ---- EtymAge should be an ordered factor, set contrasts accordingly
etymology$EtymAge = ordered(etymology$EtymAge, levels = c("Dutch",
"DutchGerman", "WestGermanic", "Germanic", "IndoEuropean"))
options(contrasts=c("contr.treatment","contr.treatment"))
library(rms)
etymology.dd = datadist(etymology)
options(datadist = 'etymology.dd')
# ---- EtymAge as additional predictor for regularity
etymology.lrm = lrm(Regularity ~ WrittenFrequency +
rcs(FamilySize, 3) + NcountStem + InflectionalEntropy +
Auxiliary + Valency + NVratio + WrittenSpokenRatio + EtymAge,
data = etymology, x = TRUE, y = TRUE)
anova(etymology.lrm)
# ---- EtymAge as dependent variable
etymology.lrm = lrm(EtymAge ~ WrittenFrequency + NcountStem +
MeanBigramFrequency + InflectionalEntropy + Auxiliary +
Regularity + LengthInLetters + Denominative + FamilySize + Valency +
NVratio + WrittenSpokenRatio, data = etymology, x = TRUE, y = TRUE)
# ---- model simplification
etymology.lrm = lrm(EtymAge ~ NcountStem + Regularity + Denominative,
data = etymology, x = TRUE, y = TRUE)
validate(etymology.lrm, bw=TRUE, B=200)
# ---- plot partial effects and check assumptions ordinal regression
plot(Predict(etymology.lrm))
plot(etymology.lrm)
resid(etymology.lrm, 'score.binary', pl = TRUE)
plot.xmean.ordinaly(EtymAge ~ NcountStem, data = etymology)
# }
Run the code above in your browser using DataLab