An exercise displayed in the image below shows example of finding the efficiency of an estimator. I am trying to replicate this example in R using monte carlo. Y1,Y2,Y3 are random samples of normal distribution.

The steps I thought I can take is using R function would be rnorm() as this function generates random numbers from a normal distribution. I can hard code in the calculation for mu1 and mu2 using the formula given with the three random sample numbers. We can use the randomly generated numbers generated for Y1, Y2, and Y3 and input them into the mu1 and mu2 functions stated in Example 5.4.5. and then find the variance of the two mu functions. We can find the relative efficiency by divide mu1/mu2.

I started off with code with a rnorm of 3:

```
Y <- rnorm(3)
mu1 = 0.25*X[1] + 0.5*X[2] + 0.25*X[3]
mu2 = (1/3)*X[1] + (1/3)*X[2] + (1/3)*X[3]
```

I can further get random deviates with:

```
Y <- replicate(1000,rnorm(3))
```

Would my next step be trying to store each mu1,mu2 to create a 2×1000 matrix? And use that matrix to get the variance through variance function in R?

## Best Answer

I am not shure, whether I understood the question correctly but maybe a wrong answer is the best basis for an improved question?

We want 1000 instances of $Y_1$, $Y_2$ and $Y_3$:

Now we can compute the $\mu$ vectorwise:

And then variances are

Edit:It's easy to compute this many times as in