library(MASS)
leaf17.lda <- lda(arch ~ logwid+loglen, data=leafshape17)
leaf17.hat <- predict(leaf17.lda)
leaf17.lda
table(leafshape17$arch, leaf17.hat$class)
pause()
tab <- table(leafshape17$arch, leaf17.hat$class)
sum(tab[row(tab)==col(tab)])/sum(tab)
leaf17cv.lda <- lda(arch ~ logwid+loglen, data=leafshape17, CV=TRUE)
tab <- table(leafshape17$arch, leaf17cv.lda$class)
pause()
leaf17.glm <- glm(arch ~ logwid + loglen, family=binomial, data=leafshape17)
options(digits=3)
summary(leaf17.glm)$coef
pause()
leaf17.one <- cv.binary(leaf17.glm)
table(leafshape17$arch, round(leaf17.one$internal)) # Resubstitution
pause()
table(leafshape17$arch, round(leaf17.one$cv)) # Cross-validation
Run the code above in your browser using DataLab