fat <- read.table("DATA/fat.txt",header=T) summary(fat) plot(fat$hip.F, fat$body.W, xlab='Tloustka kozni rasy (mm)', ylab='Telesna hmotnost (kg)') m.weight <- lm(body.W ~ hip.F, data=fat) par(mfrow=c(2,2)) plot(m.weight) shapiro.test(m.weight$residuals) t.test(m.weight$residuals) library(car) durbinWatsonTest(m.weight) summary(m.weight) confint(m.weight) 100 * mean(abs(m.weight$residuals/fat$body.W)) predict(m.weight, newdata=data.frame(hip.F=20)) xx <- seq(min(fat$hip.F), max(fat$hip.F), length=300) interval.spol <- predict(m.weight,newdata=data.frame(hip.F=xx),interval='confidence') pred.interval <- predict(m.weight,newdata=data.frame(hip.F=xx),interval='predict') plot(fat$hip.F, fat$body.W, xlab='Tloustka kozni rasy (mm)', ylab='Telesna hmotnost (kg)') lines(xx,interval.spol[,1],col='red') lines(xx,interval.spol[,2], col='red', lty=2) lines(xx,interval.spol[,3], col='red', lty=2) lines(xx,pred.interval[,2], col='blue', lty=2) lines(xx,pred.interval[,3], col='blue', lty=2) legend("topleft",c('model','IS','pred. int.'), lty=c(1,2,2), col=c('red', 'red', 'blue')) m.weight.2 <- lm(body.W ~ hip.F + I(hip.F^2), data=fat) par(mfrow=c(2,2)) plot(m.weight.2) shapiro.test(m.weight.2$residuals) t.test(m.weight.2$residuals) durbinWatsonTest(m.weight.2) summary(m.weight.2) #parabola 100 * mean(abs(m.weight.2$residuals/fat$body.W))