Calculating Bias in R Write a simulation experiment to estimate the bias of the estimator λˆ= 1/ X¯ by sampling using x=rexp(n,rate=5) and recording the values of 1/mean(x). You should find that the bias is λ/n−1. Here we’ve used λ = 5 but the result will hold for any λ. Here is my solution ( I dont get λ/n−1). Am I doing something wrong here?
set.seed(1)
lambda <- 5
x <- rexp(n= 1e5, rate = lambda )
samp.mean <- mean(x)
lam.est <- 1/samp.mean
lam.est ##4.986549

bias <- abs(lambda - lam.est)
bias ##0.01345146


You computed the outcome of only a single test.
Could you instead write a program that repeats this test a lot of times. Then look at how the distribution of the estimates is. Is the distribution of the estimates centered around $\lambda$ or is there a bias?
