Get hat matrix from QR decomposition for weighted least square regression
问题 I am trying to extend the lwr() function of the package McSptial , which fits weigthed regressions as non-parametric estimation. In the core of the lwr() function, it inverts a matrix using solve() instead of a QR decomposition, resulting in numerical instability. I would like to change it but can't figure out how to get the hat matrix (or other derivatives) from the QR decomposition afterward. With data : set.seed(0); xmat <- matrix(rnorm(500), nrow=50) ## model matrix y <- rowSums(rep(2:11