DGP_OLS <- function() {
X <- runif(100,2,10)
Y <- X + rnorm(100, sd = sqrt(X))
return(
c("beta_1_hat" = sum(X*Y)/sum(X^2))
)
}
set.seed(1)
# generate 1000 estimates of beta_1 using `GDP_OLS()` and store them in `estimates`
# estimate the variance of the estimator and assign the result to `est_var_OLS`
set.seed(1)
# generate 1000 estimates of beta_1 using `GDP_OLS()` and store them in `estimates`
estimates <- replicate(1000, DGP_OLS())
# estimate the variance of the estimator and assign the result to `est_var_OLS`
est_var_OLS <- var(estimates)
test_predefined_objects("DGP_OLS")
test_object("estimates")
test_object("est_var_OLS")