[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**Muestreo y estadísticas oficiales - El blog de Andrés Gutiérrez**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Assume we want to know the mean square error (MSE) of the *sample median* as a estimator of a *population mean *under normality. As you know, this is not a trivial problem. We may take advantage of the Bootstrap method and solve it by means of simulation.

This way, for $b=1,\ldots, B$, we generate $X_{b1},\ldots, X_{bn} \sim N(\hat{\mu}, \hat{\sigma}^2)$. Then, we compute the sample median $\tilde{X}_b$ for each sample in the bootstrap. Finally, an estimator of the MSE is given by

$$\widehat{MSE} = B^{-1} \sum_{b=1}^B(\tilde{X}_b – \hat{\mu})^2$$

In R, the simulation should look like this for a sample size of ten units:

To

**leave a comment**for the author, please follow the link and comment on their blog:**Muestreo y estadísticas oficiales - El blog de Andrés Gutiérrez**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.