RaukR 2026 • Data Science With R
Dania Machlab
18-Aug-2026

Caroline Uhler
Davide Risso
Mireia Ramos-Rodríguez
Luca Giorgetti
Daria Lazic








“Statistical learning refers to a set of tools for making sense of complex datasets” – An Introduction to Statistical Learning by James, Witten, Hastie and Tibshirani
Many of these methods were developed long before we had computers, and they are incredibly useful today.
No single methods will perform well or be appropriate for all data set. It is therefore important to understand how these tools work, when to use them and how to interpret the results.
“We are drowning in information and starving for knowledge” – Rutherford D. Roger as quoted in Elements of Statistical Learning

Suppose we have measurements for \(p\) variables \(x_1, x_2 ... x_p\) and their associated variable \(y\) and wish to say something about how \(x_1, x_2 ... x_p\) explain or relate to \(y\). An example is prediction or classification.
\(y \sim f(x)\)


Training data vs test data
Trade off between prediction accuracy and model interpretability





\(y = f(x) + \epsilon\)
\(y\) is often called the response or dependent variable
\(x\) is often called the predictor or independent variable
\(\epsilon\) is the random error term
Statistical learning refers to a set of approaches for estimating \(f\)
Simple linear model: \(y = \beta_0 + \beta_1x + \epsilon\)
By the 1970s many methods for learning from the data were available. The vast majority of them were linear methods because fitting non-linear relationships was computationally difficult at the time.
Having a good understanding of linear models is essential for understanding non-linear ones. Many of the latter are generalizations of the linear methods.
Powerful in their interpretability and in their flexibility
If we are interested in inference then retaining interpretability is key


learn the association between a single predictor \(x\) and a quantitative response \(y\).
assumes an approximately linear relationship between \(x\) and \(y\).
\[y = \beta_0 + \beta_1x + \epsilon\]

The residual sum of squares (RSS) is defined as \(RSS=\sum_{i=1}^Ne_i^2\)
We want to choose beta estimates which minimize the RSS. This is the least squares method.
Least squares was developed at the beginning of the 19th century (earliest form of linear regression), with applications in astronomy.



\[y = \beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_4x_5 + \epsilon\]
\[y = \beta_0 + \beta_1x_1 + \beta_2x_2^2 + \beta_3\sqrt{x_3} + \epsilon\]
\[log2(y) = \beta_0 + \beta_1x_1 + \beta_2x_2^2 + \beta_3\sqrt{x_3} + \epsilon\]
\[y = \beta_0 e^{\beta_1x} + \epsilon\]
\[y = \beta_0 + \beta_1e^{x} + \epsilon\]
\[y = \beta_0 + sin(\beta_1x) + \epsilon\]
Call:
lm(formula = sales ~ TV + radio + newspaper, data = advertisingData)
Coefficients:
(Intercept) TV radio newspaper
2.938889 0.045765 0.188530 -0.001037
Call:
lm(formula = sales ~ TV + radio + newspaper, data = advertisingData)
Coefficients:
(Intercept) TV radio newspaper
2.938889 0.045765 0.188530 -0.001037

\(y = \beta_0 + \beta_1x_1 + \beta_2x_2 + ... + \beta_px_p + \epsilon\)
Income Limit Rating Cards Age Education Own Student Married Region Balance
1 14.891 3606 283 2 34 11 No No Yes South 333
2 106.025 6645 483 3 82 15 Yes Yes Yes West 903
3 104.593 7075 514 4 71 11 No No No West 580
4 148.924 9504 681 3 36 11 Yes No No West 964
5 55.882 4897 357 2 68 16 No No Yes South 331
6 80.180 8047 569 4 77 10 No No No South 1151




Please follow sections 1 to 5 in the lab. Read carefully and try to answer the sections marked as Task.


\(RSS=\sum_{i=1}^Ne_i^2\)

\[y = \beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_3 + \beta_4x_4 + \beta_5x_5 + \epsilon\]
\[ \hat{\beta}=\min\limits_{\beta}\{\sum_{i=1}^N (y_i - \beta_0 - \sum_{j=1}^px_{ij}\beta_j)^2 + \lambda \sum_{j=1}^p\beta_j^2 \} \]



glmnet
[1] 39.65627
[1] 63.144
\[ \hat{\beta}=\min\limits_{\beta}\{\frac{1}{2}\sum_{i=1}^N (y_i - \beta_0 - \sum_{j=1}^px_{ij}\beta_j)^2 + \lambda \sum_{j=1}^p|\beta_j| \} \]
[1] 0.7784687
[1] 15.28166
What do you think the method does when 2 predictors \(x_1\) and \(x_2\) are highly correlated to each other?
Is this problematic?
Collinearity within the predictor matrix:


\[ \lambda \sum_{j=1}^p(\alpha|\beta_j| + (1-\alpha)\beta_j^2) \]

\[ \hat{\beta}=\min\limits_{\beta} (||y-X\beta||_2^2 + \lambda \sum_{j=1}^p\frac{|\beta_j|}{W_j} ) \]





limma’s normalizeCyclicLoess()


\[y_{observed} = \beta_0 + \beta_{biology}x_{biology} + \beta_{batch}x_{batch} + \epsilon\]
\[y_{corrected} = \beta_0 + \beta_{biology}x_{biology} + \epsilon\]
or
\[y_{corrected} = y_{observed} - \beta_{batch}x_{batch}\]
glmnet allows you to specify other distribution families that better match the response.

An Introduction to Statistical Learning with applications in R – Gareth James, Daniela Witten, Trevor Hastie and Robert Tibshirani

The Elements of Statistical Learning – Trevor Hastie, Robert Tibshirani and Jerome Friedman

“The quiet statisticians have changed our world; not by discovering new facts or technical developments, but by changing the ways that we reason, experiment and form our opinions.”
– Ian Hacking
“Many of us are drawn to the field of statistics because we are natural-born skeptics. Through our statistical training, we become more skeptical still. Our experience—both personal and professional—has taught us that if something seems too good to be true, then it probably is. We seek the simplest possible answer to every question, and no simpler. After all, statistics is hard. The key is to enjoy the challenge.”
– Daniela Witten & Rob Tibshirani