Under the null \((\beta_1 = 0)\) the t-statistic \((\hat\beta_1/se_{\hat\beta_1})\) has a t-distribution with \(n-2\) degrees of freedom.
What t statistic did we observe?
Call:
lm(formula = battery_percent ~ screen_time, data = data_sample)
Residuals:
Min 1Q Median 3Q Max
-48.166 -16.846 1.795 18.387 51.194
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 86.23349 11.85438 7.274 2.4e-08 ***
screen_time -0.10986 0.04851 -2.265 0.0302 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 24.36 on 33 degrees of freedom
Multiple R-squared: 0.1345, Adjusted R-squared: 0.1083
F-statistic: 5.129 on 1 and 33 DF, p-value: 0.03022
The probability of observing a statistic as extreme or more extreme than the observed test statistic given the null hypothesis is true
null$color <- ifelse(null$t < 2.265 & null$t > -2.265, "out", "in")
ggplot(null, aes(t, fill = color)) +
geom_histogram(bins = 30) +
geom_textvline(xintercept = c(2.265), label = "observed t statistic") +
geom_textvline(xintercept = c(-2.265), label = "observed t statistic (flipped)") +
theme(legend.position = "none")
The proportion of area greater than 2.265
null$color <- ifelse(null$t < 2.265 & null$t > -2.265, "out", "in")
ggplot(null, aes(t, fill = color)) +
geom_histogram(bins = 30) +
geom_textvline(xintercept = c(2.265), label = "observed t statistic") +
geom_textvline(xintercept = c(-2.265), label = "observed t statistic (flipped)") +
theme(legend.position = "none")
The proportion of area less than -2.265
null$color <- ifelse(null$t < 2.265 & null$t > -2.265, "out", "in")
ggplot(null, aes(t, fill = color)) +
geom_histogram(bins = 30) +
geom_textvline(xintercept = c(2.265), label = "observed t statistic") +
geom_textvline(xintercept = c(-2.265), label = "observed t statistic (flipped)") +
theme(legend.position = "none")
The proportion of area greater than 2.265 or less than -2.265
null$color <- ifelse(null$t < 2.265 & null$t > -2.265, "out", "in")
ggplot(null, aes(t, fill = color)) +
geom_histogram(bins = 30) +
geom_textvline(xintercept = c(2.265), label = "observed t statistic") +
geom_textvline(xintercept = c(-2.265), label = "observed t statistic (flipped)") +
theme(legend.position = "none")
The proportion of area greater than 2.265 or less than -2.265
null$color <- ifelse(null$t < 2.265 & null$t > -2.265, "out", "in")
ggplot(null, aes(t, fill = color)) +
geom_histogram(bins = 30) +
geom_textvline(xintercept = c(2.265), label = "observed t statistic") +
geom_textvline(xintercept = c(-2.265), label = "observed t statistic (flipped)") +
theme(legend.position = "none")