Reading: Chapter 2 – Shumway and Stoffer
Today¶
Simple and multiple linear regression¶
Last time we spoke about regression models where we have just two parameters, and :
For example, is height of an adult and is the height of their parent, or is the price of chicken and is time.
However, often we have multiple independent series that may be contributing to . We can then express this through Multiple Linear Regression
Here we will still be estimating .
We can do this by rewriting the equation above as:
for . To add an intercept, we can redefine each vector so that it has a 1 prepended to it:
Now, the first entry of will be the intercept, while the rest are the coefficients for each .
We now have the least squares problem:
We can then set the derivatives equal to zero to obtain:
Matrix notation¶
We can also write this equation in a more general matrix form:
Here might represent the number of time points and is the number of parameters. We can then write our least squares problem as:
Recall that the norm of a vector is defined as . Then, we can solve to get an estimate of :
An important note here is that we assume that the columns of (sometimes called our features) are linearly independent. This can only happen for - where we have no more features than samples. Otherwise, will not have an inverse, but we will be able to deal with this using regularization (which we will cover later).
Finger tapping demo¶
Next we will try collecting some data in class and fitting a multiple linear regression model to the data. We will collect data based on a finger tapping task, which is sometimes used as a clinical diagnostic tool to assess fine motor speed, coordination, and brain function. For these tests, typically the experimenter assesses the number of taps that a person makes over a given period of time. As you might imagine, we can also look at whether the number of taps is fairly steady over time, or whether the person is showing some fatigue (slowing down their taps over time).
We will use the following website to test your finger taps, then analyze the resulting data.
We will also chat about what external factors might influence the data and which might make the most sense to add to our model predicting the data.