6
$\begingroup$

I'm measuring error on the median of my data using bootstrapping. I would like to obtain I sigma error bars on my data, so I'm measuring the 16th and 84th percentiles of my data. Should I divide these percentile values by the square root of the number of data or not? Thanks in advance.

$\endgroup$
3
  • $\begingroup$ The sample standard deviation of a median is inversely proportional to the height of the PDF at the median. Thus the 16th and 84th percentiles are irrelevant. $\endgroup$
    – whuber
    Commented May 2, 2013 at 22:11
  • 1
    $\begingroup$ BTW, I'm surprised not to see more upvotes for this question: it has attracted three answers, which is prima facie evidence that it is a worthy and interesting question. It's especially remarkable that nobody who has answered has upvoted the question! What's up with that, people? $\endgroup$
    – whuber
    Commented May 2, 2013 at 22:12
  • 1
    $\begingroup$ Forgetfulness - my apologies. I am wondering about your first comment. The expected value of the 84th percentile minus the 16th percentile is $2 \sigma$ for a normal distribution, which is the limiting distribution for the sample median. So the poster's proposal of making use of those sample percentiles is an option to be considered. $\endgroup$
    – soakley
    Commented May 3, 2013 at 13:49

3 Answers 3

1
$\begingroup$

Since you are bootstrapping, why not take all of your observed medians and calculate the sample standard deviation $s$ and use that as your estimator of $\sigma$?

$\endgroup$
3
  • $\begingroup$ So if I measure s, the error bars on my median are given by σ+s and σ-s, right? $\endgroup$
    – Marika
    Commented May 3, 2013 at 9:29
  • $\begingroup$ $\sigma$ is unknown. If the sample mean of all of your bootstrapped medians is $\bar x$, then if you want to estimate a range of plus or minus 1 standard deviation, you would use the range $\bar x - s$ to $\bar x + s$. $\endgroup$
    – soakley
    Commented May 3, 2013 at 13:33
  • $\begingroup$ Sorry, I just wanted to write x¯ instead of σ. Perfect, thanks a lot! $\endgroup$
    – Marika
    Commented May 3, 2013 at 15:25
1
$\begingroup$

If I am understanding your intent, then the answer is "no", don't divide. The sample size is taken into account as part of the bootstrapping process. Of course the values that are using will mostly be meaningful if everything is normally distributed, the fact that you are bootstrapping makes that seem an unlikely assumption. Skewness could really throw this off. Are you dividing the distance from 16th to 84th by 2? If not that could be why you think you need to dived by something.

In general (and good to do here to check if I understood you and even if this method will work for your case) you can answer questions like this through a little simulation. Simulate a data set and do the above analysis, calculate the value both ways and see which is closest to the "true" value from the simulation. Repeat the process with a different sample size, also simulate from different distributions. It should become fairly clear after a few simulations whether to divide or not.

$\endgroup$
3
  • $\begingroup$ First of all I have the median of my data (the point I want to plot). Then, after bootstrapping I have the distribution of all the median, which in priciple should be gaussian. So if I want to plot the error bar on the point I have plotted, there are two ways of plotting error bars: 1) measuring the sigma so the errors are median+sigma and median-sigma 2) taking the 16 and 84th percentiles so errors are median-16th and median+84. Should I divide by a factor of 2 in the second case? $\endgroup$
    – Marika
    Commented May 3, 2013 at 7:59
  • $\begingroup$ If you are plotting the error bars then just go from the percentiles without dividing by 2. If you want a numerical estimate of the standard error based on the 16th and 84th percentile, then you would divide the distance between them by 2. $\endgroup$
    – Greg Snow
    Commented May 3, 2013 at 14:05
  • $\begingroup$ Thanks Greg. I also checked median+sigma/median-sigma are more or less similar to 84th-median/median-16th. So the problem is solved. $\endgroup$
    – Marika
    Commented May 3, 2013 at 15:32
1
$\begingroup$

Following along the lines developed by Greg and soakley, here's a function that calculates the (bootstrapped) standard errors of an estimate of the median:

median.w.se = function(vec,B){
  # Inputs:  vector of data (vec)
  #          number of bootstrap replicates (B)
  # Outputs: list with estimates of median and standard error
  empty.vec = rep(NA,B)
  for(i in 1:B){
  curr.sample = sample(vec,length(vec),replace = TRUE)
  curr.med    = median(curr.sample)
  empty.vec[i] = curr.med
  }
  lst = list(median = mean(empty.vec), se = sd(empty.vec))
  return(lst)
}

data(iris)
median.w.se(iris$Sepal.Length,1000)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.