Más aplicaciones estadísticas en:

https://rpubs.com/orlandoan

0. Introducción.

Los datos utilizados son tomados del libro Control estadístico de la calidad de Douglas C. Montgomery.

Datos tomados de la página 289.

nn<-rep(50,30)
dis<-c(12,15,8,10,4,7,16,9,14,10,5,6,17,12,22,8,10,5,13,
       11,20,18,24,15,9,12,7,13,9,6)

1. Fracción disconforme.

grap<-qcc(dis,type="p",sizes=nn,rules = shewhart.rules)

prop1<-c(dis/nn)
plot(prop1,pch=16,type="o")

data.frame(nn,dis,prop1)
##    nn dis prop1
## 1  50  12  0.24
## 2  50  15  0.30
## 3  50   8  0.16
## 4  50  10  0.20
## 5  50   4  0.08
## 6  50   7  0.14
## 7  50  16  0.32
## 8  50   9  0.18
## 9  50  14  0.28
## 10 50  10  0.20
## 11 50   5  0.10
## 12 50   6  0.12
## 13 50  17  0.34
## 14 50  12  0.24
## 15 50  22  0.44
## 16 50   8  0.16
## 17 50  10  0.20
## 18 50   5  0.10
## 19 50  13  0.26
## 20 50  11  0.22
## 21 50  20  0.40
## 22 50  18  0.36
## 23 50  24  0.48
## 24 50  15  0.30
## 25 50   9  0.18
## 26 50  12  0.24
## 27 50   7  0.14
## 28 50  13  0.26
## 29 50   9  0.18
## 30 50   6  0.12
summary(grap)
## 
## Call:
## qcc(data = dis, type = "p", sizes = nn, rules = shewhart.rules)
## 
## p chart for dis 
## 
## Summary of group statistics:
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.0800000 0.1600000 0.2100000 0.2313333 0.2950000 0.4800000 
## 
## Group sample size:  50
## Number of groups:  30
## Center of group statistics:  0.2313333
## Standard deviation:  0.421685 
## 
## Control limits:
##            LCL       UCL
##     0.05242755 0.4102391
##     0.05242755 0.4102391
## ...                     
##     0.05242755 0.4102391

2. Carta np.

granp<-qcc(dis,type="np",sizes=nn,rules = shewhart.rules)

summary(granp)
## 
## Call:
## qcc(data = dis, type = "np", sizes = nn, rules = shewhart.rules)
## 
## np chart for dis 
## 
## Summary of group statistics:
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  4.00000  8.00000 10.50000 11.56667 14.75000 24.00000 
## 
## Group sample size:  50
## Number of groups:  30
## Center of group statistics:  11.56667
## Standard deviation:  2.981763 
## 
## Control limits:
##       LCL      UCL
##  2.621377 20.51196

3. Curva característica de operación.

beta3 <- oc.curves(qcc(dis, sizes=nn, type="p", plot=TRUE))

## Warning in oc.curves.p(object, ...): Some computed values for the type II error
## have been rounded due to the discreteness of the binomial distribution. Thus,
## some ARL values might be meaningless.

4. Carta p revisada eliminando las observaciones 15 y 23.

nn2<-rep(50,28)
dis2<-c(12,15,8,10,4,7,16,9,14,10,5,6,17,12,8,10,5,13,
       11,20,18,15,9,12,7,13,9,6)
grap3<-qcc(dis2,type="p",sizes=nn2,rules = shewhart.rules)

summary(grap3)
## 
## Call:
## qcc(data = dis2, type = "p", sizes = nn2, rules = shewhart.rules)
## 
## p chart for dis2 
## 
## Summary of group statistics:
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.080   0.155   0.200   0.215   0.265   0.400 
## 
## Group sample size:  50
## Number of groups:  28
## Center of group statistics:  0.215
## Standard deviation:  0.4108223 
## 
## Control limits:
##            LCL       UCL
##     0.04070284 0.3892972
##     0.04070284 0.3892972
## ...                     
##     0.04070284 0.3892972
granp4<-qcc(dis2,type="np",sizes=nn2,rules = shewhart.rules)

summary(granp4)
## 
## Call:
## qcc(data = dis2, type = "np", sizes = nn2, rules = shewhart.rules)
## 
## np chart for dis2 
## 
## Summary of group statistics:
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    4.00    7.75   10.00   10.75   13.25   20.00 
## 
## Group sample size:  50
## Number of groups:  28
## Center of group statistics:  10.75
## Standard deviation:  2.904953 
## 
## Control limits:
##       LCL      UCL
##  2.035142 19.46486

5. Monitoreo.

nn3<-rep(50,54);nn3
##  [1] 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
## [26] 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
## [51] 50 50 50 50
dis3<-c(12,15,8,10,4,7,16,9,14,10,5,6,17,12,22,8,10,5,13,
11,20,18,24,15,9,12,7,13,9,6,9,6,12,5,6,4,6,3,7,6,2,4,3,6,5,4,8,5,6,7,5,6,3,5)
nn4<-nn3[1:30]
nn5<-nn3[31:54]
prueba<-dis3[1:30]
moni<-dis3[31:54]
q1<-qcc(prueba,sizes=nn4,  type="p")

summary(q1)
## 
## Call:
## qcc(data = prueba, type = "p", sizes = nn4)
## 
## p chart for prueba 
## 
## Summary of group statistics:
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.0800000 0.1600000 0.2100000 0.2313333 0.2950000 0.4800000 
## 
## Group sample size:  50
## Number of groups:  30
## Center of group statistics:  0.2313333
## Standard deviation:  0.421685 
## 
## Control limits:
##            LCL       UCL
##     0.05242755 0.4102391
##     0.05242755 0.4102391
## ...                     
##     0.05242755 0.4102391
q2<-qcc(moni,sizes=nn5,  type="p")

summary(q2)
## 
## Call:
## qcc(data = moni, type = "p", sizes = nn5)
## 
## p chart for moni 
## 
## Summary of group statistics:
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.0400000 0.0800000 0.1100000 0.1108333 0.1200000 0.2400000 
## 
## Group sample size:  50
## Number of groups:  24
## Center of group statistics:  0.1108333
## Standard deviation:  0.3139256 
## 
## Control limits:
##     LCL       UCL
##       0 0.2440207
##       0 0.2440207
## ...              
##       0 0.2440207
qcc(prueba,sizes=nn4, type="p", newdata=moni,newsizes=nn5,ylim=c(0,0.5))

## List of 15
##  $ call        : language qcc(data = prueba, type = "p", sizes = nn4, newdata = moni, newsizes = nn5,      ylim = c(0, 0.5))
##  $ type        : chr "p"
##  $ data.name   : chr "prueba"
##  $ data        : num [1:30, 1] 12 15 8 10 4 7 16 9 14 10 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics  : Named num [1:30] 0.24 0.3 0.16 0.2 0.08 0.14 0.32 0.18 0.28 0.2 ...
##   ..- attr(*, "names")= chr [1:30] "1" "2" "3" "4" ...
##  $ sizes       : num [1:30] 50 50 50 50 50 50 50 50 50 50 ...
##  $ center      : num 0.231
##  $ std.dev     : num 0.422
##  $ newstats    : Named num [1:24] 0.18 0.12 0.24 0.1 0.12 0.08 0.12 0.06 0.14 0.12 ...
##   ..- attr(*, "names")= chr [1:24] "31" "32" "33" "34" ...
##  $ newdata     : num [1:24, 1] 9 6 12 5 6 4 6 3 7 6 ...
##  $ newsizes    : num [1:24] 50 50 50 50 50 50 50 50 50 50 ...
##  $ newdata.name: chr "moni"
##  $ nsigmas     : num 3
##  $ limits      : num [1:54, 1:2] 0.0524 0.0524 0.0524 0.0524 0.0524 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ violations  :List of 2
##  - attr(*, "class")= chr "qcc"

6. Tamaño de muestra variable.

Datos tomados de la página 299.

muest<-c(rep(100,1),rep(80,2),rep(100,1),rep(110,2),rep(100,2),rep(90,2),rep(110,1),rep(120,3),rep(110,1),rep(80,3),rep(90,1),rep(100,4),rep(90,2) )
discon<-c(12,8,6,9,10,12,11,16,10,6,20,15,9,8,6,8,10,7,5,8,5,8,10,6,9)
q3<-qcc(discon,sizes=muest,  type="p")

prop2<-c(discon/muest)
plot(prop2,pch=16,type="o")

data.frame(muest,discon,prop2)
##    muest discon      prop2
## 1    100     12 0.12000000
## 2     80      8 0.10000000
## 3     80      6 0.07500000
## 4    100      9 0.09000000
## 5    110     10 0.09090909
## 6    110     12 0.10909091
## 7    100     11 0.11000000
## 8    100     16 0.16000000
## 9     90     10 0.11111111
## 10    90      6 0.06666667
## 11   110     20 0.18181818
## 12   120     15 0.12500000
## 13   120      9 0.07500000
## 14   120      8 0.06666667
## 15   110      6 0.05454545
## 16    80      8 0.10000000
## 17    80     10 0.12500000
## 18    80      7 0.08750000
## 19    90      5 0.05555556
## 20   100      8 0.08000000
## 21   100      5 0.05000000
## 22   100      8 0.08000000
## 23   100     10 0.10000000
## 24    90      6 0.06666667
## 25    90      9 0.10000000

6. Tamaño de muestra promedio.

n<-mean(muest)
muest2<-rep(n,25)
q4<-qcc(discon,sizes=muest2,  type="p")
n<-mean(muest)
muest2<-rep(n,25)
q4<-qcc(discon,sizes=muest2,  type="p")

beta4 <- oc.curves(qcc(dis, sizes=n, type="p", plot=TRUE))

## Warning in oc.curves.p(object, ...): Some computed values for the type II error
## have been rounded due to the discreteness of the binomial distribution. Thus,
## some ARL values might be meaningless.

beta4
##             0          0.01          0.02          0.03          0.04 
##  0.000000e+00  6.265357e-01  8.619122e-01  9.494606e-01  9.816945e-01 
##          0.05          0.06          0.07          0.08          0.09 
##  9.934399e-01  9.976744e-01  9.991838e-01  9.997093e-01  9.998536e-01 
##           0.1          0.11          0.12          0.13          0.14 
##  9.997369e-01  9.991363e-01  9.973791e-01  9.931400e-01  9.842936e-01 
##          0.15          0.16          0.17          0.18          0.19 
##  9.679861e-01  9.410310e-01  9.006000e-01  8.450274e-01  7.744591e-01 
##           0.2          0.21          0.22          0.23          0.24 
##  6.911060e-01  5.989983e-01  5.033102e-01  4.094627e-01  3.222558e-01 
##          0.25          0.26          0.27          0.28          0.29 
##  2.452391e-01  1.804225e-01  1.283200e-01  8.823582e-02  5.867043e-02 
##           0.3          0.31          0.32          0.33          0.34 
##  3.773214e-02  2.347580e-02  1.413323e-02  8.234920e-03  4.644566e-03 
##          0.35          0.36          0.37          0.38          0.39 
##  2.536011e-03  1.340632e-03  6.861673e-04  3.400162e-04  1.631100e-04 
##           0.4          0.41          0.42          0.43          0.44 
##  7.573731e-05  3.403291e-05  1.479561e-05  6.221134e-06  2.528941e-06 
##          0.45          0.46          0.47          0.48          0.49 
##  9.934413e-07  3.769223e-07  1.380413e-07  4.876679e-08  1.660632e-08 
##           0.5          0.51          0.52          0.53          0.54 
##  5.446273e-09  1.718730e-09  5.213931e-10  1.518795e-10  4.243185e-11 
##          0.55          0.56          0.57          0.58          0.59 
##  1.135483e-11  2.906375e-12  7.104580e-13  1.655830e-13  3.672791e-14 
##           0.6          0.61          0.62          0.63          0.64 
##  7.737903e-15  1.545134e-15  2.917503e-16  5.195843e-17  8.703570e-18 
##          0.65          0.66          0.67          0.68          0.69 
##  1.367170e-18  2.007224e-19  2.744387e-20  3.480535e-21  4.076622e-22 
##           0.7          0.71          0.72          0.73          0.74 
##  4.388515e-23  4.319026e-24  3.863164e-25  3.119902e-26  2.258401e-27 
##          0.75          0.76          0.77          0.78          0.79 
##  1.453329e-28  8.238108e-30  4.070726e-31  1.732875e-32  6.269901e-34 
##           0.8          0.81          0.82          0.83          0.84 
##  1.898611e-35  4.726459e-37  9.474085e-39  1.492320e-40  1.794733e-42 
##          0.85          0.86          0.87          0.88          0.89 
##  1.592242e-44  9.996426e-47  4.221225e-49  1.125661e-51  1.750662e-54 
##           0.9          0.91          0.92          0.93          0.94 
##  1.433398e-57  5.399486e-61  7.795705e-65  3.339486e-69  2.917158e-74 
##          0.95          0.96          0.97          0.98          0.99 
##  2.905275e-80  1.245431e-87  3.700676e-97 1.263449e-110 1.031882e-133 
##             1 
##  0.000000e+00

7. Carta c.

Datos tomados de la página 311.

circ<-c(21,24,16,12,15,5,28,20,31,25,20,24,16,19,10,17,13,22,18,39,30,24,16,19,17,15)
q5<-qcc(circ, type="c")

summary(q5)
## 
## Call:
## qcc(data = circ, type = "c")
## 
## c chart for circ 
## 
## Summary of group statistics:
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##  5.00000 16.00000 19.00000 19.84615 24.00000 39.00000 
## 
## Group sample size:  1
## Number of groups:  26
## Center of group statistics:  19.84615
## Standard deviation:  4.454902 
## 
## Control limits:
##       LCL      UCL
##  6.481447 33.21086

8. Monitoreo.

circ2<-c(16,18,12,15,24,21,28,20,25,19,18,21,16,22,19,12,14,9,16,21)
q6<-qcc(circ2, type="c")

summary(q6)
## 
## Call:
## qcc(data = circ2, type = "c")
## 
## c chart for circ2 
## 
## Summary of group statistics:
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    9.00   15.75   18.50   18.30   21.00   28.00 
## 
## Group sample size:  1
## Number of groups:  20
## Center of group statistics:  18.3
## Standard deviation:  4.27785 
## 
## Control limits:
##      LCL      UCL
##  5.46645 31.13355

9. Carta u.

Datos tomados de la página 317.

tama<-rep(5,20)
total<-c(10,12,8,14,10,16,11,7,10,15,9,5,7,11,12,6,8,10,7,5)
q10<-qcc(total,sizes=tama,type="u")

summary(q10)
## 
## Call:
## qcc(data = total, type = "u", sizes = tama)
## 
## u chart for total 
## 
## Summary of group statistics:
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    1.40    2.00    1.93    2.25    3.20 
## 
## Group sample size:  5
## Number of groups:  20
## Center of group statistics:  1.93
## Standard deviation:  1.389244 
## 
## Control limits:
##         LCL      UCL
##  0.06613305 3.793867

10. Curva característica de operación para la carta u.

beta5 <- oc.curves(qcc(total, sizes=tama, type="u", plot=TRUE))

## Warning in oc.curves.c(object, ...): Some computed values for the type II error
## have been rounded due to the discreteness of the Poisson distribution. Thus,
## some ARL values might be meaningless.

11. Carta u tamaño de muestra variable.

Datos tomados de la página 320.

defec<-c(14,12,20,11,7,10,21,16,19,23)
mue<-c(10,8,13,10,9.5,10,12,10.5,12,12.5)
q11<-qcc(defec,sizes=mue,type="u")

summary(q11)
## 
## Call:
## qcc(data = defec, type = "u", sizes = mue)
## 
## u chart for defec 
## 
## Summary of group statistics:
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.7368421 1.1750000 1.5119048 1.3972447 1.5721154 1.8400000 
## 
## Summary of group sample sizes:                                  
##   sizes  8 9.5 10 10.5 12 12.5 13
##   counts 1 1.0  3  1.0  2  1.0  1
## 
## Number of groups:  10
## Center of group statistics:  1.423256
## Standard deviation:  1.193003 
## 
## Control limits:
##           LCL      UCL
##     0.2914739 2.555038
##     0.1578852 2.688626
## ...                   
##     0.4109593 2.435552

12. Carta de control estandarizada pag 321.

upro<-c(defec/mue);upro
##  [1] 1.4000000 1.5000000 1.5384615 1.1000000 0.7368421 1.0000000 1.7500000
##  [8] 1.5238095 1.5833333 1.8400000
ubarra<-c(sum(defec)/sum(mue));ubarra
## [1] 1.423256
zeta1<-(upro-ubarra)/(sqrt(ubarra/mue));zeta1
##  [1] -0.06164389  0.18194872  0.34818035 -0.85685012 -1.77339822 -1.12191886
##  [7]  0.94876140  0.27311859  0.46481431  1.23504583
plot(zeta1,type="o",ylim=c(-3,3))
abline(h=0,lty=2)
abline(h=-3,lty=2)
abline(h=3,lty=2)

13. Defectos bajos.

Datos tomados de la página 326.

tiempo<-c(286,948,536,124,816,729,4,143,431,8,2837,596,81,227,603,492,1199,1214,2831,96)
y<-tiempo^0.2777;y
##  [1] 4.809865 6.709029 5.726497 3.813671 6.435412 6.237053 1.469576 3.967682
##  [9] 5.390069 1.781509 9.096180 5.897744 3.388335 4.510954 5.916898 5.591891
## [17] 7.161238 7.186005 9.090833 3.552031
qcc(y, type="xbar.one")

## List of 11
##  $ call      : language qcc(data = y, type = "xbar.one")
##  $ type      : chr "xbar.one"
##  $ data.name : chr "y"
##  $ data      : num [1:20, 1] 4.81 6.71 5.73 3.81 6.44 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named num [1:20] 4.81 6.71 5.73 3.81 6.44 ...
##   ..- attr(*, "names")= chr [1:20] "1" "2" "3" "4" ...
##  $ sizes     : int [1:20] 1 1 1 1 1 1 1 1 1 1 ...
##  $ center    : num 5.39
##  $ std.dev   : num 2.09
##  $ nsigmas   : num 3
##  $ limits    : num [1, 1:2] -0.888 11.661
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"

|-|-|-|

O.M.F.

|-|-|-|