Quantij quantitative finance education and research
Quant Research Interviews: Regression, Neighbours and Econometrics
Compare linear models and nearest neighbours, diagnose regressions, reduce dimension, and reason about causality.
Published 27 November 2026 · Full chapter
Data science for quant research
This section is an overview of the ”main” chapters of Elements of Statistical Learning. The Elements of Statistical Learning (ESL) book is considered GOATed in the fields of data science, machine learning, and statistics, and is essentially the first book you’ll want to consult for a comprehensive and rigorous yet concise overview of basics about regression, data modeling, and inference.
Least Squares and Nearest Neighbors
The linear model has been a mainstay of statistics for the past 30 years and remains one of the most important tools. Given a vector of inputs XT = (X1,X2,...,Xp), the participants predict the output Y via the model ˆ Y= ˆ β0 + p i=1 ˆ Xi βi In other words, Y is a linear combination of the input features X plus a bias term. The goal is to fit the best set β of coefficients and bias. Y is often just a scalar (so β would be a vector), but Y can also be a vector, so that β would be a matrix. The equation above represents a hyperplane in the input-output space.
The most popular method for fitting a linear model is using least squares, i.e. picking the right hyperplane so that the sum of squares of distances of each input feature to the hyperplane is minimized across all possible hyperplanes. In other words, the participants are trying to minimize an objective function, the “residual sum of squares”: RSS(β) = N (yi−xT i β)2 i=1 The residual sum of squares is a highly “natural” choice for the measure of error that the objective is to minimize for a model, and it’s indeed used in many contexts besides linear regression. Due to some technical math, it actually turns out that simple linear regression, using residual sum of squares, for the linear model provides the best ”unbiased” estimate among all linear models for the underlying conditional expectation of output values given input values. This conditional expectation is known as the conditional expectation function (CEF) and is the optimal theoretical predictor for the data problem from a Bayesian standpoint. It is for this reason that residual sum of squares is not only a “natural” choice of error function, but actually the mathematically optimal one in the linear context.
a candidate can derive a simple formula for β for the linear model by taking the derivative of the RSS above; the analysis will do this in a few pages, and this β formula is one of the core formulas in data science and is very important to memorize by heart.
The other “simplest” model is nearest neighbors. Nearest-neighbor methods use those observations in the ˆ training set T closest in the input space to x to form Y. Specifically, the k-nearest neighbor fit for ˆ Y is defined as follows: ˆ Y(x) = 1 k yi xi∈Nk(x) This formula essentially corresponds to taking the average of the knearest points for x, which are symbolized by the Nk(x) function. Note that nearest neighbors just involves direct calculations on the training data, and not fitting a model (except maybe the choice of k); the participants just have to memorize the training data and compute with it!
Decision regions and boundaries for nearest neighbors:
For 1-nearest-neighbor, the decision boundaries/regions form a Voronoi tessellation which is easily computable, and often highly disjoint + irregular
For highest k-nearest-neighbor, the decision regions generally get less disjoint but are still highly irregular, something that a linear model can’t do
Impt point: the “effective” number of parameters is n/k instead of just 1 (the single parameter k), because up to overlap, nearest neighbors is creating n/k different decision regions. This gives an intuitive explanation for why regions get less disjoint with higher k.
Kernel methods are augmentations of nearest neighbors that employ a varying weight, smoothly decreasing with distance between source and target, rather than a constant weight.
Comparing and contrasting the two approaches: Linear model w/ least squares Nearest neighbors Low variance and high bias High variance and low bias Relies on assumption that linear models are the right choice for the data Doesn’t rely on assumptions about underlying data Works well for “Scenario 1”: Gaussian distributed data with uncorrelated components and different means Works well for “Scenario 2”: mixtures of Gaussian distributions, with mean of each component Gaussian in each mixture independently sampled Efficient and accurate choice for high-dimensional data Effective and indeed commonly used in practice when data is low-dimensional and plentiful, but suffers from the ”curse of dimensionality”.
How least squares and nearest neighbours behave
There are some important technical details about the nearest neighbor and linear regression models that the participants will discuss here; the analysis will address each row of the above compare-and-contrast table, discussing their broader context and important intuitive ways of thinking about them.
First, the details about ”Scenario 1” vs. ”Scenario 2” are the easiest to address. When each class or target value of data follows a single Gaussian distribution, the data are more cleanly separable, i.e. a single line can effectively delineate the difference between one Gaussian and the next. This corresponds to ”Scenario 1” and the use of linear models, which create these simpler delineations for prediction. On the other hand, when each class or target value of data follows a mixture of distributions that can intertwine and overlap with each other in more complex ways, the prediction must be done with a larger number of disjoint and often irregular decision regions. This corresponds to ”Scenario 2” and the use of nearest neighbors, which naturally creates these disjoint regions when the linear model doesn’t.
Bias-Variance Tradeoff the participants expand on the bias-variance tradeoff for nearest neighbors vs. linear regression. In this context, and actually in general, a candidate can think of bias as the degree of assumptions and constraints inherent in the choice of model; this intuition is a bit different from the formal definition of bias as the expected difference between the model’s prediction vs. the actual output for an arbitrary data point. On the other hand, a candidate can think of variance as the resulting ”instability” of the model, or its degree of sensitivity to changes in the input data; fortunately this intuition pretty closely captures the formal definition of variance. These intuitive viewpoints of bias and variance allow the candidate to think of bias as the property the participants directly control, via the assumptions and constraints the participants bake into the design and tuning of the model, and variance as the property the participants observe as an output result.
Any model inevitably faces a bias-variance tradeoff, in which model design and tuning that decreases bias results in increased variance, and vice versa. The relative levels of this tradeoff for nearest neighbors vs. linear regression are then closely linked to the second row of the table, which mentions the assumptions that each model makes. Nearest neighbor models are some of the lowest-bias models possible, and in fact 1-nearest neighbor is THE lowest, by exactly memorizing the training data and creating the most complex and numerous disjoint regions of classification. 1-nearest neighbor makes no assumptions about the data, no matter what the data is. One illuminating aspect of 1-nearest neighbor is that it is the only model that always perfectly classifies the training data, i.e. there is zero error; any other model will have some assumptions or generality that causes it to misclassify or mispredict at least some points in the training data. The other side of the coin is that 1-nearest neighbor displays extremely high variance; the participants usually make significant changes to the classification regions if the participants add or perturb even a single data point.
Now pivoting to linear regression, the participants mentioned that linear regression assumes a linear relationship is the right underlying approach for modeling the data. This assumption is not as strict as it sounds, for various reasons; for example, a candidate can make transformations to the features such as introducing new parameters that polynomial or trigonometric functions of the original parameters, so that nonlinear relationships are captured. Even so, this lenient assumption increases the bias and decreases the variance of linear regression relative to nearest neighbors, which has virtually no assumptions (or for 1-nearest neighbors, actually no assumptions). The analysis will see later on that linear regression is still highly unbiased compared to most other models, which have stricter assumptions.
There are two other notes about bias-variance important to note:
Bias is also directly correlated with ”model complexity,” which is a more common consideration in data science and statistics generally than the intuitive perspective of bias from earlier. a candidate can think of any data science/statistics problem as taking a dataset which has some set amount of information or ”complexity” baked into it, and trying to accurately capture this complexity to make good predictions.
Complexity comes from both the model itself and the assumptions behind the model, which in a sense are two independent sources of complexity. Make stricter assumptions, and complexity shifts towards the assumptions and away from the model; likewise, relax your assumptions and complexity shifts back towards the model. In this way model complexity is inversely related to the level of the underlying assumptions in designing the model, and the model complexity viewpoint of bias cleanly aligns with the intuitive viewpoint about model assumptions.
Any model has an implicit property called (effective) degrees of freedom (denoted df), which is linked to the bias-variance tradeoff. With higher degrees of freedom, bias decreases and variance increases.
This makes sense with the discussion; more degrees of freedom are granted when assumptions and constraints are relaxed, but more degrees of freedom also means more room for change in the model when the data changes. The participants noted earlier that n/k is the effective number of parameters of k-nearest neighbors, and it’s also in fact the effective degrees of freedom.
Curse of Dimensionality Nearest neighbors and linear models are better fits for two different domains of data modeling problems, respectively low-dimensional and high-dimensional data. This dichotomy is governed by the curse of dimensionality, which is a formal way of saying that inference becomes exponentially harder as the data becomes high-dimensional for certain classes of models. a candidate can observe the curse of dimensionality for nearest neighbors in a few geometrically intuitive ways:
In high dimensions, the distance between two arbitrary points in some region increases on average compared to low dimensions. Because nearest neighbors classifies new points according to some nearby point a small distance away, high dimension without a proportional increase in the number of training data points results in less availability of a nearby training point for an arbitrary input point, and therefore less accurate prediction.
In high dimensions, it becomes exponentially more likely for data points to lie on the edge of the range of input values, and boundary points are harder to predict because they more often require extrapolating from one nearby training point rather than interpolating between training points.
When data is low-dimensional and plentiful, nearest neighbors dominates and is often used in the real world for applications where available data follows this paradigm. When data dimensionality increases even a moderate amount, nearest neighbors falls off very quickly. For example, a candidate can imagine that 2-dimensional data is very easy for nearest neighbors to classify, while 10-dimensional data has already grown to be very inefficient for nearest neighbors.
For moderate to high dimensionality, linear regression methods dominate over nearest neighbors. The assumption of linear underlying relationship provides some defense for linear models against the curse of dimensionality compared to nearest neighbor models. In general, simple linear regression is still highly impacted by the curse of dimensionality when compared to many other models; however, as the analysis will see soon, there are various additional assumptions and variations for linear regression a candidate can make that strengthen linear regression in high dimensionality.
Regressions
This section will pivot away from the more general nearest neighbors vs. linear model discussion as the participants go into the deep technical details of linear regression.
Normal equations and the hat matrix
For a full-column-rank design matrix , minimise . Its gradient is . Setting it to zero gives Fitted values are , where projects orthogonally onto the columns of . This projection minimises the residual distance. Numerically, use a solver rather than explicitly forming the inverse.
Residual variance
With observations, predictors, and one intercept, the classical estimate is
Test an individual coefficient
For uncorrelated, homoskedastic errors with variance , Write . With Gaussian errors and a full-rank design, has a chi-square distribution with degrees of freedom and is independent of . Under , Large absolute values provide evidence against the null.
In other words, the z-score for individual beta coefficients based on t distribution tells the candidate how dramatically a model would change if the coefficient was removed; higher z-scores (absolute value) tell the candidate that that coefficient is more important, and z-scores beyond a threshold (say, 2) mean that these coefficients and corresponding predictors are significant. The participants might choose to discard predictors whose coefficients do not reach this threshold.
A two-sided interval for coefficient under the classical Gaussian model is Use a standard-normal quantile for a suitable large-sample approximation.
Even if the Gaussian error assumption does not hold, this interval will be approximately correct, with its coverage approaching 1−2α as the sample size N →∞. Z-Score for Groups of Beta Coefficients (F-Statistic) Instead of just testing for the exclusion of single coefficients like in the t-test, the participants may want to test groups of coefficients at once. Testing singletons vs. groups is actually two highly distinct tasks; with a lot of possible configurations for correlations between variables, it may very well be the case that, for example, there are three coefficients that do not meet the Z-score significance threshold, but a group of those three coefficients IS significant, a property that can only be detected with the F-statistic and not the t-test. The F-statistic looks like: (RSS0−RSS1)/(p1−p0) F= RSS1/(N−p1−1).
Here RSS1 is the original RSS, and RSS0 is the RSS for the regression with all coefficients in the group set to 0. One common use of the F-statistic is to verify the significance of coefficients together after t-tests for all single coefficients have been calculated. For example, if the objective is to drop every non-significant coefficient, i.e. with |zscore|<2, the participants might group all the non-significant coefficients for an F-statistic and verify whether the F-statistic is still non-significant, helping the candidate make a final decision on whether to drop the entire group or keep some terms.
Multivariate Regression from Univariate In other words, when the participants regress on one variable and take the residuals, the set of residuals is orthogonal with respect to the original variable; then a candidate can use the residuals as the new inputs for the successive orthonormalization.
This is actually the standard way multiple linear regression is done. The whole point of multiple linear regression is for the fitting of the model to be independent for each variable, i.e. for the beta coefficient corresponding to each single variable in the multiple regression to represent that variable’s effect on the output adjusted for the effects between that variable and all other variables in the multiple regression. By orthonormalizing and regressing on the residual after each single variable step in the multiple regression, the participants ensure this is the case. Another way of saying this is that the multiple regression coefficient βj represents the additional contribution of xj only after xj has been adjusted for the p other input variables in the multiple regression, x0,x1,...,xj−1,xj+1,...,xp.
Dimensionality Reduction
One common goal in linear regression is dimensionality reduction, where the participants restrict or even vanish some of the original variables’ coefficients in order to narrow down a smaller subset of important input variables with smaller dimension than the original. There are two main justifications for dimensionality reduction:
Improving test error. One important detail of the bias-variance tradeoff is that total error is generally given by the sum variance + bias2. The participants mentioned earlier that, although simple linear regression is more biased and lower-variance than nearest neighbors, it’s still highly unbiased relative to many other models beyond nearest neighbors. Simple linear regression is often in the region of bias vs. variance where introducing further assumptions and restrictions will actually decrease variance more than it increases bias, resulting in improved overall error.
The participants care about interpretability of the regression, and part of interpretability is pinpointing what subset of variables are the highly significant portion of the regression.
Stepwise Regressions There are three stepwise regressions for performing subset selection (finding subset of size k of the parameters that creates the best possible model out of all such subsets). Each one takes a slightly different approach but is usually built on the regression through orthonormalization algorithm from earlier.
Forward stepwise
Start with empty model, no parameters
At each step, find the one parameter that creates the model of best fit (vanilla univariate regression), then add that parameter to your total model and orthonormalize everything with respect to that parameter. Repeat this for further steps.
Backward stepwise
Start with full model, incorporating all parameters
At each step, find the one parameter that contributes least to the fit, then remove it, then orthonormalize with respect to the removed parameter. Repeat this for further steps.
Forward stagewise
Start with zero-initialized model
At each step, find the parameter most correlated w the current residual, then compute the beta coefficient for this parameter and add it to the corresponding coefficient in the total model
Note: takes much longer than k steps for size-k subset, which is in contrast to the first two stepwises taking just k steps, but this actually pays off with greater accuracy/effectiveness in very high dimension.
One other technique is good to know: for relatively small total dimension, i.e. 30 or less, the “leaps-andbounds” algorithm is a highly efficient method for this.
Ridge regression
Penalise the squared norm of the slopes. With centred inputs and response, the intercept is handled separately. For , the penalised matrix is nonsingular.
One way of seeing how ridge regression increases bias is by observing its effect on the effective degrees of freedom df. It can be calculated that df(λ) follows a monotone decreasing function, where df(0) = p, where p is the number of parameters, and df(∞) →0. Increasing the regularization weight λ reduces the degrees of freedom and likewise increases bias, both results of imposing additional restriction.
More technical aspect of ridge regression: it is actually an implementation of “principal components analysis (PCA),” which aims to reduce dimensionality by transforming to new features and truncating to the first k most important new features. PCA relies on the singular value decomposition (SVD) of a matrix X, i.e. decomposing it into X= UDVT where U and V are unitary and D is diagonal with real nonnegative entries d1,d2,...,in decreasing order as you go down the diagonal. This is also called “eigen-decomposition”.
The matrices in SVD also give a formula: XTX= VD2VT The SVD gives the building blocks for a transformation very similar to a “change of basis”; the columns of V are eigenvectors where each one generates a linear combination of the original vectors which is orthogonal to all the previous vectors in the sequence. These transformed vectors are the “principal components” z: z1 = Xv1 and the corresponding di’s (diagonal values of D) correspond to a “scaling” (actually sample variance) for the principal components, so that the first principal has the highest sample variance (the biggest impact on the model) and this impact decreases in order so the last principal components has the smallest sample variance and the smallest impact.
Ridge regression shrinks the last principal components.
Lasso regression
Penalise the sum of absolute coefficient values instead. Unlike ridge, lasso can shrink individual slopes exactly to zero.
This is a more subtle optimization problem with different results compared to ridge. While ridge has the closed form with the new beta matrix equation, the lasso has no such closed form and is actually a quadratic programming problem. An interesting point is that, if the participants constraint the lasso term to be <tfor some t, then some beta coefficients vanish as tgets smaller before hitting 0, which doesn’t happen for ridge. This creates an important difference in use cases between lasso and ridge; lasso can create sparse models by removing some variables entirely, while ridge compresses variables to nonzero values, so it doesn’t induce the same sparsity.
Comparing and contrasting the various dimensionality reduction approaches: Subset selection (stepwises) Ridge Lasso “Hard thresholding”, completely drops/truncates features beyond the desired subset size.
Proportional shrinkage, most important features are shrunk less than least important features. “Soft thresholding”, transforms each coefficient by the same constant factor and truncates at 0.
It’s also worth mentioning that lasso and ridge regression are the q = 1 and q = 2 cases, respectively, of regularization with the Lq norm of the beta. Any non-negative values of q are possible for Lq regularization, including q = 0 (which corresponds to variable subset selection) and even higher powers like q = 3 or q= 4. In practice it’s common for an optimal or highly effective value of q to lie between 1 and 2. For this reason, “elastic-net” is often used as a weighted average between lasso and ridge, to efficiently approximate calculation in the q∈(1,2) regime. Elastic-net uses the following regularization term for regression: Least Angle Regression Similar to the forward stepwise approach, but this time instead of adding whole parameters from the feature set to the model one by one, the coefficients in the model are continuously increased, with constant tracking of which parameters (can be multiple) have the highest correlation with the residuals and continuously increasing those.
LAR only adds to the model the amount of coefficient that it “deserves”.
LAR is useful because it is a greedy algorithm →easily computable but it also produces a very similar result to lasso, basically identical until any coeff crosses 0.
This leads to a “lasso modification” for LAR: by dropping any variable whose coefficient crosses 0 and recomputing the joint least squares distribution after dropping, a candidate can obtain the entire lasso path.
After k iterations of LAR, the fit has k degrees of freedom, super elegant Principal Components Regression Continuing from the principal components derivation from ridge regression, the participants regress y directly on the principal components, and after obtaining the beta coefficients for the principal components, the participants expand them out as linear combinations of the original features to obtain a regression on the original features.
The principal components are already orthonormal so regression ends up simplifying to univariate regressions on each.
The participants usually drop out a bunch of the last principal components, i.e. only regress y on the first M principal components where M < p. This is the biggest difference between PCR and ridge; PCR directly truncates the last principal components while ridge proportionally shrinks them from first to last but retains at least some to all principal components.
Note: Principal Components Analysis The principal components process described above doesn’t have to apply to just regressions. The step of transforming the input basis into a smaller-dimension set of principal components bases can be done on the input data points before fitting any model or even considering the target values of those points; this is a form of unsupervised learning and allows the dimensionality reduction advantage of principal components transformations to be applied in many contexts besides ridge regression or PCR.
Brainteasers about Regression
What are some of the main assumptions of linear regression?
The underlying relationship between the input features and the target output is actually linear (this is the main distinction that facilitates using linear regression over the other “simple” method of k-nearest neighbors).
Building off of the first assumption, linear regression generally relies on the target having a linear relationship with the inputs plus some amount of error. The participants also assume that this error term is centered around 0 so that there is no bias. a candidate can also assume the error term follows a normal distribution but this is not strictly necessary.
Little to no multicollinearity, i.e. the input features are not highly correlated with each other and are independent from each other. Of course, in practice multicollinearity can happen often so at the very least the participants want none of the inputs to be a perfect linear combination of the other inputs.
Homoskedasticity, which means that the errors should have the same variance at different values of any of the input.
No autocollinearity, i.e. the residuals for a single variable are independent of each other. This means that the error should be uncorrelated with any input variable, i.e. it should actually be an unpredictable random error.
Suppose the candidate has two inputs X and Y, and the candidate does two different regressions, each for one input w.r.t the ˆ ˆ other. In other words, the candidate regresses Y= α1 + β1X and also X= α2 + β2Y. Is it true that β1 = 1/β2?
No; the intuition is that the first regression is trying to minimize the sum of vertical residuals while the second regression is trying to minimize the sum of horizontal residuals, and there is no reason that these sums should lead to an exact match for the betas.
What happens to the regression if the input features are not all linearly independent?
The solution to linear regression is not unique
I perform a regression on three features that are highly correlated; two of the features fit well but the third has a high standard error. How do I deal with this?
This is a sign of multicollinearity, which is a challenging issue in practice that has a lot of possible remedies. The simplest way to deal with it is to drop the third variable entirely. However, the third variable can still carry valuable information not present in the other variable so this might be undesirable.
Other remedies to multicollinearly without dropping the variable include different types of transformations, such as trying different kinds of feature transformations like polynomials, centering the variables by subtracting the mean, or using linear combinations of the variables.
a candidate can also try other types of regression more equipped to deal with multicollinearity. Any of the dimensionality reduction regressions, like ridge, lasso, or PCA work well.
Suppose each data point is duplicated, i.e. repeat each point once; what happens to the regression?
The betas stay the same. To see this analytically, a candidate can either observe the closed form β= (XTX)−1XTy and see that doubling the points leads to “doubling” the matrices with duplicate values so that the closed form is the same; a candidate can also look at β= Cov(X,Y)/Var(X) and argue both terms don’t change.
Between lasso and ridge regression, which exhibits lower bias/higher variance?
Intuitively a candidate can compare the shapes of the Lq norm for lasso vs. ridge. The L2 norm expands further outwards, i.e. takes higher values, than the L1 norm, so that imposing a penalty on the L2 norm is a stricter constraint than the same weight penalty on the L1 norm. Using the model assumption perspective for bias, this implies that lasso regression should have the lower bias and higher variance, and indeed this is usually the case in practice.
One case where the variance difference between lasso and ridge is highly apparent is with a group of variables that are each insignificant according to their z-scores and that each have similar effects on the output. Because lasso soft thresholds by truncating some of the least significant terms, a small perturbation of the data can shift the order of significant terms and change the choice of truncated terms in lasso, which makes the lasso regression more unstable in this case. On the other hand, ridge regression performs proportional shrinkage on the insignificant terms and this shrinkage does not change much if the order of significance shifts, so ridge regression is more stable in this case.
The Econometrics Perspective
Randomized Trials
The goal of econometrics is to deduce cause and effect relationships between different aspects of society and economics; Suppose there are access to many data science tools for doing so.
An example of an econometrics problem that highlights some of the biggest initial roadblocks:
Suppose there are data samples for health insurance status, health, and other attributes for many different people in a population. the objective is to deduce whether greater levels of health insurance are a cause of better health outcomes.
Ideally a candidate can prove causality if Suppose there are “other things equal” (ceteris paribus). However, this almost never happens and Suppose there are many other variables, known and unknown, that vary with the input and/or output variable the participants care about.
For the health insurance problem, a candidate can measure other factors such as education level, income/wealth, age, etc. The participants find that all of these factors, and probably many more, also correlate with health insurance status and/or health in some way, so the participants don’t have other things equal.
Without other things equal, the participants run into selection bias with calculating the average causal effect.
Mathematical explanation of selection bias:
Suppose Suppose there are two input possibilities, 0 = not on health insurance, 1 = on health insurance.
Let Yi be the health outcome for person i, and further define Y0i as the outcome if person iis not on health insurance and Y1i as the outcome if person i is on health insurance.
Let Dbe the input for health insurance, i.e. D= 0 corresponds to no health insurance and D= 1 corresponds to health insurance. the average causal effect is Avgn[Y1i−Y0i] = Avgn[Yi|D= 1]−Avgn[Yi|D= 0] = Avgn[Y1i|D= 1]−Avgn[Y0i|D= 0] From the above equations, the selection bias qualitatively arises; the participants see the D = 1 dependent outcome only for the people in the D = 1 group, and the participants compare it to the D = 0 dependent outcome only for the people in the D= 0 group. If these groups are not the same in other things equal, then the calculated comparison between Y1i and Y0i is faulty.
To extract a selection bias term, write Avgn[Y1i−Y0i] = Avgn[Y1i|D= 1]−Avgn[Y0i|D= 0] + Avgn[Y0i|D= 0]−Avgn[Y0i|D= 0] = (averagecausaleffect) + (selectionbias)
Randomizing the assignment of people to groups greatly mitigates selection bias. This involves randomly assigning each person in the total population set to either receive treatment or control, i.e. the D= 1 and D= 0 groups.
LLN in this context tells the candidate that sample averages tend towards underlying population expectations as the sample size gets larger, i.e. every average taken for two large randomized sample groups from the same population will tend to be equal.
LLN implies that the selection bias term Avgn[Y0i|D= 0]−Avgn[Y0i|D= 0] will also become 0.
“Checking for balance”: after performing the randomization, it is useful to measure various sample averages and check that they are actually roughly equal.
Statistics Fundamentals in Econometrics
Refresher on important stats fundamentals:
The sample mean is unbiased: ¯ E[ Y] = E[Yi]
Population variance: Var(Yi) = σ2 Y = E[(Yi−E[Yi])2]
Sample variance of Yi in a sample of size n: 1 S(Yi)2 = n n (Yi− i=1 ˆ Y)2
Sampling variance: ¯ Var( Y) = σ2 Y n a candidate can obtain an estimator for the sampling variance by plugging in the sample variance for Yi: ˆ ¯ Var( Y) = S(Yi)2 n ˆ ¯ SE( Y) = S(Yi) √n
From the data a candidate can calculate a t-statistic as the difference between sample mean and assumed population mean, scaled by standard error: t(µ) = ¯ Y−µ ˆ ¯ SE( Y)
The CLT states that the distribution of t(µ) approaches the standard normal distribution as the sample size grows larger. This fact allows the candidate to test for statistical significance in two directions.
a candidate can check whether the sample mean is statistically different from the population mean by checking whether |t|is above some threshold value, often 2. a candidate can also construct confidence intervals for what values of µ are reasonable for the data: ¯ I= [ Y−C׈ ¯ SE( Y), ¯ Y + C׈ ¯ SE( Y)] where C is a similar threshold value to before, often C = 2. ¯
Testing two sample means: Suppose there are a treatment sample group with Y1 and µ1, and Suppose there are ¯ a control sample group with Y0 and µ0. The goal is to test whether µ1 = µ0. the estimated standard error looks like ˆ SE(Y1 −Y0) = S(Yi) 1 n1 where n1 and n0 are the sample sizes. Under the null hypothesis that µ1 −µ0 = µ, the t-statistic looks like t(µ) = ¯ Y1 ¯ − Y0 ˆ ¯ SE( Y1 − −µ ¯ Y0) and the confidence intervals are constructed similarly as before.
Important note: a large t-statistic often comes simultaneously from a significant underlying effect and from a small standard error (large sample size). Therefore, a small t-statistic doesn’t necessarily mean that the underlying effect is insignificant, but rather may reflect a lack of statistical precision (high sampling variance). 1 + n0 Regression in Econometrics
Without random assignment, the participants instead use regression to deduce causal relationships; the participants make the assumption that when observed variables are the same across treatment and control groups, selection bias from unobserved variables is also mostly eliminated.
This is the “conditional independence assumption” (CIA), or “selection on observables,” i.e. the idea that there is no selection bias in the average causal effect conditional on a given set of observables when comparing outcomes conditional on the same set of observables.
Treatment and control variables are encoded numerically
Raw encoding (often for continuous or discrete variables)
One-hot or “dummy” encoding (often for categorical or “yes/no” variables)
A regression model links the treatment variable to the outcome, and also holds control variables fixed by including them in the model. Let X be a vector representing the treatment, and let A be a vector (or matrix) representing the controls. the model is Yi = α+ βXi + γA+ ϵ ˆ The ϵ term is the residual, or the difference between the fitted output Y= α+ βXi + γA and the actual output Y. Regression fits the α,β,γ as to make the sum of squared residuals (RSS) the least possible; the resulting estimates are called ordinary least squares (OLS).
Regression is commonly performed in most econometrics studies as a benchmark against more advanced techniques.
Technical detail: under certain technical conditions, regression provides the most statistically precise estimates possible for average causal effects from a given sample.
Regressing on the log of the outcome variable is useful for obtaining estimates that can be interpreted as percentage changes.
One main roadblock in regression is omitted variables bias (OVB); since regression only eliminates selection bias across observed variables that are encoded as controls in the model, an inadequate set of controls (i.e. The participants failed to include important non-treatment variables) can cause selection bias to persist in the regression.
For a given control variable, its OVB effect can be quantified by performing two regressions, one with the control (“long”) and one without (“short”), and measuring the difference between the betas as follows: OVB = (Treatmenteffectinshort)−(Treatmenteffectinlong) = βs −βl = (Relationshipbetweenomittedandtreatment) ×(Omittedeffectinlong) = π1 ×γ In the above, the βs and βl are the regression coefficients for the treatment variable in the short and long regressions, respectively; the γ is the regression coefficient of the omitted control in the long regression; and the π1 is the regression coefficient of the omitted control on the treatment, i.e.
Aomitted = π0 + π1X+ ϵomitted
Important quote about OVB: “The importance of the OVB formula stems from the fact that if you claim an absence of omitted variables bias, then typically you’re also saying that the regression you’ve got is the one you want. And the regression you want usually has a causal interpretation. In other words, you’re prepared to lean on the CIA for a causal interpretation of the long regression estimates.” (excerpt from MHE)
The OVB formula can’t generate exact quantities for omitted variables Suppose there are no data on, but a candidate can perform qualitative reasoning with it to deduce whether the effects of omitted variables should be positive or negative. Example in case studies.
Robustness of regression: the confidence in a regression model grows when the OVB effect is small for any variables besides a set of a few core control variables, i.e. the treatment effect is insensitive to outside omitted variables.
Technical Details of Regression
Technical details of regression.
Regression finds the best possible fit to the unknown conditional expectation function (CEF) E[Yi|Xi]; this is the exact match if the CEF is linear, and a close linear approximation if the CEF is nonlinear.
In the bivariate case, i.e. Y and X are single variables, regression is closely related to the covariance through direct formulas for the regression coefficients: Cov(Y,X) β= Var(X) α= E[Y]−βE[X]
Residuals have zero mean (expectation and sample mean) and are also uncorrelated with all input variables and fitted outputs.
“Regression anatomy”: in a multivariate regression, the coefficient for one input variable X1 comes from the residual of its regression on the other control variable X2. In other words, for Y= α+ βX1 + γX2 + ϵ, Suppose there are β= Cov(Y,X1) Var(X1) where X1 is the residual from input on control, i.e. X1 = π0 + π1X2 + X1 This makes sense because it implies that the coefficient for any input in a multivariate regression depends on its residual (the leftover) after regressing on all other variables, i.e. the coefficient for any input encapsulates information only about itself.
Another way of stating this. If X2 is uncorrelated to X1 then the participants expect the beta in the “short” regression (excluding X2) to be very close to the beta from the “long” regression including X2, and the more correlated, the most the short and long betas will differ. (MHE)
Standard error for a regression can be expanded out as follows: ˆ SE( β) = σϵ √n 1 × σX To minimize the standard error for the estimated coefficients, the participants want less variance in the residuals σϵ, and/or more variance in the inputs σ2. A high residual variance means the regression is a poorer fit, but high input variance is actually good.
Regression with the above standard error assumes homoskedasticity (one of the core assumptions of regression), which is that the variance of residuals is uncorrelated to inputs. If the model is heteroskedastic (variance of residuals IS correlated to inputs) then the participants need “robust standard error” (formula not shown here).
Homoskedasticity can be hard to attain. Whenever the CEF is nonlinear Suppose there are heteroskedasticity because the residual variance is proportional to the square of the gap between the regression line and the CEF. Many underlying linear CEFs also do not imply homoskedasticity, such as the linear probability model (LPM) which is a regression on a zero-one input.
Homoskedasticity is not a very strict requirement for regression to work and in practice, heteroskedasticity doesn’t make that much of a difference (the robust standard error is usually close to the conventional (homoskedastic) standard error.
Technical details about the CEF
CEF decomposition. The target is equal to the CEF plus a residual (written ϵi) that is uncorrelated to Xi and has property E[ϵi|Xi] = 0 (“mean independent”).
Yi = E[Yi|Xi] + ϵi
The CEF is the minimum mean square error predictor of Yi given Xi. Out of all m(Xi), the class of all possible functions of X, Suppose there are E[Yi|Xi] = argmin E[(Yi−m(Xi))2] m(Xi)
The ANOVA theorem (analysis of variance): Var(Yi) = Var(E[Yi|Xi]) + E[Var(Yi|Xi)]
Technical details about the population regression solution vs. asymptotic OLS inference
The best regression coefficient vector, i.e. the solution to β = argminbE[(Yi−Xib)2], is given by β= E[XT i Xi]−1E[XT i Yi] This is also the best beta for the CEF E[Yi|Xi], not only Yi. This insight allows the candidate to apply “grouped data” strategies where, when the participants don’t have access to microdata (individual data points), a candidate can regress on aggregated data points which are averages conditional on the input features.
The sample analog of the population beta is ˆ β = (XTX)−1(XTY) where X and Y are the sample data points and respective targets. As the participants expect, ˆ β converges in probability to the population β from above and has an asymptotic normal distribution (with covariance matrix) ˆ β d −→ N(β,E[XTX]−1E[XTXϵ2]E[XTX]−1) Under homoskedasticity assumptions, where the residual variance is σ2, the covariance matrix becomes σ2E[XTX]−1.
Extra Regression Details
Sample weights and when to use them
One common situation is having samples that are nonrandom, sampled differently compared to the underlying population distribution, but the target is still the population regression function.
If the participants know the data is constructed with sampling weights wi equal to the inverse probability of sampling observation i, then a candidate can use weighted least squares using wi.
a candidate can also use weighted least squares on grouped data, weighted by the underlying frequencies of the data in each group, but this is not strictly necessary (especially in macroeconomics where the scientific convention is the unweighted analysis of aggregate variables).
Heteroskedasticity is not a good reason to use weighted least squares over OLS with robust standard error.
Saturated regressions are a way of constructing a regression with a guaranteed linear CEF, and are available to the candidate when all the input variables are discrete.
a candidate can create dummy variables representing all possible values of each input variable (the “main effects”) as well as dummy variables for all possible products of the input variables (the “interaction terms”).
Generates coefficients for each main effect and interaction term, and since everything is a zero-one dummy, the underlying CEF is linear so the regression will fit it perfectly.
Saturated models are the most restrictive strategy for modeling; creates a perfect fit but the interaction terms and their coefficients may be highly noisy/imprecise/meaningless.