Let us say I have daily measurements of a KPI with potential gaps (i.e. no measurements some days) and sometimes several measurements per day. How would one apply the running median (see for example here) in this situation? The intention is to show a trend of the underlying process's KPI. Should one average the values for days with several measurements (e.g. using the median)?

I have used statistical process control charts (SPCCs) and applied box-cox transformations but am not to sure whether the underlying assumption of normality is violated.

I read somewhere that one can use (monthly ?) bootstrapping and then apply SPCCs. Pretty sure I could program this but I lack the "statistical confidence" to judge whether it is worthwhile.


  • $\begingroup$ What do you hope the running median will do? What property of the process is it intended to reflect, or how do you plan on interpreting or using it? There's no way to provide an objective answer without such information. $\endgroup$
    – whuber
    Jan 13, 2021 at 15:30
  • $\begingroup$ obviously this is already closed so not sure if commenting helps? Maybe whoever closed it, should at least give me a chance without shooting me down immediately? Any way it is quite common to have daily measurements of some KPI. A very basic approach is to take the monthly medians and look at the trend over time. I also used methods from statistical process control. The latter requires normal distributed data so I used the box cox transformation but I would also like to look at the trend of the data as moving median. Not sure, if this makes more sense? $\endgroup$
    – cs0815
    Jan 13, 2021 at 16:16
  • $\begingroup$ You've been here awhile, so it's time to read our help to learn how SE sites work. A closed question is not "shot down:" it is merely in suspension awaiting edits for clarification, at which point users can vote to reopen it. This prevents people from wasting their time answering the question they thought was being asked only to discover later that a different question was intended. $\endgroup$
    – whuber
    Jan 13, 2021 at 16:59
  • $\begingroup$ @whuber I edited my question, which conveys the issue/intend. $\endgroup$
    – cs0815
    Jan 13, 2021 at 17:09
  • $\begingroup$ You seem to be trying to ask two or three questions at once. Could you explicitly connect SPCCs, the running median, the idea of averaging values, and bootstrapping for us so we can see how they are describing a coherent issue? What is your objective here? $\endgroup$
    – whuber
    Jan 13, 2021 at 17:12

2 Answers 2


It is hard to gauge how any method would work without even seeing sample data, but the possibilities include

  • summarizing the last so many values, by a median, or mean, or more generally a trimmed mean

(in this case, consider downweighting according to time elapsed)

  • summarizing each day, ditto, and just leaving blank days without measurements.

Whatever you do, graphing data and results is essential. (Fine if that is obvious.)

There is no assumption of normality underlying descriptive or exploratory smoothing, although a skewed conditional distribution will affect means more than medians. Trimmed means appear a little non-standard in this territory, but they allow tunable compromise between mean and median.

Box-Cox I personally consider oversold, although not by its original authors (no relation): in the majority of cases, there are two leading possibilities, leaving the data as they come and working on a logarithmic scale.

It is hard to know how you should think about outliers: in a business context, very high or very low values might tell you about past events you know about that aren't part of your decision-making, or they might be important detail you shouldn't discount.

  • $\begingroup$ I think some weighting is probably essential given the circumstances described; downweighting by time elapsed would correspond to the first or second option in my answer. $\endgroup$
    – Matt F.
    Jan 25, 2021 at 21:06
  • $\begingroup$ @Nick - thanks Nick and sorry for taking so long before coming back to you. You mentioning "outliers" being interesting. I guess using a trimmed mean would be contradictory then? $\endgroup$
    – cs0815
    Feb 5, 2021 at 8:29
  • $\begingroup$ Trimmed means tell you about the general level of the middle of your data, where middle is defined by how much you trim. Calculating a trimmed mean is entirely consistent with recognising outliers: indeed it is motivated by realising that those outliers pull a plain mean towards them, which may not be desirable. $\endgroup$
    – Nick Cox
    Feb 5, 2021 at 8:43

Suppose the running median was intended to be the median of 7 values, observed at noon every day of the past week. With irregular observations, one alternative is to take the median of 168 values over all the hours of the past week. The question is then how to fill in the values at the many unobserved hours.

Depending on the KPI and the measurement procedure, you might fill in the value for an unmeasured hour with:

  • the last measurement before the unmeasured hour
  • the first measurement after the unmeasured hour
  • a linear interpolation between the above two measurements
  • any of the above adjusted for the time of day, e.g. adding the expected difference between noontime and nighttime temperatures to any nighttime temperature observation
  • a value from some hourly model fitted to the observed data

If you actually get data once a day at noon as intended, then the first four of these procedures will all give the same value that you would have gotten from the median of the seven daily measurements.

None of this refers to SPCCs, transformations, or an assumption of normality, but it may be enough for a transparent demonstration of trends.


Your Answer

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

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