我已经编写了这个函数,希望获得用于统计质量控制的非参数休哈特标志控制图。功能是: -
Shewhart.Sign<-function(data,size)
{
y<- as.matrix(data,ncol=size)
n<-nrow(data)
p<-ncol(y)
center<-0
##Charting Statistic SNt##
Rnk<-t(apply(y,1,rank))
Sgn<-t(apply(y,1,sign))
med<-369
Calc<-t(apply(x-med,1,sign))
Psi<-Calc*Rnk
SNt<-t(t(apply(Psi,1,sum))
U<-10
##Upper & Lower Control Limits##
UCL<- +U
LCL<- -U
## Drawing the Shewhart Sign Control_Chart ##
xmin <- 1; xmax <- n
ymin <- LCL; ymax <- UCL
x<-seq(from=1, to=n, by=1)
plot(x, SNt,xlim=c(xmin,xmax), ylim=c(ymin,ymax),pch=16, cex=1.25,
col="red", type="b", xlab= "Subgroup",ylab=expression(paste("SNt")),
main="Shewhart Sign Control Chart")))
abline(h=UCL, col = "red", lty = 2)
abline(h=LCL, col = "red", lty = 2)
abline(h=0, col="black",lty=2)
}
但是我一直收到这个错误: -
> Shewhart.Sign<-edit()
Error in .External2(C_edit, name, file, title, editor) :
unexpected symbol occurred on line 15
use a command like
x <- edit()
to recover
我似乎无法在我的功能中找到错误
答案 0 :(得分:0)
使用以下数据和7
的大小,最后的函数Shewhart.Sign(V,7)
似乎提供了您正在寻找的图表。
V <- c(-.01,-.04,.08,-.08,.03,-.02,.08,-.05,.01,.01,.06,0,0,.11,.06,-.05,-.01,-.03,.04,.05,.07,.03,-.02,.02,.04,.02,-.01,.08,.02,.07,.01,.03,.01,.01,.08,.11,.10,.12,.12,.13,.12,.06,.08,.11,.12,.12,.13,.12,.06,.07,.04,.06,.07,.07,.05,.07,.04,.01,.01,0,-.02,.03,.08,-.01,.04,.02,0,.01,.01,.14)
功能:
Shewhart.Sign<-function(data,size)
{
y<-matrix(data, ncol = size, byrow = TRUE)
n<-nrow(y)
p<-ncol(y)
center<-0
##Charting Statistic SNt##
Rnk<-t(apply(y,1,rank))
Sgn<-t(apply(y,1,sign))
med<-369
Calc<-t(apply(y-med,1,sign))
Psi<-Calc*Rnk
SNt<-t(t(apply(Psi,1,sum)))
d<-0 # The number of signs that should signal an error
U<-2*d-p
##Upper & Lower Control Limits##
UCL<- +U
LCL<- -U
## Drawing the Shewhart Sign Control_Chart ##
xmin <- 1; xmax <- n
ymin <- LCL; ymax <- UCL
x<-seq(from=1, to=n, by=1)
plot(x, SNt,xlim=c(xmin,xmax), ylim=c(ymin,ymax),pch=16, cex=1.25,
col="red", type="b", xlab= "Subgroup",ylab=expression(paste("SNt")),
main="Shewhart Sign Control Chart")
abline(h=UCL, col = "red", lty = 2)
abline(h=LCL, col = "red", lty = 2)
abline(h=0, col="black",lty=2)
}