Module 3 formulas
Matrix products
Section titled “Matrix products”Inner dimensions match; outer dimensions survive.
For real matrices of shape and of shape :
- : output row; : output column.
- : index along the matched row and column.
- : individual entries.
- : add the products as runs from 1 to .
One entry = row times column. Row and column give .
Powers and identity
; . The identity has diagonal entries 1 and other entries 0: when sizes match.
Algebra rules
- Generally .
- .
- .
The transpose swaps rows and columns:
Transposing a product reverses its order. All operations require compatible dimensions.
Vector products
Section titled “Vector products”Inner = one number; outer = a grid. Let be column vectors with real entries.
are vector entries. The outer product is an matrix; select its row and column.
Matrix times vector: for with rows and columns,
The result has entries. Each is one row of dotted with .
Squared length = sum of squared entries:
Invented example: , give inner product and outer product .
Eigenvectors
Section titled “Eigenvectors”Multiply, then check for one common scaling factor.
- : square matrix.
- : nonzero eigenvector.
- : eigenvalue, the multiplier.
Negative reverses direction; zero collapses the vector to zero. For invented and , .
If is real and symmetric, , its eigenvalues are real and one can choose mutually perpendicular eigenvectors. Perpendicular means for different chosen vectors. General real matrices may have complex eigenvalues/eigenvectors.
Regression model
Section titled “Regression model”Prediction = baseline + input contributions.
- : response; : input .
- : number of predictors, excluding the intercept.
- : intercept, the baseline when all inputs are zero.
- : multiplier, or response change per unit of input , holding other inputs fixed.
- : unexplained noise.
A hat means “estimated from the data.” For observation with recorded inputs :
Unknown noise is left out of the prediction. Invented rule at : contribution ; add baseline .
Probability story: draw inputs, then draw an output given those inputs.
is the input density, the conditional output density, and their joint density. are possible input and output values; the model plus noise distribution describes the conditional output.
Simple regression
Section titled “Simple regression”Center → multiply → add → divide. Given observed pairs , fit with an intercept.
1. Means
2. Centered totals
measures joint movement; measures input spread.
3. Slope and intercept
Require : identical inputs cannot identify a slope.
The intercept puts the line through the averages:
Shared Q3: pairs give calculated means , , and . Thus slope ; intercept .
Matrix least squares
Section titled “Matrix least squares”One matrix fits every row at once.
- : design matrix with rows and columns; first column all ones, then predictor columns.
- : column of observed outputs.
- : trial vector of coefficients.
- : fitted coefficient vector, intercept first.
Argmin selects the coefficients with smallest RSS. The squared length adds squared residual entries.
With linearly independent columns — no column an exact combination of others — use
means transpose. An inverse undoes a matrix: , with identity . The displayed inverse requires independent design columns.
Fit metrics
Section titled “Fit metrics”Choose the right comparison. For observed outputs , predictions , and sample mean :
Residual = observed − predicted
RSS = fitted model’s squared misses
TSS = mean-only guess’s squared misses
R² = fraction of baseline error removed
Require TSS . For training-set least squares with an intercept, RSS TSS and .
RSE = estimated noise size in output units
counts predictor coefficients, excluding the intercept. Require and linearly independent design columns. RSS/TSS have squared output units; has no units.
Shared Q3: RSS , TSS , , . Then RSE and .
Coefficient uncertainty
Section titled “Coefficient uncertainty”RSE describes output misses; SE describes estimate spread. Smaller coefficient SE means a more precise estimate.
Assumptions: correct linear model ; zero-mean errors given inputs; independent errors with common variance ; linearly independent design columns.
- : design matrix, including an intercept.
- : observed-output vector; : error vector.
- : true coefficient vector; : least-squares estimate.
- : noise standard deviation; if variance is supplied, take its square root.
Unbiased = centered on the truth
averages estimates across repeated samples with design fixed. This does not make every estimate close.
Covariance = joint uncertainty
Its diagonal entries are coefficient variances. Their square roots are standard deviations (SDs).
One-predictor formulas
For inputs , define and .
is the slope; is the intercept.
Unknown noise? Replace with RSE:
For one predictor, RSE , where RSS uses observed outputs and predictions .
Calculation chain: RSS → RSE → coefficient SE. If the problem supplies a coefficient SE, use it directly.
Invented example: RSE and give slope SE .
Intervals and tests
Section titled “Intervals and tests”Interval = estimate ± margin. Test statistic = gap ÷ uncertainty.
- : fitted coefficient .
- : its standard error.
- : proposed true coefficient value.
Quick approximately 95% interval
Calculate margin , then subtract/add it. Across repeated samples, about 95% of these intervals contain the fixed true coefficient , under the normal approximation.
Two-sided test
is the null claim; is the alternative. is the gap measured in SEs.
- : reject under the approximate rule.
- : fail to reject; the value remains consistent with this test.
Equivalently, reject values outside the interval. Endpoints count as inside for the practice convention. Failure to reject does not prove the null true.
Shared Q5(a): estimate , SE , claim give . The gap is 4 SEs: reject. For estimate 2 and SE , the interval is , so neither 1 nor 2 is rejected under this convention.
Zero-slope question: use , . Significance describes the repeated-test rejection rate when the null is true, not the probability the null is true.
Approximation: 2 rounds the normal cutoff 1.96. Under a correct linear model with independent, zero-mean normal errors of constant variance, estimated noise, and independent design columns, exact 95% intervals replace 2 with . This is the Student cutoff with degrees of freedom; counts observations and predictors excluding the intercept. The practice uses the approximate rule.