Guide Questions:
1. Does the simulation exercise support the algebraic results on the expected values of muhat and mutilde?
2. Which of the two is more asymptotically efficient?
Below is the sample R script for the first part of the Monte Carlo exercise to investigate the properties of two competing estimators of the population mean:
# Monte Carlo Exercise 1
# The purpose of this exercise is to learn
# the properties of the sampling distribution
# of muhat (arithmetic mean) and mutilde (min plus max divided by two)
# when the parent distribution is Normal
rm()
nobs = 30
nsim = 100
# muhat when R.V. is from Normal
mu.bar.vals = rep(0,nsim)
set.seed(223)
for (i in 1:nsim) {
z = rnorm(nobs)
mu.bar.vals[i] = mean(z)
}
mubar.mean = mean(mu.bar.vals)
mubar.mean
x.vals1 = seq(from=min(mu.bar.vals), to=max(mu.bar.vals), length=300)
y.vals1 = dnorm(x.vals1, mean=0, sd = 1/sqrt(nobs))
hist(mu.bar.vals, probability=T, main="Distribution of Mubar and Normal Approximation", sub="N(0,1), T=30")
points(x.vals1, y.vals1, type="l")
# mutilde when R.V. is from Normal
mu.tilde.vals = rep(0,nsim)
set.seed(223)
for (i in 1:nsim) {
w = rnorm(nobs)
mu.tilde.vals[i] = (min(w)+max(w))/2
}
mutilde.mean = mean(mu.tilde.vals)
mutilde.mean
x.vals2 = seq(from=min(mu.tilde.vals), to=max(mu.tilde.vals), length=300)
y.vals2 = dnorm(x.vals2, mean=0, sd = sqrt(1/2))
hist(mu.tilde.vals, probability=T, main="Distribution of Mutilde and Normal Approximation", sub="N(0,1), T=30")
points(x.vals2, y.vals2, type="l")