Bieu do tan xa cua Sepal.Length & Petal.Width tu dataset = iris

attach(iris)
library('ggplot2')
q = ggplot(iris, aes(x=Petal.Width, y=Sepal.Length))
q + geom_point() + geom_smooth(method='lm', se=F)
## `geom_smooth()` using formula 'y ~ x'

Xac dinh mo hinh hoi quy tuyen tinh cua Sepal.Length theo Petal.Width

m = lm(Sepal.Length~Petal.Width)
summary(m)
## 
## Call:
## lm(formula = Sepal.Length ~ Petal.Width)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.38822 -0.29358 -0.04393  0.26429  1.34521 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  4.77763    0.07293   65.51   <2e-16 ***
## Petal.Width  0.88858    0.05137   17.30   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.478 on 148 degrees of freedom
## Multiple R-squared:  0.669,  Adjusted R-squared:  0.6668 
## F-statistic: 299.2 on 1 and 148 DF,  p-value: < 2.2e-16

***Theo mo hinh tren, ta thay:

beta0 = 4.77

beta1 = 0.88 >0

Ca x & y deu co y nghia thong ke

R binh phuong = 67%***