Intro to Linear Models
BioData Training School 2025
December 10-13, 2025, Tirana, Albania
Overview
▪ One and two-way ANOVA
▪ Multiple linear regression
▪ Fitting the model
▪ Checking the assumptions
▪ Assessing model performance
The problem
▪ We want to investigate the relationship between cholesterol levels and several
predictors, including systolic blood pressure (SBP), diastolic blood pressure
(DBP), age, BMI, race, and gender. The goal is to determine how these factors
influence cholesterol levels and assess the strength of their associations.
What is the purpose of fitting a model?
▪ To explain the relationship between the response and the
predictors.
▪ To predict the response based on the predictors. Often, a
good model will do both.
One-way ANOVA as a linear model
One-Way ANOVA tests whether the means of k groups are
equal.
It can be expressed as a linear regression model with
categorical predictors.
𝑌𝑖 :response variable
𝑌𝑖 = 𝛽0 + 𝛽1 𝑋1𝑖 + 𝛽2 𝑋2𝑖 + ⋯ + 𝛽𝑘−1 𝑋 𝑘−1 𝑖 + 𝜀𝑖 𝑋𝑔𝑖 :dummy variables for group
membership
𝛽0 :mean of reference group
𝛽𝑔 :difference between group 𝑔and
ANOVA F-test = test that all 𝛽1 = ⋯ = 𝛽𝑘−1 = 0
reference
𝜀𝑖 ∼ 𝑁 0 𝜎 2
Two-way ANOVA as a linear model
Two-Way ANOVA evaluates effects of Factor A, Factor B, and
their interaction.
Also fits naturally in a linear model framework.
• Main effects: Do levels of A or B
𝑌𝑖𝑗 = 𝛽0 + 𝛼𝑎 + 𝛽𝑏 + ቀ𝛼𝛽)𝑎𝑏 + 𝜀𝑖𝑗 change the mean outcome?
• Interaction: Does the effect of A
depend on B?
• F-tests compare each set of
coefficients to 0.
Multiple Linear regression
• When there are two or more independent
variables used in the regression analysis, the
model is not simply linear but a multiple
regression model.
• Y is always continuous
• The covariates X can be:
• Continuous variable (age, weight, etc.)
• Dummy variables coding a categorical
covariate.
Significance and interpretation of
coefficients
• The coefficients can be interpreted after testing their
significance.
• If the independent variable Xi increases by one unit and all
other predictors are constant, the dependent variable Y
increases by βi.
Checking the assumptions
1. Linear relationship between the dependent and the
independent variables.
2. Multicollinearity, no strong correlation between independent
variables.
3. Residual values are normally distributed
4. Homoscedasticity assumes that the variance of the residual
errors is similar across the values of each independent
variable.
Check model performance
• Coefficient of determination R-Square
R-squared is the proportion of the variance in
the response variable that can be explained by
the predictor variables.
• Root mean squared error
yi are the actual values of the response
yi are the predicted values using the fitted model
Linear models step by step in R
Go to Practical_LinearModels R notebook