RepetPlan is an R package developed to obtain failured-censored repetitive group sampling plans.
To install the current version of the code from Zenodo:
if(!require(zen4r)){install.packages("zen4r")} #install if needed
zen4r::download_zenodo("10.5281/zenodo.5035779")
install.packages("RepetPlan-1.0.3.zip", repos = NULL)
To install the current version of the code from GitHub:
if(!require(devtools)){install.packages("devtools")} #install if needed
devtools::install_github("ULL-STAT/RepetPlan")
To load the RepetPlan package:
# load library and dependant libraries
library(RepetPlan)
To see all available functions in the package use the command below
# To get index of help on all functions
help(package="RepetPlan")
Suppose that T represents a lifetime variable and X = log (T) follows a log-location and scale distribution. This is an example which shows how to determine the designs of conventional censored repetitive sampling plans for the given requirements of maximum risks and quality levels
risks<-c(0.05,0.10) #vector of producer and consumer maximum sampling risks
p<-c(0.00654, 0.0426) #vector of acceptance and rejection quality levels
q<- 0.1 #censoring degree
asvar<-asympt.var(q,"normal") #asymptotical variance-covariance matrix of MLE estimators of location and scale paramters
designs<-rep.plan(risks,p,asvar) #designs satisfying the previous requirements
The first designs returned by the function rep.plan() are
q | n | kr | ka | termcd | message | p_alpha | p_beta | dist | alpha | beta | asn_alpha | asn_beta | asn_avg | p_asn_max | asn_max |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0.1 | 49 | 2.053225 | 2.055370 | 1 | Function criterion near zero | 0.00654 | 0.0426 | normal | 0.05 | 0.1 | 49.04823 | 49.06290 | 49.05557 | 0.0188643 | 49.16223 |
0.1 | 48 | 2.048891 | 2.060242 | 1 | Function criterion near zero | 0.00654 | 0.0426 | normal | 0.05 | 0.1 | 48.25590 | 48.32952 | 48.29271 | 0.0188293 | 48.84398 |
0.1 | 47 | 2.044397 | 2.065329 | 1 | Function criterion near zero | 0.00654 | 0.0426 | normal | 0.05 | 0.1 | 47.47311 | 47.60146 | 47.53728 | 0.0187927 | 48.52982 |
0.1 | 46 | 2.039733 | 2.070647 | 1 | Function criterion near zero | 0.00654 | 0.0426 | normal | 0.05 | 0.1 | 46.70045 | 46.87892 | 46.78969 | 0.0187547 | 48.22016 |
0.1 | 45 | 2.034888 | 2.076213 | 1 | Function criterion near zero | 0.00654 | 0.0426 | normal | 0.05 | 0.1 | 45.93857 | 46.16215 | 46.05036 | 0.0187151 | 47.91550 |
0.1 | 44 | 2.029850 | 2.082044 | 1 | Function criterion near zero | 0.00654 | 0.0426 | normal | 0.05 | 0.1 | 45.18813 | 45.45141 | 45.31977 | 0.0186738 | 47.61636 |
The ASNavg-optimal design can be obtained as
optimal.design<-designs %>% group_by(q,dist,p_alpha,p_beta) %>%
filter( (abs(alpha-risks[1])<1e-05) & (abs(risks[2]-beta)<1e-05) & (termcd==1)) %>%
slice(which.min(asn_avg)) %>% arrange(q,p_alpha,p_beta) %>% as.data.frame()
q | n | kr | ka | termcd | message | p_alpha | p_beta | dist | alpha | beta | asn_alpha | asn_beta | asn_avg | p_asn_max | asn_max |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0.1 | 21 | 1.799825 | 2.3974 | 1 | Function criterion near zero | 0.00654 | 0.0426 | normal | 0.05 | 0.1000001 | 34.71139 | 32.27409 | 33.49274 | 0.0168694 | 46.02262 |
Design of repetitive group sampling plans using a generalized beta (GB) prior model of p and expected sampling risks
In this case, the censored repetitive sampling plans can be determined when a GB prior is assumed and there is available knowledge about the mean and variance of p. For given requirements of maximum expected risks and quality levels, the sampling plans are
risks<-c(0.05,0.10) #vector of producer and consumer maximum sampling risks
p<-c(0.00654, 0.0426) #vector of acceptance and rejection quality levels
q<- 0.1 #censoring degree
asvar<-asympt.var(q,"normal") #asymptotical variance-covariance matrix of MLE estimators of location and scale paramters
l<- p[1]/5 #lower limit of p
u<- p[2]+(p[1]-l) #upper limit of p
# GB parameters for a knowledge of mean and variance of p distribution
know_p<-list(mean_p=p[1],var_p=((p[2]-p[1])/4)^2)
beta.parms<-beta.params(p,l,u, know_p)
designs<-repGBprior.plan(risks,p,asvar, beta.parms)
Then, the function repGBprior.plan() returns these designs. The first plans are
q | n | n_low | n_up | kr | ka | termcd | message | p_alpha | p_beta | a | b | l | u | mean_p | var_p | dist | alpha | beta | asn_alpha | asn_beta | asn_avg | easn | p_asn_max | asn_max |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0.1 | 24 | 3 | 49 | 2.200833 | 2.200877 | 1 | Function criterion near zero | 0.00654 | 0.0426 | 0.1862234 | 1.469713 | 0.001308 | 0.047832 | 0.00654 | 8.13e-05 | normal | 0.0500619 | 0.1000161 | 24.00090 | 24.00042 | 24.00066 | 24.00039 | 0.0121556 | 24.00107 |
0.1 | 23 | 3 | 49 | 2.187946 | 2.216942 | 1 | Function criterion near zero | 0.00654 | 0.0426 | 0.1862234 | 1.469713 | 0.001308 | 0.047832 | 0.00654 | 8.13e-05 | normal | 0.0500908 | 0.1000238 | 23.58511 | 23.27324 | 23.42917 | 23.30382 | 0.0120410 | 23.69109 |
0.1 | 22 | 3 | 49 | 2.173528 | 2.234751 | 1 | Function criterion near zero | 0.00654 | 0.0426 | 0.1862234 | 1.469713 | 0.001308 | 0.047832 | 0.00654 | 8.13e-05 | normal | 0.0500003 | 0.1000001 | 23.20269 | 22.56201 | 22.88235 | 22.63308 | 0.0119251 | 23.40886 |
0.1 | 21 | 3 | 49 | 2.158403 | 2.254219 | 1 | Function criterion near zero | 0.00654 | 0.0426 | 0.1862234 | 1.469713 | 0.001308 | 0.047832 | 0.00654 | 8.13e-05 | normal | 0.0500319 | 0.1000146 | 22.82986 | 21.85480 | 22.34233 | 21.97611 | 0.0118011 | 23.12469 |
0.1 | 20 | 3 | 49 | 2.142068 | 2.275593 | 1 | Function criterion near zero | 0.00654 | 0.0426 | 0.1862234 | 1.469713 | 0.001308 | 0.047832 | 0.00654 | 8.13e-05 | normal | 0.0500924 | 0.1000943 | 22.47555 | 21.15569 | 21.81562 | 21.34039 | 0.0116246 | 22.84847 |
0.1 | 19 | 3 | 49 | 2.123503 | 2.300221 | 1 | Function criterion near zero | 0.00654 | 0.0426 | 0.1862234 | 1.469713 | 0.001308 | 0.047832 | 0.00654 | 8.13e-05 | normal | 0.0500073 | 0.1000022 | 22.18107 | 20.48217 | 21.33162 | 20.74946 | 0.0114847 | 22.62697 |
and the EASN-optimal design is obtained as
optimal.design<-designs %>% group_by(q,dist,p_alpha,p_beta) %>%
filter( (abs(alpha-risks[1])<1e-05) &
(abs(risks[2]-beta)<1e-05) & (termcd==1)) %>%
group_by(q,p_alpha,p_beta,a,b,l,u,dist) %>%
mutate(easn_min=min(easn)) %>%
slice(which.min(easn)) %>% as.data.frame()
q | n | n_low | n_up | kr | ka | termcd | message | p_alpha | p_beta | a | b | l | u | mean_p | var_p | dist | alpha | beta | asn_alpha | asn_beta | asn_avg | easn | p_asn_max | asn_max | easn_min |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0.1 | 12 | 3 | 49 | 1.921685 | 2.611877 | 1 | Function criterion near zero | 0.00654 | 0.0426 | 0.1862234 | 1.469713 | 0.001308 | 0.047832 | 0.00654 | 8.13e-05 | normal | 0.05 | 0.1000001 | 21.7853 | 16.33357 | 19.05943 | 18.15345 | 0.0099061 | 22.38735 | 18.15345 |