Is there a relationship between officer height (x) and report accuracy (y)?
height_cm
report_accuracy
198
75.5
129
82.7
89
78.0
Example 2
Is there a relationship between officer height (x) and report accuracy (y)?
Constructing the model,
m2 <-glm(report_accuracy ~ height_cm, data = reports)m2 |>coefficients()
(Intercept) height_cm
80.430106777 0.009226122
Example 2
Checking assumptions,
m2 |>reg_check()
Statistical Inference in Linear Regression
Once we confirm that our residuals follow a normal distribution, we begin to make inference.
Omnibus test for the model.
Individual predictor tests.
Confidence intervals for \beta_i.
If the residuals do not follow a normal distribution with mean 0 and some common variance, \sigma^2, we do not follow our modeling up with formal hypothesis tests.
Confidence Intervals for \beta_i
Like all statistics, we can put a confidence interval on \beta_i.
When reporting regression results, I always include the corresponding CI.
Practice time is a significant predictor of exam score (p < 0.001).
Example 3
Returning to our third example,
m3 |>tidy(conf.int =TRUE)
term
estimate
std.error
statistic
p.value
conf.low
conf.high
(Intercept)
142.694320
59.0211593
2.417681
0.0209643
27.014973
258.373666
advertising_dollars
1.734312
0.2930268
5.918610
0.0000010
1.159990
2.308634
foot_traffic
1.383370
0.0901519
15.344879
0.0000000
1.206676
1.560065
temperature_c
8.607033
1.9711721
4.366454
0.0001068
4.743606
12.470459
discount_percent
11.922056
1.5012304
7.941523
0.0000000
8.979698
14.864413
All predictors are significant (all p < 0.001).
Example 4
A cafe owner in Savanna Central brings you a spreadsheet: “We’ve been tracking everything! Can you help us figure out which of these are related to sales?”
We have collected data from 40 days to answer the following question:
Which of the five explanatory variables are associated with daily cafe sales after accounting for the other variables?
advertising_dollars
foot_traffic
temperature_c
music_volume_db
window_display_hours
sales_dollars
16.46
239
25.3
66.7
3.5
639.90
16.97
398
17.5
52.7
2.0
1018.52
28.16
123
18.6
53.9
10.1
438.26
Example 4
Constructing the model,
Which of the five explanatory variables are associated with daily cafe sales after accounting for the other variables?