require(utils)
set.seed(129)
n <- 7 ; p <- 2
X <- matrix(rnorm(n * p), n, p) # no intercept!
y <- rnorm(n)
w <- rnorm(n)^2
str(lmw <- lm.wfit(x = X, y = y, w = w))
str(lm. <- lm.fit (x = X, y = y))
if(require("microbenchmark")) {
mb <- microbenchmark(lm(y~X), lm.fit(X,y), .lm.fit(X,y))
print(mb)
boxplot(mb, notch=TRUE)
}
Run the code above in your browser using DataCamp Workspace