wls_hat_matrix function

Create the "hat matrix" for weighted least squares regression

Create the "hat matrix" for weighted least squares regression

wls_hat_matrix(X, w)

Arguments

  • X: Matrix of predictor variables, with n rows
  • w: Vector of weights (should all be nonnegative), of length n

Returns

An n×nn \times n matrix. This is the "hat matrix" for a WLS regression.