Starting with 3.5, we looked into confidence intervales. To aid with looking into confidence intervales I looked into Sepal Length and Sepal width.

data(iris)
attach(iris)

model <- lm(Sepal.Length ~ Sepal.Width, data=iris)

summary(iris)
##   Sepal.Length    Sepal.Width     Petal.Length    Petal.Width   
##  Min.   :4.300   Min.   :2.000   Min.   :1.000   Min.   :0.100  
##  1st Qu.:5.100   1st Qu.:2.800   1st Qu.:1.600   1st Qu.:0.300  
##  Median :5.800   Median :3.000   Median :4.350   Median :1.300  
##  Mean   :5.843   Mean   :3.057   Mean   :3.758   Mean   :1.199  
##  3rd Qu.:6.400   3rd Qu.:3.300   3rd Qu.:5.100   3rd Qu.:1.800  
##  Max.   :7.900   Max.   :4.400   Max.   :6.900   Max.   :2.500  
##        Species  
##  setosa    :50  
##  versicolor:50  
##  virginica :50  
##                 
##                 
## 

To establish a confidence interval we use confident() to find a confidence intervale with 95% confidence. (or 5% alpha)

confint(model) #3.5
##                 2.5 %     97.5 %
## (Intercept)  5.579865 7.47258038
## Sepal.Width -0.529820 0.08309785

This shows that there is possibility for there to be a positive corrilation between Sepal width and Sepal length, but it seems like a larger portin of the confidence interval sits below 0.

cor(Sepal.Width,Sepal.Length)
## [1] -0.1175698

This reinforces the though that there is a negative corrilation between Sepal lenght and width.

Next we will look into some confidence intervales. They should both be centered on the same mean, but the main difference is that the confidence intervale that is designed for predicting the next occurance will have a wider interval than the conffidence intervale predicting the mean.

Sepal.Frame <- data.frame( Sepal.Width = 3.15)
Length.mod <- lm(Sepal.Length ~ Sepal.Width)
(p1 <- predict(Length.mod, Sepal.Frame, interval="predict"))
##        fit      lwr    upr
## 1 5.822635 4.186471 7.4588
(c1 <- predict(Length.mod, Sepal.Frame, interval="confidence"))
##        fit      lwr     upr
## 1 5.822635 5.686511 5.95876

The major difference again is that the interval for the prediction of the next point is wider than the interval for predicting the mean. The last thing I will look at is that the middle’s of each interval are equal to eachother.

p1[1]==c1[1]
## [1] TRUE