About this question
Medium · Linear Algebra & Machine Learning · Quant Trader interview question · linear-algebra, regression, statistics, ols
Consider a standard Ordinary Least Squares (OLS) linear regression model: $Y = X \beta + \epsilon$, where: $Y$ is an $N \times 1$ vector of the dependent variable. $X$ is an $N \times p$ matrix of independent variables (including a constant if one is used). $\beta$ is a $p \times 1$ vector of coefficients. $\epsilon$ is an $N \times 1$ vector of error terms. The 'hat matrix' $H$ is defined as $H = X(X^T X)^{-1} X^T$. What is the trace of $H$, i.e., $tr(H)$?