by Guangming Lang

### Categories

• r

When calculating the bias and precision of a sample estimate to the popluation parameter, because we often don’t know the true value of the population parameter and we often only have one sample, we use a procedure called bootstrap. The idea is simple:

1. treat the sample as the population
2. understand the sampling scheme, i.e., how the sample was taken from the population
3. sample the same number of observations with replacement from the sample according to the same sampling scheme
4. for each of the new samples, calculate its sample statistic. For example, if you’re interested in the mean of the population, you just calculate the sample average. If you’re interested in the sd of the population, you just calculate the sample sd.
5. these sample statistics form a distribution. Take its average and use it as a proxy to the true value of the population parameter. Plug it and the sample statistic of your original sample into the formulas of bias and precision.

The following is a concrete example implementing the above bootstrap procedure using R and some stock price data.

Step 1. Download the monthly adjusted closing price data of VTSMX since Sept 2005 from Yahoo!. Change the class of the time index to yearmon. And calculate continuously compounded returns.

Step 2. Calculate the sample average c.c. returns

Step 3. Calculate bias and precision of the mean using bootstrap.

Step 4. Instead of doing the bootstrap procedure ourselves, we can use the boot() function in the boot library. For example, we can use the following code to calculate the bootstrap bias and precision for the volatility (standard deviation).

Step 5. We can also calculate the bootstrap 95% confidence intervals of the volatility.

Step 6. A common measure in risk management is Value at Risk (VaR). We can find the bootstrap 95% confidence intervals of the VaR assuming the initial investment is \$100,000.