# Simulate one random sample of n=25 # observations from a standard normal # distribution x <- rnorm(25) x # Compute the 75-the percentile of # the sample y <- quantile(x, 0.75) y # Use a single statement to estimate # the 75-th percentile from a simulated # sample of 25 observations from a # standard normal distribution y <- quantile(rnorm(25), 0.75) y # Collect the estimated 75_th percentiles # for 999 additional simulated samples # of size 25 for(i in 1:999) { y <- c(y, quantile(rnorm(25), 0.75) )} # Construct a histogram lab <- "1000 upper quartile estimates (n=25)" hist(y, nclass=20, main=lab) # Obtain the average of the simulated estimates mean(y) # Obtain the standard error of the 1000 # simulated estimates sqrt(var(y)) # Obtain estimates of the lower 2.5-th percentile and # and the upper 97.5-th percentile of the distribution # of the estimates of the upper quartile of a standard # normal distribution for samples of size 25. quantile(y, c(0.025, 0.975)) # Compute the true value of the upper quartile # of a standard normal distribution qnorm(.75)