Attachment 'devoicing.R'
Download 1 library(languageR)
2
3 data(finalDevoicing)
4 library(rpart)
5
6 # ---- CART tree
7
8 finalDevoicing.rp = rpart(Voice ~ ., data = finalDevoicing[ , -1])
9 plotcp(finalDevoicing.rp)
10 finalDevoicing.pruned = prune(finalDevoicing.rp, cp = 0.021)
11 plot(finalDevoicing.pruned, margin = 0.1, compress = FALSE)
12 text(finalDevoicing.pruned, use.n = TRUE, pretty = 0, cex=0.8, fancy=F)
13
14 # ---- logistic regression
15
16 library(Design)
17
18 finalDevoicing.dd = datadist(finalDevoicing)
19 options(datadist='finalDevoicing.dd')
20
21 finalDevoicing.lrm = lrm(Voice ~ VowelType + ConsonantType + Obstruent +
22 Nsyll + Stress + Onset1Type + Onset2Type, data = finalDevoicing)
23 anova(finalDevoicing.lrm)
24 vif(finalDevoicing.lrm)
25
26 # ---- model simplification
27
28 fastbw(finalDevoicing.lrm)
29
30 finalDevoicing.lrm = lrm(Voice ~ VowelType + ConsonantType +
31 Obstruent + Nsyll, data = finalDevoicing, x = TRUE, y = TRUE)
32
33 par(mfrow=c(2,2))
34 plot(finalDevoicing.lrm, fun = plogis, ylim = c(0, 1),
35 ylab = "p(voiceless)")
36 par(mfrow=c(1,1))
37
38 # ---- model validation
39
40 validate(finalDevoicing.lrm, B = 200)
41
42
43 ## End(Not run)
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.