Question

# Perform Monte-Carlo estimation where theta = E(e^U) where U is a continuous uniform random variable between...

Perform Monte-Carlo estimation where theta = E(e^U) where U is a continuous uniform random variable between zero and one a. Estimate !using 1000 data points and obtain a 95% confidence interval for this case. b. Perform part a) 100 times. Check how often the true !actually does fall within the 100 resulting confidence intervals. Please solve in R.

(a) We use 1000 data points from U[0,1] and estimated theta. The R-codes are given below:

U=runif(1000,0,1)
mean(exp(U))

and the output is:

[1] 1.724483.

To calculate the 95% confidence interval we use the function CI() and we need the package Rmisc.

R-codes are given below:

install.packages("Rmisc")
library(Rmisc)
CI(x, ci = 0.95)

and the output is:

upper mean lower
1.720706 1.717510 1.714314

(b) We now perform the process(a) to get 100 estimates for theta as:

x=replicate(100,mean(exp(runif(1000,0,1))));x

The histogram of x is:

Now to calculate the percentage of estimated values of theta falls in the 95%confidence interval, we use the codes:

length(which(x>1.714314&x<1.720706))

and the output is : 18.