#Iris data:
head(iris)
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1          5.1         3.5          1.4         0.2  setosa
## 2          4.9         3.0          1.4         0.2  setosa
## 3          4.7         3.2          1.3         0.2  setosa
## 4          4.6         3.1          1.5         0.2  setosa
## 5          5.0         3.6          1.4         0.2  setosa
## 6          5.4         3.9          1.7         0.4  setosa
dim(iris)
## [1] 150   5
#plot of the data:

plot(iris[,"Sepal.Length"], iris[,"Petal.Length"], main="Iris Dataset",
xlab="Sepal Length", ylab="Petal Length")

iris.lm <- lm(Petal.Length ~ Sepal.Length, data=iris)
iris.lm
## 
## Call:
## lm(formula = Petal.Length ~ Sepal.Length, data = iris)
## 
## Coefficients:
##  (Intercept)  Sepal.Length  
##       -7.101         1.858
summary(iris.lm)
## 
## Call:
## lm(formula = Petal.Length ~ Sepal.Length, data = iris)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.47747 -0.59072 -0.00668  0.60484  2.49512 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -7.10144    0.50666  -14.02   <2e-16 ***
## Sepal.Length  1.85843    0.08586   21.65   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8678 on 148 degrees of freedom
## Multiple R-squared:   0.76,  Adjusted R-squared:  0.7583 
## F-statistic: 468.6 on 1 and 148 DF,  p-value: < 2.2e-16

\[y=-7.01+1.86 Sepal.Length \] R squared: 0.76

plot(Petal.Length  ~ Sepal.Length, data=iris)
abline(iris.lm)

qqnorm(resid(iris.lm))
qqline(resid(iris.lm))

hist(resid(iris.lm))

par(mfrow=c(2,2))
plot(iris.lm)

#R squared 0.76 is high, the QQ plot shows most of the ponint on the line, small P value means we have a good model .