Bootstrap covariance matrix for least squares estimates of linear regression
Bootstrap covariance matrix for least squares estimates of linear regression
This function calculates bootstrapped covariance matrix for least squares estimates of linear regression. The estimates should be obtained via lm function.
boot(model, iter =100)
Arguments
model: object of class lm.
iter: positive integer representing the number of bootstrap iterations.
Returns
This function returns a bootstrapped covariance matrix of the least squares estimator.
Details
Calculations may take long time for high iter value.
Examples
set.seed(123)# Generate data according to linear regressionn <-20eps <- rnorm(n)x <- runif(n)y <- x + eps
# Estimate the modelmodel <- lm(y ~ x)# Calculate bootstrap covariance matrixboot(model, iter =50)