Class 16: Practice Linear Models

Methodology of Scientific Research

Andrés Aravena, PhD

April 5, 2023

Linear models

Deciding the model formula

The hard part is to decide

  • What is the dependent variable
    • The values that we want to predict
    • The vertical axis
  • What are the independent variables
    • The values that we can control
    • The horizontal axis
  • What is the formula connecting them

Our model

Here we are using a linear model \[y=β_0 + β_1\cdot x\] In the example of last class, we have \[\text{time} = β_0 + β_1\cdot \text{volume}\]

\(β_0\) and \(β_1\) are the coefficients of the model

Which are the best \(β_0\) and \(β_1\) values?

The best straight line

We find the best coefficients by minimizing the squared error \[\begin{aligned} β_0 &= \overline{𝐲} - β_1 \overline{𝐱}\\ β_1 &= \frac{\text{cov}(𝐱, 𝐲)}{\text{var}(𝐱)} \end{aligned}\] Finding the best coefficients is called “fitting the model to the data”

An experiment

Coils and Rubber bands

  • Coils and rubber bands have a natural size
  • If you apply a force to them, they expand
  • What is the relation between the expansion and the force?

Robert Hooke said it first

Robert Hooke (1635–1703) was an English natural philosopher, architect and polymath.

In 1660, Hooke discovered the law of elasticity which describes the linear variation of tension with extension

“The extension is proportional to the force”

Robert Hooke

Natural philosophy was the study of nature and the physical universe that was dominant before the development of modern science

Polymath (from Greek “having learned much”) is a person whose expertise spans a significant number of different subject areas

Biologist. Hooke used the microscope and was the fists to use the term cell for describing biological organisms.

How do we model a coil?

The essence of the coil is:

  • It has a natural length \(L\)
  • If we change the length by \(x\), it pulls with a force \[\text{force}(x)= K \cdot (L-x)\]

Doing the experiment


n_balls length repetition
0 78.00 1
1 82.61 1
2 85.85 1
3 90.26 1
4 95.05 1
0 79.21 2
2 85.55 2

The table shows only part of the data.
Get all data at

Graphic Results

Best-fit line

Remember that straight lines can be represented by the formula \[\text{length} = β_0 + β_1 \cdot \text{n_balls}\] The coefficient \(β_0\) is the value where the line intercepts the vertical axis

The coefficient \(β_1\) is how much length goes up when n_marbles increases. This is called slope

Physical interpretation of the linear model

The formula from Hooke’s Law is “\(\text{force}=K\cdot(L-\text{length})\)”.

Since force is the weight of the balls, we can write \[-m g\cdot\text{n_balls}=K\cdot(L-\text{length})\] which can be re-written as \[\text{length}=\underbrace{L}_{β_0}+\underbrace{\frac{m g}{K}}_{β_1}\cdot\text{n_balls}\]

Physical interpretation of coefficients

When there are no balls, the length of the coil is \(L\), in this case \[L = β_0\] If we assume that the mass of each ball is 20gr, we can find \(K\) as \[K = \frac{β_1}{0.020 \cdot 9.8}\]

Balls weight \(\approx 21\pm 0.5\) grams