Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Matrix calculus

Introduction

Statistics is meant to impart structure to observations in nature and many times the observations that we. are interested in contain many different pieces of information. For example, when studying the relationship between patients randomized in a clinical trial we may be interested in, for each patient, their age, sex, race, body mass index, and whether or not they attain the outcome of interest. Then every observation (a patient) contains five pieces of information. We can think of this observation as living in a single, 5-dimensional space.

Mathematical objects that keep track of values in 1, 2, 3, and higher dimensional spaces are called vectors, and linear maps that take as input one vector and produce a second vector are called matrices. The rules for operating with vectors and matrices is called matrix calculus.

Because we wish to structure observations with many pieces of information it is natural that statistics rely on matrix calculus.

Vectors

Definition

Define the set of all real numbers (positive, negative, and decimal numbers) with the symbol R\mathbb{R}, and further define the Cartesian product of the set of real numbers with itself as R2=R×R\mathbb{R}^{2} = \mathbb{R} \times \mathbb{R}. In general the Cartesian produce of R\mathbb{R} with itself NN times can be denoted as RN\mathbb{R}^{N}.

We will informally define a vector of length NN as a point in the space RN\mathbb{R}^{N}. A vector is typically represented as a lowercase letter and the values of the vector are enclosed in square brackets.

For the space R2\mathbb{R}^{2} we can define the vector

a=[32]a = \begin{bmatrix} 3\\ 2 \end{bmatrix}

or the vector

c=[0.1−23.01]c = \begin{bmatrix} 0.1\\ -23.01 \end{bmatrix}

For a space R6\mathbb{R}^{6} we could define a vector

v=[01−83.2−0.71]v = \begin{bmatrix} 0\\ 1\\ -8\\ 3.2\\ -0.7\\ 1 \end{bmatrix}

Vectors can be characterized by their length. The length of a vector is the number of values that are needed to define it. The vector aa and cc have a length of 2 and the vector vv has a length of 6.

Though it is possible to discuss vectors of length one, more often we give these objects their own name and special properties. A vector of length one is called a scalar. Scalars do not need to be enclosed by square brackets.

In any of the spaces RNR^{N} for N>1N>1 examples of scalars are 6, -0.4, 0,1, 22, etc.

Addition and subtraction

There are specific rules for how two vectors can interact with one another. You can add and subtract vectors, and you can multiply vectors by a scalar. Addition, subtraction; multiplication and division by a scalar all have a geometric interpretation.

To add two vectors you add the corresponding values in the first, second, third and so on position. You cannot add vectors of different lengths.

Let

x=[10−2]\begin{aligned} x = \begin{bmatrix} 1\\ 0\\ -2 \end{bmatrix} \end{aligned}

and

y=[0.52.0−2.0]\begin{aligned} y = \begin{bmatrix} 0.5\\ 2.0\\ -2.0 \end{bmatrix} \end{aligned}

Then

x+y=[1+0.50+2.0−2+(−2.0)]=[1.52.0−4.0]\begin{aligned} x + y = \begin{bmatrix} 1 + 0.5\\ 0 + 2.0\\ -2 + (-2.0) \end{bmatrix} = \begin{bmatrix} 1.5\\ 2.0\\ -4.0 \end{bmatrix} \end{aligned}

To subtract two vectors you subtract the corresponding values in the first, second, third and so on position. You cannot subtract vectors of different lengths.

x−y=[1−0.50−2.0−2−(−2.0)]=[0.5−2.00.0]\begin{aligned} x - y = \begin{bmatrix} 1 - 0.5\\ 0 - 2.0\\ -2 - (-2.0) \end{bmatrix} = \begin{bmatrix} 0.5\\ -2.0\\ 0.0 \end{bmatrix} \end{aligned}

Consider R2\mathbb{R}^{2}, the vector v=[xy]v = \begin{bmatrix} x \\ y \end{bmatrix} can be drawn on the Cartesian coordinate plane by starting at the origin (0,0)(0,0) and then drawing a straight line from the origin to the point (x,y)(x,y).

You can draw the addition of two vectors with a method nicknamed the "tip to tail" draw. Consider two vector labeled xx and yy. Draw the first vector xx starting at the origin. Draw the second vector starting, not at the origin, but at the tip of the first vector. The vector x+yx+y is the vector starting at the origin and ending at the tip of the second vector.

Multiplication and division by a scalar

A new vector vv can be built by multiplying or dividing a vector xx by a scalar α\alpha, v=αxv = \alpha x. The vector vv is built by multiplying each entry in xx by α\alpha.

v=α⋅x=α[x1x2⋮xn]=[α⋅x1α⋅x2⋮α⋅xn]\begin{aligned} v &= \alpha \cdot x\\ &= \alpha \begin{bmatrix} x_{1}\\ x_{2}\\ \vdots\\ x_{n} \end{bmatrix}\\ &= \begin{bmatrix} \alpha \cdot x_{1}\\ \alpha \cdot x_{2}\\ \vdots\\ \alpha \cdot x_{n} \end{bmatrix} \end{aligned}

Geometrically, when you multiply a vector by a scalar that is greater than one the vector is stretched. When diving by that scalar (or multiplying by a scalar between 0 and one) then the vector is compressed. When you multiply a vector by negative one that vector is rotated by 180 degrees. To multiply a vector by a scalar smaller than negative one first rotate the vector 180 degrees and then stretch the vector. A vector multiplied by a scalar between negative one and zero is rotated and then compressed.

Matrices

Definition

A matrix is a list of vectors and can be thought of as a function that transforms one vector to another. A matrix is often denoted as a capital letter and the values of a matrix are enclosed in square brackets.

We can build a matrix

A=[2−100.50.110]\begin{aligned} A = \begin{bmatrix} 2 & -1 & 0 \\ 0.5 & 0.1 & 10 \\ \end{bmatrix} \end{aligned}

Entries in a matrix AA can be referred to by row number and column number. For example the (2,1)(2,1) entry in the matrix AA is value 0.5. We can also refer to the (2,1) entry in the matrix AA as A(2,1)A_{(2,1)}

The shape of a matrix is a tuple that describes the number of rows of the matrix and the number of columns. The shape of the matrix AA above is (2,3)(2,3).

An important operation---called the transpose---interchanges rows and columns of a matrix. Define a matrix

B=[12234551]\begin{aligned} B = \begin{bmatrix} 1 & 2 \\ 2 & 3 \\ 4 & 5 \\ 5 & 1 \\ \end{bmatrix} \end{aligned}

with shape (4,2)(4,2). Then the transpose of BB, labeled B′B' or sometimes BtB^{t}, is the matrix with shape (2,4)(2,4) and where the first row of BB is the first column of B′B', the second row of BB is the second column of B′B', and so on.

B′=[12452351]\begin{aligned} B' = \begin{bmatrix} 1 & 2 & 4 & 5\\ 2 & 3 & 5 & 1 \end{bmatrix} \end{aligned}

If the matrix BB has shape (2,4)(2,4) then the matrix B′B' has shape (4,2)(4,2).

We can think of vectors as matrix where the number of rows equals the length of the vector and the number of columns equals one. This allows us to consider both a vector

r=[3210]\begin{aligned} r = \begin{bmatrix} 3\\ 2\\ 1\\ 0 \end{bmatrix} \end{aligned}

and a vector transpose r=[3,2,1,0]′r = [3, 2, 1, 0]'. A vector with several rows and one column is often called a column vector and a vector with several columns and one row is often called a row vector. The vector rr is an example of a column vector.

Like vectors, matrices can interact with other matrices and with vectors.

Matrix times vector

If the number of columns of a matrix MM is equal to the length of a vector vv then MM and vv can be multiplied together to produce another vector.

M⋅v=q\begin{aligned} M \cdot v=q \end{aligned}

If the shape of the matrix MM is (n,p)(n,p) and the vector vv is of length pp then the new vector qq will be of length nn.

The values of each entry in qq are combinations of individual rows in the matrix MM and the vector vv.

Let

M=[123456]\begin{aligned} M = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ \end{bmatrix} \end{aligned}

and

v=[0−3−2]\begin{aligned} v = \begin{bmatrix} 0\\ -3\\ -2 \end{bmatrix} \end{aligned}

To compute the first entry in qq we work with the first row of MM and the vector vv.

q1=M1,1⋅v1+M1,2⋅v2+M1,3⋅v3=1⋅0+2⋅(−3)+3⋅(−2)=0−6−6=−12\begin{aligned} q_{1} &= M_{1,1} \cdot v_{1} + M_{1,2} \cdot v_{2} + M_{1,3} \cdot v_{3} \\ &= 1 \cdot 0 + 2 \cdot (-3) + 3 \cdot (-2)\\ &= 0 -6 -6 = -12 \end{aligned}

where q1q_{1} denotes the first entry in qq, viv_{i} denotes the ithi^{th} entry in vv and Mi,jM_{i,j} denotes the (i,j)(i,j) entry in the matrix MM.

To compute the second entry in qq we work with the second row of MM and the vector vv, and so on.

q2=M2,1⋅v1+M2,2⋅v2+M2,3⋅v3=4⋅0+5⋅(−3)+6⋅(−2)=0−13−12=−25\begin{aligned} q_{2} &= M_{2,1} \cdot v_{1} + M_{2,2} \cdot v_{2} + M_{2,3} \cdot v_{3} \\ &= 4 \cdot 0 + 5 \cdot (-3) + 6 \cdot (-2)\\ &= 0 -13 -12 = -25 \end{aligned}

The new vector qq generated by multiplying MM and vv is the vector

q=[−12−25]\begin{aligned} q = \begin{bmatrix} -12\\ -25 \end{bmatrix} \end{aligned}

We could rewrite, if desired, the above vector qq as a scalar times a vector

q=−1[1225]\begin{aligned} q = -1\begin{bmatrix} 12\\ 25 \end{bmatrix} \end{aligned}

In general, given a matrix AA with shape (N,P)(N,P) and a vector bb with length PP, multiplying AbA b produces a new vector cc where

ci=∑kAi,k  bk\begin{aligned} c_{i} = \sum_{k} A_{i,k}\; b_{k} \end{aligned}

Because a matrix times a vector produces a new vector we can think of a matrix as a function. The input to our function is a vector (such as the vector vv) and the output is another vector (such as the vector qq above)

Matrices and vectors have special properties when interacting. A matrix can be "distributed" across two vectors Given a matrix MM and the vectors qq and rr, the matrix product

M(q+r)=Mq+Mr\begin{aligned} M (q + r) = M q + M r \end{aligned}

Scalars can be "factored" out of a matrix, vector multiplications. Let α\alpha be a scalar, then

M(αq)=α(Mq)\begin{aligned} M (\alpha q ) = \alpha \left(M q\right) \end{aligned}

Matrix-matrix operations

Addition and subtraction

Matrices of the same shape can be added and subtracted by adding (subtracting) corresponding entries.

Given the matrix

A=[−12−30−12]\begin{aligned} A = \begin{bmatrix} -1 & 2 & -3 \\ 0 & -1 & 2 \\ \end{bmatrix} \end{aligned}

and the matrix

B=[9871020.5]\begin{aligned} B = \begin{bmatrix} 9 & 8 & 7 \\ 10 & 2 & 0.5 \\ \end{bmatrix} \end{aligned}

then the (i,j)(i,j) entry of a new matrix C=A+BC = A + B is the sum of the (i,j)(i,j) entry in AA and (i,j)(i,j) entry in BB or

Cij=Aij+BijC_{ij} = A_{ij} + B_{ij}

The (i,j)(i,j) entry of a matrix D=A−BD = A - B is the difference of the (i,j)(i,j) entry in AA and (i,j)(i,j) entry in BB or

Dij=Aij−BijD_{ij} = A_{ij} - B_{ij}

Multiplication

A matrix AA can be multiplied by a matrix BB to produce a new matrix CC with the following formula

Cij=∑kAi,kBk,j\begin{aligned} C_{ij} = \sum_{k} A_{i,k} B_{k,j} \end{aligned}

Given a matrix

A=[01−12]\begin{aligned} A = \begin{bmatrix} 0 & 1 \\ -1 & 2 \\ \end{bmatrix} \end{aligned}

and a matrix

B=[1432]\begin{aligned} B = \begin{bmatrix} 1 & 4 \\ 3 & 2 \\ \end{bmatrix} \end{aligned}

The entry in the new matrix CC, in the (1,1) position is

C1,1=A1,1B1,1+A1,2B2,1=0(1)+1(3)=3\begin{aligned} C_{1,1} &= A_{1,1} B_{1,1} + A_{1,2} B_{2,1}\\ &= 0 (1) + 1 (3) = 3 \end{aligned}

C1,2=A1,1B1,2+A1,2B2,2=0(4)+1(2)=2\begin{aligned} C_{1,2} &= A_{1,1} B_{1,2} + A_{1,2} B_{2,2}\\ &= 0 (4) + 1 (2) = 2 \end{aligned}

C2,1=A2,1B1,1+A2,2B2,1=−1(1)+2(3)=5\begin{aligned} C_{2,1} &= A_{2,1} B_{1,1} + A_{2,2} B_{2,1}\\ &= -1 (1) + 2 (3) = 5 \end{aligned}

C2,2=A2,1B1,2+A2,2B2,2=−1(4)+2(2)=0\begin{aligned} C_{2,2} &= A_{2,1} B_{1,2} + A_{2,2} B_{2,2}\\ &= -1 (4) + 2 (2) = 0 \end{aligned}

C=[3250]\begin{aligned} C = \begin{bmatrix} 3 & 2 \\ 5 & 0 \end{bmatrix} \end{aligned}

The above operation for computing an entry in CC occurs frequently in matrix calculus. This operation is called an inner product. The inner product of the vector vv of length nn and the vector qq of length nn is equal to

v′q=∑k=1nvkqk\begin{aligned} v'q = \sum_{k=1}^{n} v_{k}q_{k} \end{aligned}

We can think of the matrix AA as consisting of 2 row vectors, the vectors A1,:=[0,1]A_{1,:} = [0,1] and A2,:=[−1,2]A_{2,:} = [-1, 2], and the matrix BB as consisting of two column vectors

B:,1=[13]\begin{aligned} B_{:,1} = \begin{bmatrix} 1 \\ 3 \end{bmatrix} \end{aligned}

and

B:,2=[42]\begin{aligned} B_{:,2} = \begin{bmatrix} 4 \\ 2 \end{bmatrix} \end{aligned}

Then the matrix Ci,j=Ai,:B:,jC_{i,j} = A_{i,:} B_{:,j} or

C=[A1,:′B:,1A1,:′B:,2A2,:′B:,1A2,:′B:,2]\begin{aligned} C = \begin{bmatrix} A_{1,:}' B_{:,1} & A_{1,:}' B_{:,2} \\ A_{2,:}' B_{:,1} & A_{2,:}' B_{:,2} \\ \end{bmatrix} \end{aligned}

Important: The matrix product ABAB is not necessarily equal to the matrix product BABA. For matrix multiplication, the order of multiplication matters.

The matrix inverse

There exists a special matrix called identity matrix. The identity matrix II of size nn is a matrix with nn rows and nn columns with ones along the diagonal entries (the entries Ik,kI_{k,k} for kk from 1 to nn) and then zeroes for all other entries.

I2=[1001]I3=[100010001]\begin{aligned} I_{2} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\\ I_{3} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \end{aligned}

A matrix AA has an inverse BB if (i) AA has the same number of rows as columns and (ii)

AB=IBA=I\begin{aligned} AB = I \\ BA = I \end{aligned}

A matrix BB that satisfies the above properties is called the inverse of AA and is denoted A−1A^{-1}.

A matrix inverse is similar to an inverse in one dimensional algebra. In 1d algebra an inverse bb for the variable aa satisfies

ab=1ba=1\begin{aligned} ab = 1 \\ ba = 1 \end{aligned}

and the variable bb is denotes a−1a^{-1} or 1a\frac{1}{a}. Matrix with a different number of rows and columns will never have an inverse.

Multivariate Linear regression

Multivariate regression models are ubiquitous in science because of their ability to relate two or more measurable quantities to a target variable.

Multivariate linear regression supposes that many different covariates (x1,x2,⋯ ,xp)(x_{1}, x_{2}, \cdots, x_{p}) may be able to describe the distribution of a random variable YY.

Multivariate linear regression extends single covariate regression, and we will see below that adding more covariates makes estimating, as well as communicating, parameters more difficult.

Data and model setup

Multivariate linear regression supposes that an experiment generates a single data point that contains one measurement of our target of interest and two or more measurements of covariates (x1,x2,⋯ )(x_{1}, x_{2}, \cdots) that may help explain our target.

A single observation takes the form

d=(y1,x1,x2,x3,⋯ ,xp)\begin{aligned} d = \left( y_{1}, x_{1}, x_{2}, x_{3}, \cdots, x_{p} \right) \end{aligned}

where y1y_{1} is our target and x1,x2,⋯ ,xpx_{1}, x_{2}, \cdots, x_{p} are pp covariates that are measured at the same time as our target.

A dataset containing nn observation then can be written as

Expected '\right', got '&' at position 103: …{1,p}), \\
    &̲(y_{2}, x_{2,1}…

\begin{aligned}
    &\mathcal{D} = \left( (y_{1}, x_{1,1}, x_{1,2}, x_{1,3}, \cdots, x_{1,p}), \\
    &(y_{2}, x_{2,1}, x_{2,2}, x_{2,3}, \cdots, x_{2,p}), \cdots, (y_{n}, x_{n,1}, x_{n,2}, x_{n,3}, \cdots, x_{n,p})  \right)     
\end{aligned}

The model for multivariate linear regression assumes

Yi∣xi,1:p∼N(β0+β1xi,1+β2xi,2+⋯ ,βpxi,p,σ2)\begin{aligned} Y_{i} | x_{i,1:p} \sim \mathcal{N}\left( \beta_{0} + \beta_{1}x_{i,1} + \beta_{2}x_{i,2} + \cdots, \beta_{p}x_{i,p}, \sigma^{2} \right) \end{aligned}

where we assume that the observation yiy_{i} was generated from a corresponding random variable YiY_{i} with the above Normal distribution conditioned on all xx covariate values.

The above model can also be expressed as

Yi∣xi,1:p=β0+β1xi,1+β2xi,2+⋯ ,βpxi,p+ϵiϵi∼N(0,σ2)\begin{aligned} Y_{i} | x_{i,1:p} &= \beta_{0} + \beta_{1}x_{i,1} + \beta_{2}x_{i,2} + \cdots, \beta_{p}x_{i,p} + \epsilon_{i} \\ \epsilon_{i} &\sim \mathcal{N}(0,\sigma^{2}) \end{aligned}

Compared to single covariate linear regression, multivariate linear regression begins with β0+β1xi,1\beta_{0} + \beta_{1}x_{i,1} as in single covariate linear regression and then further adjusts the mean by multiplying each additional covariate xi,kx_{i,k} with a corresponding βk\beta_{k} and summing all of these quantities βkxi,k\beta_{k}x_{i,k}.

A single categorical variable

A natural experiment where one will need to use multivariate regression is when associating a continuous target variable yy to a categorical explanatory variable xx that can take one of CC possible categories.

Suppose that we wish to relate yy, a continuous variable, to x, a variable that can take one of the three values ‘A’, ‘B’, ‘C’ then linear regression does not---at first---make much sense.

Given the dataset

D=[yx0.2"A"0.4"A"−0.5"B"0.6"C"−0.5"B"]\begin{aligned} \mathcal{D} = \begin{bmatrix} y & x \\ 0.2 & "A"\\ 0.4 & "A"\\ -0.5 & "B"\\ 0.6 & "C"\\ -0.5 & "B" \end{bmatrix} \end{aligned}

The naive model would assume that

Yi=β0+β1xi+ϵiϵi∼N(0,σ2)\begin{aligned} Y_{i} &= \beta_{0} + \beta_{1} x_{i} + \epsilon_{i} \\ \epsilon_{i} &\sim \mathcal{N}(0,\sigma^{2}) \end{aligned}

However, we cannot multiply the value β1\beta_{1} by the letters A, B, C.

One solution is to convert this single categorical variable into many numerical variables. We will need to (i) choose a reference value for xx that we will compare all other y values corresponding to other categories to and (ii) create two additional columns---one per category excluding the reference---that contain the value one when that category value is present in xx and the value zero otherwise.

For example, suppose for the above dataset we choose a reference of "B". Then we will create one column that identifies values of "A" and a second column that identifies values of "C".

Our new dataset will look like

D=[yxxAxc0.2"A"100.4"A"10−0.5"B"000.6"C"01−0.5"B"00]\begin{aligned} \mathcal{D} = \begin{bmatrix} y & x & x_{A} & x_{c}\\ 0.2 & "A" & 1 & 0\\ 0.4 & "A" & 1 & 0\\ -0.5 & "B" & 0 & 0\\ 0.6 & "C" & 0 & 1\\ -0.5 & "B" & 0 & 0\\ \end{bmatrix} \end{aligned}

We can update our naive single covariate linear regression with the following multivariate linear regression.

Yi=β0+β1xi,A+β2xi,C+ϵiϵi∼N(0,σ2)\begin{aligned} Y_{i} &= \beta_{0} + \beta_{1}x_{i,A} + \beta_{2}x_{i,C} + \epsilon_{i}\\ \epsilon_{i} & \sim \mathcal{N}(0,\sigma^{2}) \end{aligned}

To interpret the above model, lets compute the expected value of YY when we observe a "A", "B", and a "C".

When we observe an "A" then the covariate xAx_{A} is the value one and the covariate xcx_{c} is the value zero. So then

E(Y∣x=A)=β0+β1(1)+β2(0)=β0+β1\begin{aligned} \mathbb{E}(Y |x=A) &= \beta_{0} + \beta_{1} (1) + \beta_{2} (0)\\ &= \beta_{0} + \beta_{1} \end{aligned}

When we observe a "B" then the covariate xAx_{A} is the value zero and the covariate xcx_{c} is the value zero. So then

E(Y∣x=B)=β0+β1(0)+β2(0)=β0\begin{aligned} \mathbb{E}(Y |x=B) &= \beta_{0} + \beta_{1} (0) + \beta_{2} (0)\\ &= \beta_{0} \end{aligned}

When we observe a "C" then the covariate xAx_{A} is the value zero and the covariate xcx_{c} is the value one. So then

E(Y∣x=C)=β0+β1(0)+β2(1)=β0+β2\begin{aligned} \mathbb{E}(Y |x=C) &= \beta_{0} + \beta_{1} (0) + \beta_{2} (1)\\ &= \beta_{0} + \beta_{2} \end{aligned}

The intercept term (β0)(\beta_{0}) is the expected value of YY when we observe a xx value that is equal to the reference. All other categories include this reference β0\beta_{0}. The parameter β1\beta_{1} is the change in the expected value of YY when an observation includes x=Ax=A compared to the expected value when x=B. The parameter β2\beta_{2} is the change in the expected value of YY when an observation includes x=Cx=C compared to the expected value when x=B.

Two or more continuous covariates and adjustment for confounding

We can include several continuous valued xx covariates without the need to first transform them as we must do when we include a xx covariate that is categorical. For example, suppose that we wish to associate the annual cost of household health insurance to annual family income, number of dependents that are claimed on previous taxes by the individual who pays the insurance, and age of the oldest resident of the household.

Then we can generate a model

Yi=β0+β1xi,1+β2xi,2+β3xi,3+ϵiϵi∼N(0,σ2)\begin{aligned} Y_{i} &= \beta_{0} + \beta_{1} x_{i,1} + \beta_{2}x_{i,2} + \beta_{3} x_{i,3} + \epsilon_{i}\\ \epsilon_{i} &\sim \mathcal{N}(0,\sigma^{2}) \end{aligned}

and estimate the parameters θ=(β0,β1,β2,β3,σ2)\theta = (\beta_{0}, \beta_{1}, \beta_{2}, \beta_{3}, \sigma^{2}). Standard software can produce point estimates, confidence intervals, and hypothesis tests at a desired false positive rate, but software can not interpret the hypothesized impact of these parameters on YY.

One method to understand whether a covariate xx is associated with YY while adjusting for all other covariates that are considered is to build an added variable plot between YY and xx.

Suppose our experiment generates three covariates (x1,x2,x3)(x_{1}, x_{2}, x_{3}) and a target yy. An added variable plot for the covariate x3x_{3} follows these steps:

The residuals ϵY∣x3\epsilon_{Y|x3} include any relationships that are not captured by associating Y,x1Y, x_{1}, and x2x_{2} linearly. The residuals ϵX3\epsilon_{X_{3}} are values that linearly relating x1x_{1} and x2x_{2} could not capture, and so when we relate ϵY∣x3\epsilon_{Y|x3} to ϵX3\epsilon_{X_{3}} we are asking about the association between patterns in YY that could not be captured by x1x_{1} and x2x_{2}, and patterns in x3x_{3} that could not be explained by x1x_{1} and x2x_{2}.

Estimating β\beta and σ\sigma

Homework

Let $$\begin{aligned} A = \begin{bmatrix} 1/2 & -2 & 0 \ -10 & -5 & -1 \end{bmatrix} ; B = \begin{bmatrix} 1 & 0 \ 0 & -1 \ 1 & 1 \end{bmatrix} ; x = \begin{bmatrix} -2 \ 1 \ 0 \end{bmatrix}

\end{aligned}$$ If possible, please compute the below. If it is not possible to compute one of the below quantities then please write "Cannot compute" and explain why.

  1. ABAB

  2. BABA

  3. AxAx

  4. BxBx

  5. BAxBAx

Suppose that we collect data on the total number of confirmed influenza hospitalizations over the 2022/2023 influenza season and hypothesize that the total number of cases may be related to population density of the state and the percent of the state population that is vaccinated before October 1, 2022.

Please describe a multivariate linear regression that may be used to model this data. Please include: (i) the model, a description of each variable in the dataset, a summary of what the vector yy and matrix XX might look like.

Let β′x\beta' x, where $$\begin{aligned} \beta = \begin{bmatrix} \beta_{0}\ \beta_{1}\ \beta_{2}\ \beta_{3}\ \end{bmatrix}; ; x = \begin{bmatrix} x_{3}\ x_{2}\ x_{1}\ x_{0}\ \end{bmatrix}

\end{aligned}$Pleaseexpand Please expand \beta’x$ as a series of sums and products.