Inference for regression

cont’d

Prof. Maria Tackett

Sep 24, 2024

Announcements

  • Project

    • Research questions due Thursday at 11:59pm

    • Proposal due Thursday, October 3 at 11:59pm

  • Lab 03 due Thursday, October 3 at 11:59pm

  • Statistics experience due Tue, Nov 26 at 11:59pm

Topics

  • Understand statistical inference in the context of regression

  • Describe the assumptions for regression

  • Understand connection between distribution of residuals and inferential procedures

  • Conduct inference on a single coefficient

  • Conduct inference on the overall regression model

Computing setup

# load packages
library(tidyverse)  
library(tidymodels)  
library(knitr)       
library(kableExtra)  
library(patchwork)   

# set default theme in ggplot2
ggplot2::theme_set(ggplot2::theme_bw())

Data: NCAA Football expenditures

Today’s data come from Equity in Athletics Data Analysis and includes information about sports expenditures and revenues for colleges and universities in the United States. This data set was featured in a March 2022 Tidy Tuesday.

We will focus on the 2019 - 2020 season expenditures on football for institutions in the NCAA - Division 1 FBS. The variables are :

  • total_exp_m: Total expenditures on football in the 2019 - 2020 academic year (in millions USD)

  • enrollment_th: Total student enrollment in the 2019 - 2020 academic year (in thousands)

  • type: institution type (Public or Private)

football <- read_csv("data/ncaa-football-exp.csv")

Univariate EDA

Bivariate EDA

Regression model

exp_fit <- lm(total_exp_m ~ enrollment_th + type, data = football)
tidy(exp_fit) |>
  kable(digits = 3)
term estimate std.error statistic p.value
(Intercept) 19.332 2.984 6.478 0
enrollment_th 0.780 0.110 7.074 0
typePublic -13.226 3.153 -4.195 0


For every additional 1,000 students, we expect the institution’s total expenditures on football to increase by $780,000, on average, holding institution type constant.

Inference for regression

Statistical inference

  • Statistical inference provides methods and tools so we can use the single observed sample to make valid statements (inferences) about the population it comes from

  • For our inferences to be valid, the sample should be representative (ideally random) of the population we’re interested in

Image source: Eugene Morgan © Penn State

Inference for linear regression

  • Inference based on ANOVA

    • Hypothesis test for the statistical significance of the overall regression model

    • Hypothesis test for a subset of coefficients

  • Inference for a single coefficient βj

    • Hypothesis test for a coefficient βj

    • Confidence interval for a coefficient βj

Linear regression model

y=Model+Error=f(X)+ϵ=E(y|X)+ϵ=Xβ+ϵ

  • We have discussed multiple ways to find the least squares estimates of β=[β0β1]

    • None of these approaches depend on the distribution of ϵ
  • Now we will use statistical inference to draw conclusions about β that depend on particular assumptions about the distribution of ϵ

Linear regression model

y|X∼N(Xβ,σϵ2I)

Image source: Introduction to the Practice of Statistics (5th ed)

Expected value of y

Let b=[b1⋮bp] be a p×1 vector of random variables.


Then E(b)=E[b1⋮bp]=[E(b1)⋮E(bp)]


Use this to find E(y|X).

Variance

Let b=[b1⋮bp] be a p×1 vector of independent random variables.


Then Var(b)=[Var(b1)0…00Var(b2)…0⋮⋮…⋅00…Var(bp)]


Use this to find Var(y|X).

Assumptions of regression

y|X∼N(Xβ,σϵ2I)

Image source: Introduction to the Practice of Statistics (5th ed)
  1. Linearity: There is a linear relationship between the response and predictor variables.
  2. Constant Variance: The variability about the least squares line is generally constant.
  3. Normality: The distribution of the residuals is approximately normal.
  4. Independence: The residuals are independent from one another.

Estimating σϵ2

  • Once we fit the model, we can use the residuals to estimate σϵ2

  • σ^ϵ2 is needed for hypothesis testing and constructing confidence intervals for regression

σ^ϵ2=∑i=1n(yi−y^i)2n−p−1=∑i=1nei2n−p−1=SSRn−p−1

  • The regression standard error σ^ϵ is a measure of the average distance between the observations and regression line

σ^ϵ=SSRn−p−1

Inference for a single coefficient

Inference for βj

We often want to conduct inference on individual model coefficients

  • Hypothesis test: Is there a linear relationship between the response and xj?

  • Confidence interval: What is a plausible range of values βj can take?

But first we need to understand the distribution of β^j

Sampling distribution of β^j

β^∼N(β,σϵ2(XTX)−1)

Let C=(XTX)−1. Then, for each coefficient β^j,

  • E(β^j)=βj, the jth element of β

  • Var(β^j)=σϵ2Cjj

  • Cov(β^i,β^j)=σϵ2Cij

Hypothesis test for βj

Steps for a hypothesis test

  1. State the null and alternative hypotheses.
  2. Calculate a test statistic.
  3. Calculate the p-value.
  4. State the conclusion.

Hypothesis test for βj: Hypotheses

We will generally test the hypotheses:

  • Null Hypothesis: H0:βj=0

    • There is no linear relationship between βj and y after accounting for the other variables in the model
  • Alternative hypothesis: Ha:βj≠0

    • There is a linear relationship between βj and y after accounting for the other variables in the model

Hypothesis test for βj: Test statistic

Test statistic: Number of standard errors the estimate is away from the null hypothesized value

Test Statstic=Estimate - NullStandard error


T=β^j−0SE(β^j) = β^j−0σ^ϵ2Cjj ∼ tn−p−1

Hypothesis test for βj: P-value

The p-value is the probability of observing a test statistic at least as extreme (in the direction of the alternative hypothesis) from the null value as the one observed

p−value=P(|t|>|test statistic|),

calculated from a t distribution with n−p−1 degrees of freedom

Understanding the p-value

Magnitude of p-value Interpretation
p-value < 0.01 strong evidence against H0
0.01 < p-value < 0.05 moderate evidence against H0
0.05 < p-value < 0.1 weak evidence against H0
p-value > 0.1 effectively no evidence against H0

These are general guidelines. The strength of evidence depends on the context of the problem.

Hypothesis test for βj: Conclusion

There are two parts to the conclusion

  • Make a conclusion by comparing the p-value to a predetermined decision-making threshold called the significance level ( α level)

    • If p-value<α: Reject H0

    • If p-value≥α: Fail to reject H0

  • State the conclusion in the context of the data

Application exercise

📋 https://sta221-fa24.netlify.app/ae/ae-03-inference

Confidence interval for βj

Confidence interval for βj

  • A plausible range of values for a population parameter is called a confidence interval

  • Using only a single point estimate is like fishing in a murky lake with a spear, and using a confidence interval is like fishing with a net

    • We can throw a spear where we saw a fish but we will probably miss, if we toss a net in that area, we have a good chance of catching the fish

    • Similarly, if we report a point estimate, we probably will not hit the exact population parameter, but if we report a range of plausible values we have a good shot at capturing the parameter

What “confidence” means

  • We will construct C% confidence intervals.

    • The confidence level impacts the width of the interval


  • “Confident” means if we were to take repeated samples of the same size as our data, fit regression lines using the same predictors, and calculate C% CIs for the coefficient of xj, then C% of those intervals will contain the true value of the coefficient βj


  • Balance precision and accuracy when selecting a confidence level

Confidence interval for βj

Estimate± (critical value) ×SE


β^1±t∗×SE(β^j)

where t∗ is calculated from a t distribution with n−p−1 degrees of freedom

Confidence interval: Critical value

# confidence level: 95%
qt(0.975, df = nrow(football) - 2 - 1)
[1] 1.97928


# confidence level: 90%
qt(0.95, df = nrow(football) - 2 - 1)
[1] 1.657235


# confidence level: 99%
qt(0.995, df = nrow(football) - 2 - 1)
[1] 2.61606

95% CI for βj: Calculation

term estimate std.error statistic p.value
(Intercept) 19.332 2.984 6.478 0
enrollment_th 0.780 0.110 7.074 0
typePublic -13.226 3.153 -4.195 0

95% CI for βj in R

tidy(exp_fit, conf.int = TRUE, conf.level = 0.95) |> 
  kable(digits = 3)
term estimate std.error statistic p.value conf.low conf.high
(Intercept) 19.332 2.984 6.478 0 13.426 25.239
enrollment_th 0.780 0.110 7.074 0 0.562 0.999
typePublic -13.226 3.153 -4.195 0 -19.466 -6.986


Interpretation: We are 95% confident that for each additional 1,000 students enrolled, the institution’s expenditures on football will be greater by $562,000 to $999,000, on average, holding institution type constant.

Test for overall significance

Test for overall significance: Hypotheses

We can conduct a hypothesis test using the ANOVA table to determine if there is at least one non-zero coefficient in the model

H0:β1=⋯=βp=0Ha:βj≠0 for at least one j

For the football data

H0:β1=β2=0Ha:βj≠0 for at least one j

Test for overall significance: Test statistic

Source Df Sum Sq Mean Sq F Stat Pr(> F)
Model 2 7138.591 3569.296 26.628 0
Residuals 124 16621.344 134.043
Total 126 23759.935


Test statistic: Ratio of explained to unexplained variability

F=Mean Square ModelMean Square Residuals

The test statistic follows an F distribution with p and n−p−1 degrees of freedom

Test for overall significance: P-value

P-value=Pr(F>F Stat)

Test for overall significance: Conclusion

H0:β1=β2=0Ha:βj≠0 for at least one j

football_anova |>
  kable(digits = 3)
Source Df Sum Sq Mean Sq F Stat Pr(> F)
Model 2 7138.591 3569.296 26.628 0
Residuals 124 16621.344 134.043
Total 126 23759.935

What is the conclusion from this hypothesis test?

Recap

  • Introduced statistical inference in the context of regression

  • Described the assumptions for regression

  • Connected the distribution of residuals and inferential procedures

  • Conducted inference on a single coefficient

  • Conducted inference on the overall regression model

🔗 STA 221 - Fall 2024

1 / 41
Inference for regression cont’d Prof. Maria Tackett Sep 24, 2024

  1. Slides

  2. Tools

  3. Close
  • Inference for regression
  • Announcements
  • Topics
  • Computing setup
  • Data: NCAA Football expenditures
  • Univariate EDA
  • Bivariate EDA
  • Regression model
  • Inference for regression
  • Statistical inference
  • Inference for linear regression
  • Linear regression model
  • Linear regression model
  • Expected value of y
  • Variance
  • Assumptions of regression
  • Estimating σϵ2
  • Inference for a single coefficient
  • Inference for βj
  • Sampling distribution of β^j
  • Hypothesis test for βj
  • Steps for a hypothesis test
  • Hypothesis test for βj: Hypotheses
  • Hypothesis test for βj: Test statistic
  • Hypothesis test for βj: P-value
  • Understanding the p-value
  • Hypothesis test for βj: Conclusion
  • Application exercise
  • Confidence interval for βj
  • Confidence interval for βj
  • What “confidence” means
  • Confidence interval for βj
  • Confidence interval: Critical value
  • 95% CI for βj: Calculation
  • 95% CI for βj in R
  • Test for overall significance
  • Test for overall significance: Hypotheses
  • Test for overall significance: Test statistic
  • Test for overall significance: P-value
  • Test for overall significance: Conclusion
  • Recap
  • f Fullscreen
  • s Speaker View
  • o Slide Overview
  • e PDF Export Mode
  • r Scroll View Mode
  • b Toggle Chalkboard
  • c Toggle Notes Canvas
  • d Download Drawings
  • ? Keyboard Help