### What is the difference between ### s^2 = sum(x_i - x.bar)^2 / (n - 1) ### ### t^2 = sum(x_i - x.bar)^2 / n # population parameters lambda <- 5 mu <- lambda mu sigma <- sqrt(lambda) sigma # 100 samples of size n = 30 x <- matrix(rexp(3000,lambda),nrow=30) # compute the s^2 for each sample x.s2 <- apply(x,2,var) # plot the sampling distribution par(mfrow=c(2,2)) hist(x.s2,probability = T,main="sampling distribution of s2") plot(density(x.s2),main="sampling distribution of x.s2",type="l") # compute the mean, bias, se, rmse mean(x.s2) bias.s2 <- mean(x.s2) - sigma^2 bias.s2 se.s2 <- stdev(x.s2) se.s2 RMSE.s2 <- sqrt(bias.s2^2 + se.s2^2) RMSE.s2 # function to compute t2 t2 <- function(x){ t2 <- (n-1)/n*var(x) } # compute the t^2 for each sample x.t2 <- apply(x,2,t2) # plot the sampling distribution hist(x.t2,probability = T,main="sampling distribution of t2") plot(density(x.t2),main="sampling distribution of x.t2",type="l") # compute the mean, bias, se, rmse mean(x.t2) bias.t2 <- mean(x.t2) - sigma^2 bias.t2 se.t2 <- stdev(x.t2) se.t2 RMSE(x.t2,sigma^2) sqrt(bias.t2^2 + se.t2^2)