Closed rjake closed 5 years ago
Part and freeze not working together is deliberate. Can you give an example of a situation where your suggestion would be useful?
This comes up at work where multiple centerline shifts occur. We may do multiple interventions and want to freeze the baseline at some point after the last intervention. Perhaps there is a way to do this that is already part of qic.
The work around we've been using is to exclude
points after a new baseline has been set, even though data are still coming in. Since we're using this to host dashboards that generate new data daily, this is really why we desire to freeze
a baseline. Because once the process is stable again, we don't want newer data points to effect our current baseline
Yes, when the baseline centre has been established it makes sense to fix the mean or median to that value. But I fail to see why and how it makes sense to mix freeze and part. Freeze is for establishing a baseline to test new data against. Part may be of use when the process has shifted in the desired direction and the cause is known. See: https://anhoej.github.io/qicharts2/articles/qicharts2.html
Could you use the cl argument for your purpose to fix the centre line to a known value, which could come from historical data or from some target value?
Please get back if I misunderstand your purpose. It might help with a reproducible example where mixing freeze and part makes sense.
Thank you for getting back to us. Could you help us understand how to use the cl
argument works? We haven't used it before and couldn't lock the new center line. Using the code below, can you help us re-write it to lock the center line to 0.0033 after the 5th month?
library(qicharts2)
library(tidyverse)
df <-
hospital_infections %>%
filter(infection == "UTI",
hospital == "BOH")
qic(month, n, days,
data = df,
chart = 'u',
point.size = 4,
multiply = 1000,
cl = c(0.0005, 0.0033),
part = 5,
freeze = 9)
Here is our actual example. We would like the positions of the first chart and the colors of the second
df <-
tibble(
date = 1:38,
y = c(
69, 69, 61, 61, 65, 67, 69, 71, 69, 70, 69, 71, 69,
70, 57, 44, 48, 46, 46, 47, 39, 39, 42, 43, 35, 40, 41, 42,
39, 37, 39, 37, 28, 33, 32, 30, 31, 25
)
)
qic(
data = df,
x = date,
y = y,
chart = "xbar",
part = c(15),
exclude = c(28:38),
point.size = 3,
y.expand = 0
)
qic(
data = df,
x = date,
y = y,
chart = "xbar",
part = c(15, 27),
part.labels = c("baseline", "intervention #1", "intervention #2"),
point.size = 3,
y.expand = 0
)
It ain't pretty, but this works. No promises, but I'll think about a more elegant solution.
library(tidyverse) library(qicharts2) library(gridExtra)
df <- tibble( date = 1:38, y = c( 69, 69, 61, 61, 65, 67, 69, 71, 69, 70, 69, 71, 69, 70, 57, 44, 48, 46, 46, 47, 39, 39, 42, 43, 35, 40, 41, 42, 39, 37, 39, 37, 28, 33, 32, 30, 31, 25 ) )
p1 <- qic(date, y, data = filter(df, date < 16), y.expand = range(df$y), title = NULL, xlab = NULL, part.labels = 'Baseline') + theme(panel.border = element_blank(), plot.margin = margin(r = 0)) + scale_x_continuous(breaks = c(5, 10))
p2 <- qic(date, y, data = filter(df, date > 15), y.expand = range(df$y), part = 27 - 15, title = NULL, ylab = NULL, xlab = NULL, part.labels = c('Intervention #1', 'Intervention #2')) + theme(axis.ticks.y = element_blank(), panel.border = element_blank(), plot.margin = margin(l = 0))
grid.arrange(p1, p2, nrow = 1, widths = c(15, nrow(df) - 15))
We love this function at work. We want to be able to part a baseline mean and then freeze the new mean after a set number of points. It appears we cannot use both part and freeze together when using
qic()
. Below is an example of the desired output but not a good example of best practices.Tagging @pwildenhain to follow the discussion.
Thanks a ton.