Solved – Monte Carlo experiment to estimate coverage probability

monte carlorself-studysimulation

I'm working on a problem as follows for a course that I'm auditing:

Suppose a 95% symmetric t-interval is applied to estimate a mean, but the
sample data are non-normal. Then the probability that the confidence interval covers
the mean is not necessarily equal to 0.95.
Use a Monte Carlo experiment to
estimate the coverage probability of
the t-interval for random samples of
$\chi^2(2)$ data with sample size $n = 20$.

Here is the current state of my R code:

alpha = 0.05;
n = 20;
m = 1000;

UCL = numeric(m);
LCL = numeric(m);

for(i in 1:m)
{
    x = rchisq(n, 2);
    LCL[i] = mean(x) - qt(alpha / 2, lower.tail = FALSE) * sd(x);
    UCL[i] = mean(x) + qt(alpha / 2, lower.tail = FALSE) * sd(x);
}

# This line below is wrong...
mean(LCL > 0 & UCL < 0);

The problem is that the result is $0$. Am I approaching this question incorrectly? What exactly does coverage probability mean…?

Best Answer

I disagree with Henry - I think you should be dividing by sqrt(n), because it's a confidence interval for the mean. You also have to add a df = n-1 argument to your qt calls.

And the last line should be mean(LCL < 2 & UCL > 2). This is because 2 is the true mean, and you're interested in the condition that 2 is in the confidence interval.

Related Question