# Correct way of building a confidence interval

My AR(1) model is $y_t = \phi y_{t-1} + \epsilon_t \quad where \quad \epsilon_t \sim \mathcal{N}(0,1)$

Here $\sigma^2 = Var(\epsilon_t) = 1$

Basically in this code I generate random values for phi and then try to recover that value using a dlm model just to see if I am using dlm correctly.

Method 1.
Do for i = 100 times:
Do for j = 100 times:
1. Randomly generate phi between 0 and 1.
2. Generate an AR1 series with phi and sigma^2=1
3. build a dlm model and construct a 95% CI for phi using MLE and delta method
count[i] = number of times out of j=100 the CI contains phi.

vs

Method 2.

Do for i = 100 times:
1. Randomly generate phi between 0 and 1.
2. Generate an AR1 series with phi and sigma^2=1
Do for j = 100 times:
3. build a dlm model and construct a 95% CI for phi using MLE and delta method

count[i] = number of times out of j=100 the CI contains phi.

Which of the above 2 methods is more appropriate?

In either case the vector count should be Binomial(n=100,size=100,p=.05). Is this correct?

• You use the values from the time series y$_t$ to estimate $\phi$ and the variability of the estimate determines the confidence interval for $\phi$. Generating a uniform distribution for $\phi$ does not make sense. Commented Apr 19, 2017 at 12:24