A. Using again the black cherry tree data set trees in R, carry
out
simulations to compare the following sampling strategies for
estimating
total volume of wood in the population. Here the population size N
is
31 and the variable of interest is tree volume.
Strategy 1: The design simple random sampling, sample size n =
15, and
the expansion estimator tau hat = N ybar, where ybar is the sample
mean.
Strategy 2: Unequal probability sampling of trees, with
replacement,
with n = 15 independent draws, and the probability of drawing tree
i
on any draw is proportional to tree girth (size of tree near
the
ground). Use the Horvitz-Thompson estimator of the population
total.
Note that the details of selecting units with unequal probability
for
this design are given in the computing section of Chapter 6.
Your comparison of the two strategies should include graphics
such as
histograms of estimates and calculations from the simulations of
bias
and mean square error.
Write a one or two sentence conclusion on your comparison.
PLZ show R code!!
library(datasets)
d=trees;d
y=d$Volume;x=d$Girth
N=31;n=15;p=0.15
M=mean(y);M
#Strategy 1
ybar=numeric()
for(i in 1:100)
{
s=sample(1:N,n)
ybar[i]=mean(y[s])
}
ybar
hist(ybar)
tau_hat=N*ybar;tau_hat #Expansion estimator
#Bias and MSE
mean(ybar)
mean(ybar-M)
var(ybar)
mean((ybar-M)^2)
#Strategy 2
#Sample mean with unequality probability sample.
mean(y[s])
unique(s)
m1=mean(y[s]/x[s]);m1
p=x/sum(x)
pinc=1-(1-(p))^n;pinc #inclusion probabilities
b=sum(y[unique(s)]/pinc[unique(s)])/N;b #Horvitz estimayor
t=unique(s);y[t]
#Bias and MLE
mean(m1)
mean(m1-mu)
var(m1)
mean((m1-M)^2)
#Conclusion
#Sampling distributions of the two strategies are compared by drawing the histogram of ybar
****
Get Answers For Free
Most questions answered within 1 hours.