Practice Regression1
Practice Regression1
80
70
mass
60
50
40
1.5 1.6 1.7 1.8 1.9
height
1
## # A tibble: 10 x 4
## ‘height[1:10]‘ ‘mass[1:10]‘ ‘height[11:20]‘ ‘mass[11:20]‘
## <dbl> <dbl> <dbl> <dbl>
## 1 1.72 67 1.75 64
## 2 1.66 66 1.55 65
## 3 1.59 67 1.61 75
## 4 1.5 42 1.65 70
## 5 1.78 83 1.61 55.4
## 6 1.71 52 1.67 84
## 7 1.57 61 1.53 52
## 8 1.74 76 1.66 76
## 9 1.73 63 1.59 64
## 10 1.93 71.1 1.93 90
Summary statistics
## # A tibble: 1 x 5
## Count AvHeight SDHeight AvWeight SDWeight
## <int> <dbl> <dbl> <dbl> <dbl>
## 1 20 1.67 0.117 67.2 11.7
n n n
!2
2 1 X
Xi2
X X
(Xi − X̄) = − Xi
i=1 i=1 n i=1
n n n n
! !
X X 1 X X
(Xi − X̄)(Yi − Ȳ ) = Xi Yi − Xi Yi
i=1 i=1 n i=1 i=1
2
1. Calculate β̂1 and β̂0 .
n
1
(Xi − X̄)2 = 57.1214 − 1137.03842 = 0.26948
X
i=1 20
n
X 1
(Xi − X̄)(Yi − Ȳ ) = 2289.782 − (33.72)(1348) = 17.054
i=1 20
17.054
βˆ1 = = 63.28
0.26948
## # A tibble: 20 x 4
## X Y Fit Res
## <dbl> <dbl> <dbl> <dbl>
## 1 1.72 67 70.0 -2.98
## 2 1.66 66 66.3 -0.320
## 3 1.59 67 62.0 4.96
## 4 1.5 42 56.5 -14.5
## 5 1.78 83 73.6 9.35
## 6 1.71 52 69.4 -17.4
## 7 1.57 61 60.8 0.177
## 8 1.74 76 71.2 4.79
## 9 1.73 63 70.6 -7.60
## 10 1.93 71.1 82.8 -11.7
## 11 1.75 64 71.8 -7.82
## 12 1.55 65 59.6 5.40
## 13 1.61 75 63.3 11.7
## 14 1.65 70 65.7 4.29
## 15 1.61 55.4 63.3 -7.87
## 16 1.67 84 66.9 17.1
## 17 1.53 52 58.4 -6.38
## 18 1.66 76 66.3 9.68
## 19 1.59 64 62.0 1.96
## 20 1.93 90 82.8 7.19
3
3. Calculate SSE/R, df, MSE/R = σ̂ 2 , RMSE/R = σ̂
n
res2i = 1895.16
X
SSE =
i=1
df = n − 2 = 20 − 2 = 18
M SE = 1895.16/18 = 105.2867
√
RM SE = 105.2867 = 10.26093
s
1
SE(β1 ) = 10.26093 = 19.76621; df = 37
(20 − 1)(0.1190931)2
v
1 (1.686)2
u
u
SE(β0 ) = 10.26093t + = 33.40472; df = 18
20 (20 − 1)(0.1190931)2
6. There is strong evidence of a relationship between mass and height for the APES
honours 2024 stats class (slope: two-sided t18 = 3.2; p = 0.004).
Scope of inference.
4
R to make life easier (yes, R can do that sometimes)
library(Sleuth3)
library(tidyverse)