Question: 1. A computer activity. This exercise uses computer simulations to demonstrate that, for heteroscedastic data, unweighted/ordinary least squares (OLS) analysis underestimates the variability of the

1. A computer activity. This exercise uses computer simulations to demonstrate that, for heteroscedastic data, unweighted/ordinary least squares (OLS) analysis underestimates the variability of the estimated slope, while weighted least squares (WLS) analysis estimates it correctly.

The simulated regression model has regression function μY|X(x) = 3 − 2x and error variance function Var(Y|X = x) = (1 + 0.5x2)2.

(a) Generate a set of 100 (x, y) values by x=rnorm(100, 0, 3); y=3-2*x+rnorm(100, 0, sapply(x, function

(x){1+0.5*x**2})). Then use fit=lm(y∼x); summary

(fit), and fitw=lm(y∼x, weights=(1+0.5*x**2)**

(-2)); summary(fitw) and report the standard error of the slope estimate obtained from the OLS and WLS analyses.

(b) The following commands generate 1000 sets of y-values. Like in part (a), obtain the OLS and WLS slope estimates for each set of 100 (x, y) values, and compute the standard deviation of the 1000 OLS slope estimates and of the 1000 WLS slope estimates.

(The x-values stay the same for all 1000 sets of 100 (x, y) values.) These standard deviations are the simulation-based approximations of the true variability of the slope estimates. Compare them with the standard errors or the slope estimates reported in part

(a), and comment. The needed commands for this simulation are:

beta=rep(0, 1000); betaw=rep(0, 1000);

for(i in 1:1000) { y=3-2∗x+rnorm(100, 0, sapply(x, function(x) {1+0.5∗x∗∗2})); beta[i]=lm(y∼x)$coefficients[2];

betaw[i]=lm(y∼x, weights=(1+

0.5∗x∗∗2)∗∗(-2))$coefficients[2]};

sd(beta); sd(betaw)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Bayesian Statistics An Introduction Questions!