我正在与医生合作开展一个项目,以监测对适当剂量抗生素的依从性。为了跟踪不合规事件的比例,医生喜欢使用P 图表
我想生成一个 P 图表,在中心线上方和下方有3 条限制线(对应于 1、2 和 3 个标准差)。我还没有找到一种方法来做到这一点。我还希望情节有几个中断,将数据分成几个时间段,我可以在 qicharts 包中做到这一点,但不能在其他包中做到这一点。
R 有几个包用于生成 P 图表。我最喜欢的是qicharts。qicharts 的标准 P-Chart 以及我见过的所有其他软件包都生成了一个绘图,其中包含一条中心线和一个控制上限以及一个控制下限,位于中心线的 +3 和 -3 SD 处。
我想弄清楚如何在同一个图上生成额外的 +1、+2 和 -1、-2 SD 控制线。一些选项,例如
LimitLines = c(1, 2, 3) where the default is LimitlLines = 3
这是从r-projects修改的代码,用于生成数据、创建图表并包含两个中断:
# Setup parameters
m.beds <- 300
m.stay <- 4
m.days <- m.beds * 7
m.discharges <- m.days / m.stay
p.pu <- 0.08
# Simulate data
discharges <- rpois(24, lambda = m.discharges)
patientdays <- round(rnorm(24, mean = m.days, sd = 100))
n.pu <- rpois(24, lambda = m.discharges * p.pu * 1.5)
n.pat.pu <- rbinom(24, size = discharges, prob = p.pu)
week <- seq(as.Date('2014-1-1'),
length.out = 24,
by = 'week')
# Combine data into a data frame
d <- data.frame(week, discharges, patientdays,n.pu, n.pat.pu)
# Create a P-chart to measure the number of patients with pressure ulcers (n.pat.pu) each week (week) as a proportion of all discharges (discharges) with breaks one third (8) and two thirds (16) of the way through the data
qic(n.pat.pu,
n = discharges,
x = week,
data = d,
chart = 'p',
multiply = 100,
breaks = c(8,16),
main = 'Hospital acquired pressure ulcers (P chart)',
ylab = 'Percent patients',
xlab = 'Week')