Exercice V
Exercice V
Where:
The summary(model) function provides the coefficients for the regression line.
# Data
x <- c(25, 20, 26, 26, 28, 28, 29, 32, 20, 25, 26, 28, 25, 31, 30)
y <- c(138, 84, 104, 112, 88, 132, 90, 183, 100, 143, 141, 161, 124,
118, 168)
data <- data.frame(x, y)
# Regression line
beta_0 <- coef(model)[1]
beta_1 <- coef(model)[2]
cat("/////////////////////////\n")
cat("Regression line: y =", beta_0, "+", beta_1, "x\n")
Call:
lm(formula = y ~ x, data = data)
Residuals:
Min 1Q Median 3Q Max
-46.493 -15.593 3.856 21.940 33.057
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.478 55.952 0.116 0.9096
x 4.483 2.087 2.148 0.0511 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 27.02 on 13 degrees of freedom
Multiple R-squared: 0.262, Adjusted R-squared: 0.2052
F-statistic: 4.615 on 1 and 13 DF, p-value: 0.05113
/////////////////////////
Regression line: y = 6.477725 + 4.483294 x
β^ 1 − β 1
∼ t ( n −2 )
√
S / ∑ ( xi − x́ )
2
^β 1 ± t n −2 ,1 − α/2 × S
√ ∑ ( x − x́ )
i
2
Decision Rule:
2.5 % 97.5 %
(Intercept) -114.39837902 127.353828
x -0.02546064 8.992048