if (method == "fastLmPure"){ # tmp <- fastLmPure(X,y) tmp <- fastLmPure(X,t(y)) # coef_all <- tmp$coefficients # id_resid__Fhat_xreg2[i,] <- tmp$residuals # id_resid__Fhat_xreg2[index(data[i,]),] <- tmp$residuals # better with index ("rowname") rm(tmp) } else if (method == "lm"){ tmp <- lm(t(y)~X-1) coef_all <- tmp$coefficients # lm function w/o intercept, the intercept might be put before (by adding column of 1 or not) in X id_resid__Fhat_xreg2[index(data[i,]),] <- tmp$residuals rm(tmp) }