2016-08-02 5 views
1

私は、抗生物質の適切な投与量への準拠を監視するプロジェクトで医師と協力しています。準拠していないイベントの割合を追跡するために、医師は、私は上記および下記3リミットライン(対応する1、2、及び3つのSDS)とP-グラフを生成したいP charts複数のラインを持つR管理図

を使用したいです中心線。私はこれを行う方法を見つけていない。また、私はqichartsパッケージではできますが、他のパッケージではできないいくつかの時間帯にデータを分けるいくつかのブレークを持つようにしたいと思います。

Pチャートを生成するためのR用のパッケージがいくつかあります。私が一番気に入っているのはqichartsです。 qichartsの標準P-Chart、および私が見てきた他のパッケージはすべて、中心線と上部制御限界と中心線からの+3および-3 SDの制御下限を持つプロットを生成します。

+1、+2、-1、-2のSDコントロールラインを同じプロットで生成する方法を理解したいと思います。あなたは、単にデータを提示する必要がある場合には、

# 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') 
+0

これを実現するには、実際にパッケージのソースコードを変更する必要があると思います。 ** qic.R **では、https://cran.r-project.org/web/packages/qicharts/index.htmlの** qicharts_0.5.1.tar.gz **から入手できます。776-780行目はたぶん始めるのがいいでしょう - パッケージはここで限界を計算します。 – tluh

+0

ありがとうございましたが、私はもっと簡単な方法があると思っていました。おそらく、別のパッケージや回避策があるかもしれません。 – user3072084

答えて

1

:そのよう

LimitLines = c(1, 2, 3) where the default is LimitlLines = 3 

などの一部のオプションは、ここでグラフを作成し、データを生成するために、r-projectsから変更され、コードであり、2つのブレークを含めます自分でチャートを作成するのは簡単です。必要に応じて機能を変更して、より簡単にしてください。

データ:

Groups <- c(120, 110, 150, 110, 140, 160, 100, 150, 100, 130, 130, 100, 120, 110, 130, 110, 150, 110, 110) 
Errors <- c(4, 3, 3, 3, 0, 6, 2, 2, 1, 5, 1, 5, 1, 1, 0, 1, 4, 0, 0) 
Week <- length(Groups) #optional: input vector of week numbers 
PchartData <- data.frame(Week,Groups,Errors) 

機能:

Shewhart.P.Chart <- function(Groups, Errors, Week) 
{ 
## Create from scratch 
# p value 
p <- Errors/Groups 
# pbar 
pbar <- mean(p) 
# calculate control limits 
UCL3 <- pbar+3*sqrt((pbar * (1 - pbar))/Groups) 
UCL2 <- pbar+2*sqrt((pbar * (1 - pbar))/Groups) 
UCL1 <- pbar+1*sqrt((pbar * (1 - pbar))/Groups) 
LCL1 <- pbar-1*sqrt((pbar * (1 - pbar))/Groups) 
LCL2 <- pbar-2*sqrt((pbar * (1 - pbar))/Groups) 
LCL3 <- pbar-3*sqrt((pbar * (1 - pbar))/Groups) 
## adjust the minimal value of the LCL to 0 
LCL3[LCL3 < 0] <- 0 
LCL2[LCL2 < 0] <- 0 
LCL1[LCL1 < 0] <- 0 
# plot pvalues 
plot(c(1:length(Groups)),p, ylim = c(min(LCL3,p),max(UCL3,p)), 
    main = "p Chart \n for Prescription Errors", xlab = "weeks", 
    ylab = 'Proportion nonconforming', col = "green", pch = 20, 
    lty = 1, type = "b") 
# add centerline reference 
abline(h = pbar, col = "red") 
# plot control limits at ±1s, 2s, and 3s 
lines(c(1:length(Groups)),UCL1, col = "blue", lty = 2) 
lines(c(1:length(Groups)),UCL2, col = "blue", lty = 2) 
lines(c(1:length(Groups)),UCL3, col = "blue", lty = 2) 
lines(c(1:length(Groups)),LCL3, col = "blue", lty = 2) 
lines(c(1:length(Groups)),LCL2, col = "blue", lty = 2) 
lines(c(1:length(Groups)),LCL1, col = "blue", lty = 2) 
} 

ブレークを簡単に前述に追加することができ、あなただけそれに応じてデータを分離する必要があります。ただし、使用されるプロセスに変更がない場合は、限界値の計算を変更しないでください。また、プロセスが統計的に制御できず、標準化が必要な場合もあります。

関連する問題