简体   繁体   中英

Shewhart Sign Control Chart

I have written this function in the hope of obtaining a Nonparametric Shewhart Sign Control Chart used in statistical quality control. The function is:-

    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)
    }

However I keep getting this error:-

    > 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

I can not seem to locate the mistake in my function

Using the following data and a size of 7 , the function at the end, Shewhart.Sign(V,7) , seems to provide the chart you are looking for.

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)

The function:

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)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM