foot <- read.table("DATA/lrm-foot.txt",header=T) summary(foot) is.factor(foot$sex) plot(foot$foot.L, foot$body.H, xlab='Delka chodidla (mm)', ylab='Telesna vyska (mm)', type='n') points(foot$foot.L[foot$sex=='f'], foot$body.H[foot$sex=='f'], pch=1, col='red') points(foot$foot.L[foot$sex=='m'], foot$body.H[foot$sex=='m'], pch=2, col='blue') legend("topleft", c("zena", "muz"), pch = c(1,2), col=c('red', 'blue')) table(foot$sex) ## ## f m ## 70 47 nrow(foot) ## [1] 117 mean(foot$body.H[foot$sex=='f']) ## [1] 1670.771 sd(foot$body.H[foot$sex=='f']) ## [1] 71.26927 mean(foot$body.H[foot$sex=='m']) ## [1] 1780.064 sd(foot$body.H[foot$sex=='m']) ## [1] 58.38456 mean(foot$body.H) ## [1] 1714.675 sd(foot$body.H) ## [1] 85.25619 mean(foot$foot.L[foot$sex=='f']) ## [1] 244.3714 sd(foot$foot.L[foot$sex=='f']) ## [1] 11.43497 mean(foot$foot.L[foot$sex=='m']) ## [1] 266.2128 sd(foot$foot.L[foot$sex=='m']) ## [1] 11.46248 mean(foot$foot.L) ## [1] 253.1453 sd(foot$foot.L) ## [1] 15.66914 model.interakce <- lm(body.H ~ sex * foot.L, data=foot) model.bez.int <- lm(body.H ~ sex + foot.L, data=foot) anova(model.bez.int, model.interakce) par(mfrow=c(2,2)) plot(model.bez.int) shapiro.test(model.bez.int$residuals) t.test(model.bez.int$residuals) library(car) durbinWatsonTest(model.bez.int) summary(model.bez.int) model.bez.int.bez.faktoru <- lm(body.H ~ foot.L, data=foot) anova(model.bez.int.bez.faktoru, model.bez.int) par(mfrow=c(2,2)) plot(model.bez.int.bez.faktoru) summary(model.bez.int.bez.faktoru) xx <- seq(min(foot$foot.L), max(foot$foot.L), length=300) interval.spol <- predict(model.bez.int.bez.faktoru,newdata=data.frame(foot.L=xx), interval='confidence') plot(foot$foot.L, foot$body.H, xlab='Delka chodidla (mm)', ylab='Telesna vyska (mm)', type='n') points(foot$foot.L[foot$sex=='f'], foot$body.H[foot$sex=='f'], pch=1, col='red') points(foot$foot.L[foot$sex=='m'], foot$body.H[foot$sex=='m'], pch=2, col='blue') lines(xx,interval.spol[,1]) lines(xx,interval.spol[,2], lty=2) lines(xx,interval.spol[,3], lty=2) legend("topleft", c("zena", "muz"), pch = c(1,2), col=c('red', 'blue'))