Package 'bayespm'

Title: Bayesian Statistical Process Monitoring
Description: The R-package bayespm implements Bayesian Statistical Process Control and Monitoring (SPC/M) methodology. These methods utilize available prior information and/or historical data, providing efficient online quality monitoring of a process, in terms of identifying moderate/large transient shifts (i.e., outliers) or persistent shifts of medium/small size in the process. These self-starting, sequentially updated tools can also run under complete absence of any prior information. The Predictive Control Charts (PCC) are introduced for the quality monitoring of data from any discrete or continuous distribution that is a member of the regular exponential family. The Predictive Ratio CUSUMs (PRC) are introduced for the Binomial, Poisson and Normal data (a later version of the library will cover all the remaining distributions from the regular exponential family). The PCC targets transient process shifts of typically large size (a.k.a. outliers), while PRC is focused in detecting persistent (structural) shifts that might be of medium or even small size. Apart from monitoring, both PCC and PRC provide the sequentially updated posterior inference for the monitored parameter. Bourazas K., Kiagias D. and Tsiamyrtzis P. (2022) "Predictive Control Charts (PCC): A Bayesian approach in online monitoring of short runs" <doi:10.1080/00224065.2021.1916413>, Bourazas K., Sobas F. and Tsiamyrtzis, P. 2023. "Predictive ratio CUSUM (PRC): A Bayesian approach in online change point detection of short runs" <doi:10.1080/00224065.2022.2161434>, Bourazas K., Sobas F. and Tsiamyrtzis, P. 2023. "Design and properties of the predictive ratio cusum (PRC) control charts" <doi:10.1080/00224065.2022.2161435>.
Authors: Dimitrios Kiagias [aut, cre, cph], Konstantinos Bourazas [aut, cph], Panagiotis Tsiamyrtzis [aut, cph]
Maintainer: Dimitrios Kiagias <[email protected]>
License: GPL (>= 2)
Version: 0.2.0
Built: 2024-11-04 04:03:34 UTC
Source: https://github.com/cran/bayespm

Help Index


Dataset for PCC process for Normal with both parameters unknown

Description

The activated Partial Thromboplastin Time (aPTT) dataset is a data frame that contains two columns. The first column (aPTT_current) repsesents 30 sequentially gathered current observations from the daily routine of a medical laboratory. The values refer to the activated Partial Thromboplastin Time (aPTT), measured in seconds. The second column (aPTT_historical) refers to 30 historical In Control measurements of the same variable. APTT is a blood test that characterizes coagulation of the blood. More specifically, it is the time that until the coagulation when reagents are added to plasma.

Usage

data("aPTT")

Examples

# Loading data
attach(aPTT)

# Plotting data
plot( 1:length(aPTT_current), aPTT_current, type = "b", lty = 1, xlab = "", ylab = "",
      ylim = c(27.3, 33.4), xlim = c(-30, 30), lwd = 1, pch = 16, axes = FALSE, yaxs = "i",
      main = "aPTT dataset" )

# x - axis for historical and current data
pastx <- c( -30, -20, -10, 0 ) ; currentx <- c( 0, 10, 20, 30 )
# Adding points
points( -length(aPTT_historical):(-1), aPTT_historical,
        type = "b", lty = 2, xlab = "", ylab = "", lwd = 1, pch = 21, col = "gray55" )
# Adding axis with names
axis(2)
mtext( "Current Data", side = 1, at = 15, line = 2.2, cex = 1.1 )
mtext( "Historical Data", side = 1, at = -15, line = 2.2, cex = 1.1, col = "gray55" )
mtext( "aPTT [sec]", side = 2, line = 2.2, cex = 1.1 )
axis( 1, at = currentx, labels = currentx )
axis( 1, at = pastx, labels = pastx, col.axis = "gray55", col = "gray55", lty = 2 )
segments( 0, 27.5, 0, 33.5, lwd = 1 )

The Highest Mass (HM) interval of Beta-Binomial distribution.

Description

betabinom_HM is used to derive the narrowest interval of a predetermined coverage from a Beta-Binomial distribution, containing the Highest Mass (HM) values.

Usage

betabinom_HM( cover = NULL, n = NULL, a = NULL, b = NULL, plot = FALSE,
              xlab = "x", ylab = "Probability" )

Arguments

cover

scalar (between 0 and 1); The coverage (probability) of the Highest Mass (HM).

n

scalar (integer); It is the number of trials of the Binomial distribution and needs to be a number.

a

scalar (positive); It is the shape1 parameter of the Beta distribution and needs to be a number.

b

scalar (positive); It is the shape2 parameter of the Beta distribution and needs to be a number.

plot

logical; if TRUE, the plot of the HM region is displayed. It is FALSE by default.

xlab, ylab

The titles of the x-axis and y-axis for the HM plot. The default values are "x" and "Probability".

Details

betabinom_HM provides the Highest Mass (HM) of a Beta-Binomial distribution. HM is the narrowest region, with the minimum absolute difference from a pretermined coverage. The values included in HM have probability larger than every point outside the region.

Value

Returns a data frame with the upper and the lower limits of the Highest Predictive Denisty or Mass (HPrD/M) region, the lower and the achieved coverage. If plot=T, then the HPrD/M is visualized.

Examples

betabinom_HM(0.95, 10, 20, 180, plot = TRUE)

The Highest Mass (HM) interval of Beta-Negative Binomial distribution.

Description

betanbinom_HM is used to derive the narrowest interval of a predetermined coverage from a Beta-Negative Binomial distribution, containing the Highest Mass (HM) values.

Usage

betanbinom_HM( cover = NULL, r = NULL, a = NULL, b = NULL, plot = FALSE,
               xlab = "x", ylab = "Probability" )

Arguments

cover

scalar (between 0 and 1); The coverage (probability) of the Highest Mass (HM).

r

scalar (integer); It is the number of failures of the Negative Binomial distribution and needs to be a number.

a

scalar (positive); It is the shape1 parameter of the Beta distribution and needs to be a number.

b

scalar (positive); It is the shape2 parameter of the Beta distribution and needs to be a number.

plot

logical; if TRUE, the plot of the HM region is displayed. It is FALSE by default.

xlab, ylab

The titles of the x-axis and y-axis for the HM plot. The default values are "x" and "Probability".

Details

betanbinom_HM provides the Highest Mass (HM) of a Beta-Negative Binomial distribution. HM is the narrowest region, with the minimum absolute difference from a pretermined coverage. The values included in HM have probability larger than every point outside the region.

Value

Returns a data frame with the upper and the lower limits of the Highest Predictive Denisty or Mass (HPrD/M) region, the lower and the achieved coverage. If plot=T, then the HPrD/M is visualized.

Examples

betanbinom_HM(0.95, 5, 20, 80, plot = TRUE)

PCC for Binomial data with probability parameter unknown

Description

binom_PCC is used to derive the Predictive Control Chart (PCC) for Binomial data, when the probability parameter is unknown and the trials are known.

Usage

binom_PCC( data = NULL, n = NULL, historical_data = NULL,
           historical_n = NULL, a0 = 1/2, b0 = 1/2, alpha_0 = NULL,
           ARL_0 = 370.4, FAP = NULL, FIR = FALSE, fFIR = .99, aFIR = 1/8,
           summary_list = TRUE, PCC_PLOT = TRUE, PriorPosterior_PLOT = FALSE,
           historical_data_PLOT = FALSE, pdf_report = FALSE, path_pdf_report = tempdir(),
           xlab = "Observations", ylab = "Quality characteristic Values",
           main = "PCC Binomial with unknown probability" )

Arguments

data

vector; a univariate dataset for PCC implementation. Data needs to be in a vector form.

n

vector; number of trials for given dataset. It needs to be in a vector form.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

historical_n

vector; number of trials for given historical dataset. It needs to be in a vector form.

a0

scalar (positive); shape hyperparameter of the prior Beta(a, b). It needs to be a number. The default is 1/2 and it refers to the initial reference prior Beta(1/2, 1/2).

b0

scalar (positive); shape hyperparameter of the prior Beta(a, b). It needs to be a number. The default is 1/2 and it refers to the initial reference prior Beta(1/2, 1/2).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

ARL_0

scalar (positive); In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4

FAP

scalar (between 0 and 1); False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0. It is based on the Sidak's correction.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PCC is applied, which is an adjustment (narrows the PCC limits) for the initial fisrt tests.

fFIR

a number between 0 and 1; It is used if FIR=TRUE. The default value is 0.99 and represents the proportion of the adjusted PCC region over the initial one for the first test.

aFIR

non-negative number; It is used if FIR=TRUE. The default value is 0.125 and it is a smoothing parameter for the FIR adjustment.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PCC_PLOT

logical; if TRUE, the PCC plot is displayed. It is TRUE by default.

PriorPosterior_PLOT

logical; if TRUE, the Prior and Posterior distribution(s) of the parameter(s) are displayed. It is TRUE by default.

historical_data_PLOT

logical; if TRUE, the historical data are plotted precending the PCC plot. It is FALSE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "Quality characteristic Values" and "PCC Binomial with unknown probability" respectively

Details

binom_PCC provides the Predictive Control Chart (PCC) process for Binomial data, when the probability parameter is unknown and the trials are known. The PCC process is based on the sequential testing of the future observable against the Highest Predictive Density (HPrD), which is obtained by the posterior predictive distribution. The PCC testing starts as early as the second observation.

The initial prior for the unknown probability is a Beta: Beta(a0, b0). Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior Beta(1/2, 1/2), without the use of historical data.

A FIR option is available by narrowing the first few control limits. The metrics that can be used to control the false alarms tolerance are either ARL_0 or FAP.

Value

Runs the PCC process, while if FIR=T, then the FIR-PCC is implemented. If plot=T, then a data frame is provided with the data, the upper and the lower limits of the Highest Predictive Density or Mass (HPrD/M) region, and an indication in case of alarms. If PCC_PLOT=T, then the PCC process is visualized, while if historical_data_PLOT=T, the historical data are added to the plot. If PriorPosterior_PLOT = T, a plot with the prior and the posterior is provided. Finally, if pdf_report=T, all the output is reported and saved into a pdf file.

Examples

# 30 Binomial observations introducing an outlier at the 15th observation
set.seed(10)
SimData <- rbinom( n = 30, size = 20, prob = 0.6 )
SimData[15] <- round( SimData[15] + 3*sqrt(20*0.6*0.4) )
binom_PCC( SimData, n = rep(20, 30) )

PRC for Binomial data with probability parameter unknown

Description

binom_PRC is used to derive the Predictive Ratio CUSUM (PRC) for Binomial data, when the probability parameter is unknown.

Usage

binom_PRC( data = NULL, n = NULL, historical_data = NULL, historical_n = NULL,
           a0 = 1/2, b0 = 1/2, alpha_0 = NULL, k=2, two.sided=FALSE,
           h = log(100), FIR = FALSE, fFIR = 1/2, dFIR = 3/4,
           summary_list = TRUE, PRC_PLOT = TRUE, pdf_report = FALSE,
           path_pdf_report = tempdir(),
           xlab = "Observation Order", ylab = "PRC cumulative statistics",
           main = "PRC Binomial with unknown probability" )

Arguments

data

vector; a univariate dataset for PCC implementation. Data needs to be in a vector form.

n

vector; number of trials for given dataset. It needs to be in a vector form.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

historical_n

vector; number of trials for given historical dataset. It needs to be in a vector form.

a0

scalar (positive); shape hyperparameter of the prior Beta(a, b). It needs to be a number. The default is 1/2 and it refers to the initial reference prior Beta(1/2, 1/2).

b0

scalar (positive); shape hyperparameter of the prior Beta(a, b). It needs to be a number. The default is 1/2 and it refers to the initial reference prior Beta(1/2, 1/2).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

k

scalar (positive); tuning parameter, which represents deviation between IC and OOC state. Precisely, if k>1 then the OOC state corresponds to a (k-1)100% increase in the expected odds of the success probability p and if k<1 corresponds (1-k)100% decrease. The dafault value is 2.

two.sided

logical; If TRUE, then a two sided PRC is employed with tuning parameters k and 1/k respectively. It is FALSE by default.

h

scalar (positive); Decision limit and we raise an alarm if the cumulative statistic exceeds it (or ?h for two sided shifts). The default value is log(100)=4.605, fow which we have a decisive cumulative evidence in favor of the OOC state.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PRC is applied, which is an exponentially decreasing adjustment for the initial fisrt tests, inflating the PRC statistics.

fFIR

non-negative number; It is used if FIR=TRUE. It represents the proportion of the inflation for the PRC statistic in the for the fisrt test. The default value is 1/2.

dFIR

a number between 0 and 1; It is used if FIR=TRUE. It is a smoothing parameter, specifying the exponential decay of the adjustment (the smaller the d the fastest the decay). The default value is 3/4.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PRC_PLOT

logical; if TRUE, the PRC plot is displayed. It is TRUE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "PRC cumulative statistics" and "PRC Binomial with unknown probability" respectively

Details

binom_PRC provides the Predictive Ratio CUSUM (PRC) process for Binomial data, when the probability parameter is unknown. The PRC process is based on sequential comparison between the IC and OOC state, via their predictive distributions. The parameter k represents the deviance between these two states. The default value is k=2, which corresponds to a doubling of the expected odds ratio of the probability of success. The testing starts as early as the second observation.

The initial prior for the unknown probability is a Beta: Beta(a, b). Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior Beta(1/2, 1/2), without the use of historical data.

A FIR option is available by inlfating the first few PRC statistics. The choice of the decision limit h reflects the false alarm tolerance.

Examples

# the PRC process for the first 30 data points in the third application in
# "Design and properties of the Predictive Ratio Cusum (PRC) control charts"


### HISTORICAL DATA (FIRST BATCH)
HD <- c( 3, 3, 1, 5, 2, 1, 3, 3, 3, 0, 2, 1, 2, 1, 4, 1, 1, 0, 3, 2, 4, 6, 0, 1, 3, 2, 2, 4, 2, 1 )

### Bernoulli trials
nn <- 50

N0 <- length(HD)
NN0 <- rep(50, N0)

binom_PRC(data = HD, n = NN0)


# the PRC process for the last 10 data points in the third application in
# "Design and properties of the Predictive Ratio Cusum (PRC) control charts"

### prior parameters before the first batch

a0 <- 1/2
b0 <- 1/2

### posterior parameters after the first batch

ap <- sum(HD) + a0
bp <- sum(NN0) - sum(HD) + b0

hl = 4.332 # the decision limit is derived by the function binom_PRC_h

### CURRENT DATA (SECOND BATCH)
CD <- c(2, 4, 5, 2, 4, 8, 4, 4, 8, 5)

N <- length(CD)
NN <- rep(50, N)

binom_PRC(data = CD, n = NN, a0 = ap, b0 = bp, h = hl)

Derivation of the decision limit for the PRC for Binomial data with probability parameter unknown

Description

binom_PRC_h is used to estimate the decision limit h for the Predictive Ratio CUSUM (PRC) for Binomial data. The process controls the false alarms tolerance, providing a lower bound of ARL_0 or FAP, based on the marginal distribution.

Usage

binom_PRC_h( ARL_0 = 370.4, FAP = NULL, N = NULL, n = NULL,
             historical_data = NULL, historical_n = NULL,
             a0 = NULL, b0 = NULL, alpha_0 = NULL, k = 2,
             it = 1e4, ARL0tol = 10/it )

Arguments

ARL_0

scalar (positive); lower bound of the In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4.

FAP

scalar (between 0 and 1); lower bound of the False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0.

N

scalar (natural); number of N hypothesis tests. It is used for the FAP determination.

n

vector; number of trials for given dataset. It needs to be in a vector form.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

historical_n

vector; number of trials for given historical dataset. It needs to be in a vector form.

a0

scalar (positive); shape hyperparameter of the prior Beta(a, b). It needs to be a number.

b0

scalar (positive); shape hyperparameter of the prior Beta(a, b). It needs to be a number.

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

k

scalar (positive); tuning parameter, which represents deviation between IC and OOC state. Precisely, if k>1 then the OOC state corresponds to a (k-1)100% increase in the expected odds of the success probability p and if k<1 corresponds (1-k)100% decrease. The dafault value is 2.

it

scalar (natural); iterations of the simulation. The default value is 10000.

ARL0tol

scalar (positive); relative tolerance of ARL_0 estimate. It represents the maximum amount of error which is allowed. The default value is 10/it.

Details

binom_PRC_h estimates the desicion limit h regarding the desired upper bound of false alarms tolerance for the Predictive Ratio CUSUM (PRC) process for Binomial data, when the probability parameter is unknown. The estimate concerns an one-sided PRC process and the default setup corresponds to a doubling of the expected odds ratio of the probability of success (k=2). The estimate is based on the use of the marginal distribution (prior predictive) and the incorporation of historical data is possible via the power prior.

The default metric of the false alarms tolerance is ARL_0=370.4, while a FAP option is available. The desicion limit is obtained via the numerical method regula falsi when ARL_0 is selected, while simulated samples of fixed size are used when FAP is of interest.

Examples

binom_PRC_h(ARL_0 = NULL, FAP = 0.05, N = 20, n = 10, a0 = 20, b0 = 180)

# derivation of the decision limit of the third application in
# "Design and properties of the Predictive Ratio Cusum (PRC) control charts"

arl0 <- 400
ap <- 66.5
bp <- 1434.5
kl <- 2


# To replicate results from application set 'ARL0tol = .001' and 'it = 1e4'
binom_PRC_h(ARL_0 = arl0, ARL0tol = .01, k = kl, n = 50, a0 = ap, b0 = bp, it = 1e3)

The Highest Density (HD) interval of Compound Gamma distribution.

Description

compgamma_HD is used to derive the narrowest interval of a predetermined coverage from a Compound Gamma distribution, containing the Highest Density (HD) values.

Usage

compgamma_HD( cover = NULL, a = NULL, c = NULL, d = NULL, plot = FALSE,
              xlab = "x", ylab = "Density" )

Arguments

cover

scalar (between 0 and 1); The coverage (probability) of the Highest Density (HD).

a

scalar (positive); It is the shape1 parameter of the Compound Gamma distribution and needs to be a number.

c

scalar (positive); It is the shape2 parameter of the Compound Gamma distribution and needs to be a number.

d

scalar (positive); It is the scale parameter of the Compound Gamma distribution and needs to be a number.

plot

logical; if TRUE, the plot of the HD region is displayed. It is FALSE by default.

xlab, ylab

The titles of the x-axis and y-axis for the HD plot. The default values are "x" and "Density".

Details

compgamma_HD provides the Highest Density (HD) of a Compound Gamma distribution. HD is the narrowest interval with a pretermined coverage. The values included in HD have density larger than every point outside the region.

Value

Returns a data frame with the upper and the lower limits of the Highest Predictive Denisty or Mass (HPrD/M) region, the lower and the achieved coverage. If plot=T, then the HPrD/M is visualized.

Examples

compgamma_HD(0.95, 2, 10, 10, plot = TRUE)

ECE dataset for the PCC process for Poisson with rate parameter unknown

Description

The Electrical Complex Equipment (ECE) dataset repsesents 25 paired observations in a data frame. The first column (defect_counts) refers the number of defects per inspected number of units, encountered in a complex electrical equipment of an assembly line. The second column (inspected_units) contains the corresponding inspected number of units for the counting of defects. The data were also analyzed by Hansen and Ghare (1987) and Bayarri and Garcia-Donato (2005).

Usage

data("ECE")

References

[1] Bayarri, M. J., and Garcia-Donato, G. (2005), "A Bayesian Sequential Look at u-Control Charts", Technometrics, 47, 2, pp. 142-151

[2] Hansen, B., and Ghare, P. (1987), "Quality Control and Application, Prentice-Hall", Englewood Cliffs, NJ

Examples

# Loading data
attach(ECE)

# Plotting data
graphpar <- par( oma = c(1,3,2,3) )
plot( 1:length(defect_counts), defect_counts/inspected_units, type = "b", lty = 1,
      xlab = "Observations", ylab = "", xlim = c(0, 25), ylim = c(1.5, 10.5),
      lwd = 1, pch = 16, axes = FALSE, yaxs = "i", main = "ECE dataset" )

# Adding points
points( 1:length(defect_counts), inspected_units, type = "b",
        lty = 2, lwd = 1, pch = 21, col = "gray55" )
# Adding legend
legend( "topleft", legend=c(expression(paste(s[i])), expression(paste(x[i]/s[i])) ), bty = "n",
        cex = 0.8, lty = c(2, 1), lwd = 1, col = c ("gray55", "black") , pch = c(21, 16) )
# Adding axis with names
axis(1) ; axis(2) ; axis(4, col.axis = "gray55", col = "gray55")
mtext( "Number of Defects \n per unit", side = 2,  line = 2.2, cex = 0.9 )
mtext( "Inspected units", side = 4,  line = 2, cex = 0.9, col = "gray55" )
# Resetting graphical paramaters
par(graphpar)

PCC for Gamma data with rate parameter unknown

Description

gamma_PCC is used to derive the Predictive Control Chart (PCC) for Gamma data, when the rate parameter is unknown and the shape parameter is known.

Usage

gamma_PCC( data = NULL, historical_data = NULL, al = NULL,
           c0 = 0, d0 = 0, alpha_0 = NULL,
           ARL_0 = 370.4, FAP = NULL, FIR = FALSE, fFIR = .99, aFIR = 1/8,
           summary_list = TRUE, PCC_PLOT = TRUE, PriorPosterior_PLOT = FALSE,
           historical_data_PLOT = FALSE, pdf_report = FALSE, path_pdf_report = tempdir(),
           xlab = "Observation Order", ylab = "Quality characteristic Values",
           main = "PCC Gamma with rate parameter unknown" )

Arguments

data

vector; a univariate dataset for PCC implementation. Data needs to be in a vector form.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

al

scalar (positive); parameter of the likelihood. It is the known shape parameter of the data and needs to be a number.

c0

scalar (positive); scalar (positive); hyperparameter of the prior G(c0,d0). It needs to be a number. The default is 0 and it refers to the initial reference prior G(0,0).

d0

scalar (positive); scalar (positive); hyperparameter of the prior G(c0,d0). It needs to be a number. The default is 0 and it refers to the initial reference prior G(0,0).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

ARL_0

scalar (positive); In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4

FAP

scalar (between 0 and 1); False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0. It is based on the Sidak's correction.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PCC is applied, which is an adjustment (narrows the PCC limits) for the initial fisrt tests.

fFIR

a number between 0 and 1; It is used if FIR=TRUE. The default value is 0.99 and represents the proportion of the adjusted PCC region over the initial one for the first test.

aFIR

non-negative number; It is used if FIR=TRUE. The default value is 0.125 and it is a smoothing parameter for the FIR adjustment.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PCC_PLOT

logical; if TRUE, the PCC plot is displayed. It is TRUE by default.

PriorPosterior_PLOT

logical; if TRUE, the Prior and Posterior distribution(s) of the parameter(s) are displayed. It is TRUE by default.

historical_data_PLOT

logical; if TRUE, the historical data are plotted precending the PCC plot. It is FALSE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "Quality characteristic Values" and "PCC Gamma with rate parameter unknown" respectively.

Details

gamma_PCC provides the Predictive Control Chart (PCC) process for Poisson data, when the rate parameter is unknown and the shape parameter is known. The PCC process is based on the sequential testing of the future observable against the Highest Predictive Density (HPrD), which is obtained by the posterior predictive distribution. The PCC testing starts as early as the second observation.

The initial prior for the unknown parameters is a Gamma: G(c0, d0), where d0 is the rate parameter. Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior G(0,0), without the use of historical data.

A FIR option is available by narrowing the first few control limits. The metrics that can be used to control the false alarms tolerance are either ARL_0 or FAP.

Value

Runs the PCC process, while if FIR=T, then the FIR-PCC is implemented. If plot=T, then a data frame is provided with the data, the upper and the lower limits of the Highest Predictive Density or Mass (HPrD/M) region, and an indication in case of alarms. If PCC_PLOT=T, then the PCC process is visualized, while if historical_data_PLOT=T, the historical data are added to the plot. If PriorPosterior_PLOT = T, a plot with the prior and the posterior is provided. Finally, if pdf_report=T, all the output is reported and saved into a pdf file.

Examples

# 30 Gamma observations introducing an outlier of 3*sd at the 15th observation
set.seed(100)
out <- rgamma( n = 30, shape = 4, rate = 4 )
out[15] <- out[15] + 1.5
gamma_PCC( out, al = 4 )

The Highest Density (HD) interval of Generalized Beta of the second kind distribution.

Description

gb2_HD is used to derive the narrowest interval of a predetermined coverage from a Generalized Beta of the second kind distribution, containing the Highest Density (HD) values.

Usage

gb2_HD( cover = NULL, a = NULL, c = NULL, d = NULL, plot = FALSE,
        xlab = "x", ylab = "Density" )

Arguments

cover

scalar (between 0 and 1); The coverage (probability) of the Highest Density (HD).

a

scalar (positive); It is the shape1 parameter of the Generalized Beta of the second kind distribution and needs to be a number.

c

scalar (positive); It is the shape2 parameter of the Generalized Beta of the second kind distribution and needs to be a number.

d

scalar (positive); It is the scale parameter of the Generalized Beta of the second kind distribution and needs to be a number.

plot

logical; if TRUE, the plot of the HD region is displayed. It is FALSE by default.

xlab, ylab

The titles of the x-axis and y-axis for the HD plot. The default values are "x" and "Density".

Details

gb2_HD provides the Highest Density (HD) of a Generalized Beta of the second kind distribution. HD is the narrowest interval with a pretermined coverage. The values included in HD have density larger than every point outside the region.

Value

Returns a data frame with the upper and the lower limits of the Highest Predictive Denisty or Mass (HPrD/M) region, the lower and the achieved coverage. If plot=T, then the HPrD/M is visualized.

Examples

gb2_HD(0.95, 4, 6, 6, plot = TRUE)

PCC for Inverse-Gamma data with scale parameter unknown

Description

invgamma_PCC is used to derive the Predictive Control Chart (PCC) for Inverse-Gamma data, when the scale parameter is unknown and the shape parameter is known.

Usage

invgamma_PCC( data = NULL, historical_data = NULL,
              al = NULL, c0 = 0, d0 = 0, alpha_0 = NULL,
              ARL_0 = 370.4, FAP = NULL, FIR = FALSE, fFIR = .99, aFIR = 1/8,
              summary_list = TRUE, PCC_PLOT = TRUE, PriorPosterior_PLOT = FALSE,
              historical_data_PLOT = FALSE, pdf_report = FALSE,
              path_pdf_report = tempdir(),
              xlab = "Observation Order", ylab = "Quality characteristic Values",
              main = "PCC Inverse-Gamma with unknown scale parameter" )

Arguments

data

vector; a univariate dataset for PCC implementation. Data needs to be in a vector form.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

al

scalar (positive); parameter of the likelihood. It is the known shape parameter of the data and needs to be a number.

c0

scalar (positive); scalar (positive); hyperparameter of the prior G(c0, d0). It needs to be a number. The default is 0 and it refers to the initial reference prior G(0, 0).

d0

scalar (positive); scalar (positive); hyperparameter of the prior G(c0, d0). It needs to be a number. The default is 0 and it refers to the initial reference prior G(0, 0).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

ARL_0

scalar (positive); In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4

FAP

scalar (between 0 and 1); False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0. It is based on the Sidak's correction.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PCC is applied, which is an adjustment (narrows the PCC limits) for the initial fisrt tests.

fFIR

a number between 0 and 1; It is used if FIR=TRUE. The default value is 0.99 and represents the proportion of the adjusted PCC region over the initial one for the first test.

aFIR

non-negative number; It is used if FIR=TRUE. The default value is 0.125 and it is a smoothing parameter for the FIR adjustment.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PCC_PLOT

logical; if TRUE, the PCC plot is displayed. It is TRUE by default.

PriorPosterior_PLOT

logical; if TRUE, the Prior and Posterior distribution(s) of the parameter(s) are displayed. It is TRUE by default.

historical_data_PLOT

logical; if TRUE, the historical data are plotted precending the PCC plot. It is FALSE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "Quality characteristic Values" and "PCC Inverse-Gamma with unknown scale parameter" respectively

Details

invgamma_PCC is used to derive the Predictive Control Chart (PCC) for Inverse-Gamma data, when the scale parameter is unknown and the shape parameter is known. The PCC process is based on the sequential testing of the future observable against the Highest Predictive Density (HPrD), which is obtained by the posterior predictive distribution. The PCC testing starts as early as the second observation.

The initial prior for the unknown scale is a Gamma: Gamma(c0, d0). Furthermore, the direct use of historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior Gamma(0, 0), without the use of historical data.

A FIR option is available by narrowing the first few control limits. The metrics that can be used to control the false alarms tolerance are either ARL_0 or FAP.

Value

Runs the PCC process, while if FIR=T, then the FIR-PCC is implemented. If plot=T, then a data frame is provided with the data, the upper and the lower limits of the Highest Predictive Density or Mass (HPrD/M) region, and an indication in case of alarms. If PCC_PLOT=T, then the PCC process is visualized, while if historical_data_PLOT=T, the historical data are added to the plot. If PriorPosterior_PLOT = T, a plot with the prior and the posterior is provided. Finally, if pdf_report=T, all the output is reported and saved into a pdf file.

Examples

# 30 Inverse-Gamma observations introducing an outlier at the 15th observation
set.seed(100)
SimData <- 1/rgamma(n = 30, shape = 3, rate = 2)
SimData[15] <- SimData[15] + 3
invgamma_PCC(SimData, al = 3)

The Highest Density (HD) interval of Lognormal distribution.

Description

lnorm_HD is used to derive the narrowest interval of a predetermined coverage from a Lognormal distribution, containing the Highest Density (HD) values.

Usage

lnorm_HD( cover = NULL, mulog = NULL, sdlog = NULL, plot = FALSE,
          xlab = "x", ylab = "Density" )

Arguments

cover

scalar (between 0 and 1); The coverage (probability) of the Highest Density (HD).

mulog

scalar (real); It is the scale parameter of the Lognormal distribution and needs to be a number.

sdlog

scalar (positive); It is the shape parameter of the Lognormal distribution and needs to be a number.

plot

logical; if TRUE, the plot of the HD region is displayed. It is FALSE by default.

xlab, ylab

The titles of the x-axis and y-axis for the HD plot. The default values are "x" and "Density".

Details

lnorm_HD provides the Highest Density (HD) of a Lognormal distribution. HD is the narrowest interval with a pretermined coverage. The values included in HD have density larger than every point outside the region.

Value

Returns a data frame with the upper and the lower limits of the Highest Predictive Denisty or Mass (HPrD/M) region, the lower and the achieved coverage. If plot=T, then the HPrD/M is visualized.

Examples

lnorm_HD(0.95, 0, 1/2, plot = TRUE)

PCC for LogNormal data with scale parameter unknown

Description

lnorm1_PCC is used to derive the Predictive Control Chart (PCC) for Normal data, when the scale parameter is unknown and the shape parameter is known.

Usage

lnorm1_PCC(data = NULL, historical_data = NULL,
           sdl = NULL, mu0 = 0, sd0 = 10^6, alpha_0 = NULL,
           ARL_0 = 370.4, FAP = NULL, FIR = FALSE, fFIR = .99, aFIR = 1/8,
           summary_list = TRUE, PCC_PLOT = TRUE, PriorPosterior_PLOT = FALSE,
           historical_data_PLOT = FALSE, pdf_report = FALSE, path_pdf_report = tempdir(),
           xlab = "Observations", ylab = "Quality characteristic Values",
           main = "PCC LogNormal with unknown mean")

Arguments

data

vector; a dataset for PCC implementation. Data needs to be in a vector form.

historical_data

vector; an optional dataset of historical data. Historical data needs to be in a vector form.

sdl

scalar (positive); parameter of the likelihood. It is the known standand deviation of the data and needs to be a number.

mu0

scalar; hyperparameter of the prior N(mu0, sd0^2). It needs to be a number. The default is 0 and it refers to the initial reference prior N(0, \infty).

sd0

scalar (positive); hyperparameter of the prior N(mu0, sd0^2). It needs to be a number. The default is 10^6 and it refers to the initial reference prior N(0, \infty).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

ARL_0

scalar (positive); In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4

FAP

scalar (between 0 and 1); False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0. It is based on the Sidak's correction.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PCC is applied, which is an adjustment (narrows the PCC limits) for the initial fisrt tests.

fFIR

a number between 0 and 1; It is used if FIR=TRUE. The default value is 0.99 and represents the proportion of the adjusted PCC region over the initial one for the first test.

aFIR

non-negative number; It is used if FIR=TRUE. The default value is 0.125 and it is a smoothing parameter for the FIR adjustment.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PCC_PLOT

logical; if TRUE, the PCC plot is displayed. It is TRUE by default.

PriorPosterior_PLOT

logical; if TRUE, the Prior and Posterior distribution(s) of the parameter(s) are displayed. It is TRUE by default.

historical_data_PLOT

logical; if TRUE, the historical data are plotted precending the PCC plot. It is FALSE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "Quality characteristic Values" and "PCC LogNormal with unknown mean" respectively.

Details

lnorm1_PCC provides the Predictive Control Chart (PCC) process for LogNormal data, when the scale parameter is unknown and the shape parameter is known. The PCC process is based on the sequential testing of the future observable against the Highest Predictive Density (HPrD), which is obtained by the posterior predictive distribution. The PCC testing starts as early as the second observation.

The initial prior for the unknown scale parameter is a Normal: N(mu0, sd0^2). Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior NIG(0, \infty), without the use of historical data.

A FIR option is available by narrowing the first few control limits. The metrics that can be used to control the false alarms tolerance are either ARL_0 or FAP.

Value

Runs the PCC process, while if FIR=T, then the FIR-PCC is implemented. If plot=T, then a data frame is provided with the data, the upper and the lower limits of the Highest Predictive Density or Mass (HPrD/M) region, and an indication in case of alarms. If PCC_PLOT=T, then the PCC process is visualized, while if historical_data_PLOT=T, the historical data are added to the plot. If PriorPosterior_PLOT = T, a plot with the prior and the posterior is provided. Finally, if pdf_report=T, all the output is reported and saved into a pdf file.

Examples

set.seed(9)
SimData <- rlnorm(n = 30, meanlog = 0, sdlog = 1/2)
SimData[15] <- SimData[15] + 3*sqrt( exp(1/4)*( exp(1/4)-1 ) )
plot(SimData)
lnorm1_PCC(SimData, sdl = 1/2)

PCC for LogNormal data with shape parameter unknown

Description

lnorm2_PCC is used to derive the Predictive Control Chart (PCC) for LogNormal data, when the shape parameter is unknown and the scale parameter is known.

Usage

lnorm2_PCC(data = NULL, historical_data = NULL,
           ml = NULL, a0 = 0, b0 =0, alpha_0 = NULL,
           ARL_0 = 370.4, FAP = NULL, FIR = FALSE, fFIR = .99, aFIR = 1/8,
           summary_list = TRUE, PCC_PLOT = TRUE, PriorPosterior_PLOT = FALSE,
           historical_data_PLOT = FALSE, pdf_report = FALSE, path_pdf_report = tempdir(),
           xlab = "Observation Order", ylab = "Quality characteristic Values",
           main = "PCC LogNormal with unknown variance")

Arguments

data

vector; a dataset for PCC implementation. Data needs to be in a vector form.

historical_data

vector; an optional dataset of historical data. Historical data needs to be in a vector form.

ml

scalar; parameter of the likelihood. It is the known mean of the data and needs to be a number.

a0

scalar (positive); hyperparameter of the prior IG(a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior IG(0, 0).

b0

scalar (positive); hyperparameter of the prior IG(a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior IG(0, 0).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

ARL_0

scalar (positive); In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4

FAP

scalar (between 0 and 1); False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0. It is based on the Sidak's correction.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PCC is applied, which is an adjustment (narrows the PCC limits) for the initial fisrt tests.

fFIR

a number between 0 and 1; It is used if FIR=TRUE. The default value is 0.99 and represents the proportion of the adjusted PCC region over the initial one for the first test.

aFIR

non-negative number; It is used if FIR=TRUE. The default value is 0.125 and it is a smoothing parameter for the FIR adjustment.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PCC_PLOT

logical; if TRUE, the PCC plot is displayed. It is TRUE by default.

PriorPosterior_PLOT

logical; if TRUE, the Prior and Posterior distribution(s) of the parameter(s) are displayed. It is TRUE by default.

historical_data_PLOT

logical; if TRUE, the historical data are plotted precending the PCC plot. It is FALSE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "Quality characteristic Values" and "PCC LogNormal with unknown variance" respectively

Details

lnorm2_PCC provides the Predictive Control Chart (PCC) process for LogNormal data, when the shape parameter is unknown and the scale parameter is known. The PCC process is based on the sequential testing of the future observable against the Highest Predictive Density (HPrD), which is obtained by the posterior predictive distribution. The PCC testing starts as early as the second observation.

The initial prior for the unknown shape parameter is an Inverse Gamma: IG(a0, b0). Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior IG(0, 0), without the use of historical data.

A FIR option is available by narrowing the first few control limits. The metrics that can be used to control the false alarms tolerance are either ARL_0 or FAP.

Value

Runs the PCC process, while if FIR=T, then the FIR-PCC is implemented. If plot=T, then a data frame is provided with the data, the upper and the lower limits of the Highest Predictive Density or Mass (HPrD/M) region, and an indication in case of alarms. If PCC_PLOT=T, then the PCC process is visualized, while if historical_data_PLOT=T, the historical data are added to the plot. If PriorPosterior_PLOT = T, a plot with the prior and the posterior is provided. Finally, if pdf_report=T, all the output is reported and saved into a pdf file.

Examples

# 30 LogNormal observations introducing an outlier at the 15th observation
set.seed(1)
SimData <- rlnorm(n = 30, meanlog = 0, sdlog = 1/2)
SimData[15] <- SimData[15] + 3*sqrt( exp(1/4)*( exp(1/4)-1 ) )
plot(SimData)
lnorm2_PCC(SimData, ml = 0)

PCC for LogNormal data with both parameters unknown

Description

lnorm3_PCC is used to derive the Predictive Control Chart (PCC) for LogNormal data, when both the scale and the shape parameters are unknown.

Usage

lnorm3_PCC(data = NULL, historical_data = NULL,
           mu0 = 0, l0 = 0, a0 = -1/2, b0 = 0, alpha_0 = NULL,
           ARL_0 = 370.4, FAP = NULL, FIR = FALSE, fFIR = .99, aFIR = 1/8,
           summary_list = TRUE, PCC_PLOT = TRUE, PriorPosterior_PLOT = FALSE,
           historical_data_PLOT = FALSE, pdf_report = FALSE, path_pdf_report = tempdir(),
           xlab = "Observation Order", ylab = "Quality characteristic Values",
           main = "PCC LogNormal with unknown parameters")

Arguments

data

vector; a univariate dataset for PCC implementation. Data needs to be in a vector form.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

mu0

scalar; hyperparameter of the prior NIG(mu0, l0, a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior NIG(0, 0, -1/2, 0).

l0

scalar (positive); hyperparameter of the prior NIG(mu0, l0, a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior NIG(0, 0, -1/2, 0).

a0

scalar (positive); hyperparameter of the prior NIG(mu0, l0, a0, b0). It needs to be a number. The default is -1/2 and it refers to the initial reference prior NIG(0, 0, -1/2, 0).

b0

scalar (positive); hyperparameter of the prior NIG(mu0, l0, a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior NIG(0, 0, -1/2, 0).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

ARL_0

scalar (positive); In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4

FAP

scalar (between 0 and 1); False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0. It is based on the Sidak's correction.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PCC is applied, which is an adjustment (narrows the PCC limits) for the initial fisrt tests.

fFIR

a number between 0 and 1; It is used if FIR=TRUE. The default value is 0.99 and represents the proportion of the adjusted PCC region over the initial one for the first test.

aFIR

non-negative number; It is used if FIR=TRUE. The default value is 0.125 and it is a smoothing parameter for the FIR adjustment.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PCC_PLOT

logical; if TRUE, the PCC plot is displayed. It is TRUE by default.

PriorPosterior_PLOT

logical; if TRUE, the Prior and Posterior distribution(s) of the parameter(s) are displayed. It is TRUE by default.

historical_data_PLOT

logical; if TRUE, the historical data are plotted precending the PCC plot. It is FALSE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "Quality characteristic Values" and "PCC LogNormal with unknown parameters" respectively.

Details

lnorm3_PCC provides the Predictive Control Chart (PCC) process for LogNormal data, when both the scale and the shape parameters are unknown. The PCC process is based on the sequential testing of the future observable against the Highest Predictive Density (HPrD), which is obtained by the posterior predictive distribution. The PCC testing starts as early as the second observation.

The joint initial prior for the unknown parameters is a Normal Inverse Gamma: NIG(mu0, l0, a0, b0). Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior NIG(0, 0, -1/2, 0), without the use of historical data. In this special case, the PCC testing starts at the third observation.

A FIR option is available by narrowing the first few control limits. The metrics that can be used to control the false alarms tolerance are either ARL_0 or FAP.

Value

Runs the PCC process, while if FIR=T, then the FIR-PCC is implemented. If plot=T, then a data frame is provided with the data, the upper and the lower limits of the Highest Predictive Density or Mass (HPrD/M) region, and an indication in case of alarms. If PCC_PLOT=T, then the PCC process is visualized, while if historical_data_PLOT=T, the historical data are added to the plot. If PriorPosterior_PLOT = T, a plot with the prior and the posterior is provided. Finally, if pdf_report=T, all the output is reported and saved into a pdf file.

Examples

# 30 LogNormal observations introducing an outlier at the 15th observation
ssddll <- 1/2
set.seed(9)
SimData <- rlnorm( n = 30, meanlog = 0, sdlog = ssddll)
SimData[15] <- SimData[15] + 3*sqrt( exp(ssddll^2)*( exp(ssddll^2)-1 ) )
plot(SimData)
lnorm3_PCC(SimData)

The Highest Density (HD) interval of Logt distribution.

Description

lt_HD is used to derive the narrowest interval of a predetermined coverage from a Logt distribution, containing the Highest Density (HD) values.

Usage

lt_HD( cover = NULL, df = NULL, mulog = NULL, sdlog = NULL, plot = FALSE,
       xlab = "x", ylab = "Density" )

Arguments

cover

scalar (between 0 and 1); The coverage (probability) of the Highest Density (HD). The default value is 0.95.

df

scalar (positive); It is the degrees of freedom of the Logt distribution and needs to be a number.

mulog

scalar (real); It is the scale parameter of the Logt distribution and needs to be a number. The default value is 0.

sdlog

scalar (positive); It is the shape parameter of the Logt distribution and needs to be a number. The default value is 1.

plot

logical; if TRUE, the plot of the HD region is displayed. It is FALSE by default.

xlab, ylab

The titles of the x-axis and y-axis for the HD plot. The default values are "x" and "Density".

Details

lt_HD provides the Highest Density (HD) of a Logt distribution. HD is the narrowest interval with a pretermined coverage. The values included in HD have density larger than every point outside the region.

Value

Returns a data frame with the upper and the lower limits of the Highest Predictive Denisty or Mass (HPrD/M) region, the lower and the achieved coverage. If plot=T, then the HPrD/M is visualized.

Examples

lt_HD(0.95, 10, 0, 1/2, plot = TRUE)

The Highest Mass (HM) interval of Beta-Negative Binomial distribution.

Description

nbinom_HM is used to derive the narrowest interval of a predetermined coverage from a Negative Binomial distribution, containing the Highest Mass (HM) values.

Usage

nbinom_HM( cover = NULL, r = NULL, p = NULL, plot = FALSE,
           xlab = "x", ylab = "Probability" )

Arguments

cover

scalar (between 0 and 1); The coverage (probability) of the Highest Mass (HM).

r

scalar (integer); It is the number of failures until the experiment is stopped.

p

scalar (between 0 and 1); It is the probability of success for each Bernoulli trial.

plot

logical; if TRUE, the plot of the HM region is displayed. It is FALSE by default.

xlab, ylab

The titles of the x-axis and y-axis for the HM plot. The default values are "x" and "Probability".

Details

nbinom_HM provides the Highest Mass (HM) of a Negative Binomial distribution. HM is the narrowest region, with the minimum absolute difference from a pretermined coverage. The values included in HM have probability larger than every point outside the region.

Value

Returns a data frame with the upper and the lower limits of the Highest Predictive Denisty or Mass (HPrD/M) region, the lower and the achieved coverage. If plot=T, then the HPrD/M is visualized.

Examples

nbinom_HM(0.95, 4, 0.2, plot = TRUE)

PCC for Negative Binomial data with probability parameter unknown

Description

nbinom_PCC is used to derive the Predictive Control Chart (PCC) for Negative Binomial data, when the probability parameter is unknown and the number of failures is known.

Usage

nbinom_PCC( data = NULL, historical_data = NULL,
            rl = NULL, a0 = 0, b0 = 1/2, alpha_0 = NULL,
            ARL_0 = 370.4, FAP = NULL, FIR = FALSE, fFIR = .99, aFIR = 1/8,
            summary_list = TRUE, PCC_PLOT = TRUE, PriorPosterior_PLOT = FALSE,
            historical_data_PLOT = FALSE, pdf_report = FALSE, path_pdf_report = tempdir(),
            xlab = "Observations", ylab = "Quality characteristic Values",
            main = "PCC Negative Binomial with unknown probability" )

Arguments

data

vector; a univariate dataset for PCC implementation. Data needs to be in a vector form.

rl

scalar (positive); parameter of the likelihood. It is the known number of failures of the data and needs to be a number.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

a0

scalar (positive); scalar (positive); shape hyperparameter of the prior Beta(a, b). It needs to be a number. The default is 0 and it refers to the initial reference prior Beta(0, 1/2).

b0

scalar (positive); scalar (positive); shape hyperparameter of the prior Beta(a, b). It needs to be a number. The default is 1/2 and it refers to the initial reference prior Beta(0, 1/2).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

ARL_0

scalar (positive); In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4

FAP

scalar (between 0 and 1); False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0. It is based on the Sidak's correction.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PCC is applied, which is an adjustment (narrows the PCC limits) for the initial fisrt tests.

fFIR

a number between 0 and 1; It is used if FIR=TRUE. The default value is 0.99 and represents the proportion of the adjusted PCC region over the initial one for the first test.

aFIR

non-negative number; It is used if FIR=TRUE. The default value is 0.125 and it is a smoothing parameter for the FIR adjustment.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PCC_PLOT

logical; if TRUE, the PCC plot is displayed. It is TRUE by default.

PriorPosterior_PLOT

logical; if TRUE, the Prior and Posterior distribution(s) of the parameter(s) are displayed. It is TRUE by default.

historical_data_PLOT

logical; if TRUE, the historical data are plotted precending the PCC plot. It is FALSE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "Quality characteristic Values" and "PCC Negative Binomial with unknown probability" respectively

Details

nbinom_PCC provides the Predictive Control Chart (PCC) process for Negative Binomial data, when the probability parameter is unknown and the number of failures is known. The PCC process is based on the sequential testing of the future observable against the Highest Predictive Density (HPrD), which is obtained by the posterior predictive distribution. The PCC testing starts as early as the second observation.

The initial prior for the unknown probability is a Beta: Beta(a0, b0). Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior Beta(0, 1/2), without the use of historical data.

A FIR option is available by narrowing the first few control limits. The metrics that can be used to control the false alarms tolerance are either ARL_0 or FAP.

Value

Runs the PCC process, while if FIR=T, then the FIR-PCC is implemented. If plot=T, then a data frame is provided with the data, the upper and the lower limits of the Highest Predictive Density or Mass (HPrD/M) region, and an indication in case of alarms. If PCC_PLOT=T, then the PCC process is visualized, while if historical_data_PLOT=T, the historical data are added to the plot. If PriorPosterior_PLOT = T, a plot with the prior and the posterior is provided. Finally, if pdf_report=T, all the output is reported and saved into a pdf file.

Examples

# 30 Negative Binomial observations introducing an outlier at the 15th observation
set.seed(5)
SimData <- rnbinom(n = 30, size = 10, prob = 0.9)
SimData[15] <- round( SimData[15] + 3*sqrt(10*0.1/(0.9^2)) )
nbinom_PCC(SimData, rl = 10)

The Highest Density (HD) interval of Normal distribution.

Description

norm_HD is used to derive the narrowest interval of a predetermined coverage from a Normal distribution, containing the Highest Density (HD) values.

Usage

norm_HD( cover = NULL, mu = NULL, sdv = NULL, plot = FALSE,
         xlab = "x", ylab = "Density" )

Arguments

cover

scalar (between 0 and 1); The coverage (probability) of the Highest Density (HD).

mu

scalar (real); It is the mean of the Normal distribution and needs to be a number.

sdv

scalar (positive); It is the standand deviation of the Normal distribution and needs to be a number.

plot

logical; if TRUE, the plot of the HD region is displayed. It is FALSE by default.

xlab, ylab

The titles of the x-axis and y-axis for the HD plot. The default values are "x" and "Density".

Details

norm_HD provides the Highest Density (HD) of a Normal distribution. HD is the narrowest interval with a pretermined coverage. The values included in HD have density larger than every point outside the region.

Value

Returns a data frame with the upper and the lower limits of the Highest Predictive Denisty or Mass (HPrD/M) region, the lower and the achieved coverage. If plot=T, then the HPrD/M is visualized.

Examples

norm_HD(0.95, mu = 10, sdv = 1/2, plot = TRUE)

PRC for Normal data with unknown parameters (mean)

Description

norm_mean2_PRC is used to derive the Predictive Ratio CUSUM (PRC) for the mean of Normal data, when both the mean and the variance are unknown.

Usage

norm_mean2_PRC( data = NULL, historical_data = NULL, mu0 = 0, l0 = 0,
                a0 = -1/2, b0 = 0, alpha_0 = NULL, k = 1, two.sided = FALSE,
                h = log(100), FIR = FALSE, fFIR = 1/2, dFIR = 3/4,
                summary_list = TRUE, PRC_PLOT = TRUE, pdf_report = FALSE,
                path_pdf_report = tempdir(), xlab = "Observation Order",
                ylab = "PRC cumulative statistics",
                main = "PRC Normal with unknown parameters (mean model)" )

Arguments

data

vector; a univariate dataset for PCC implementation. Data needs to be in a vector form.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

mu0

scalar; hyperparameter of the prior NIG(mu0, l0, a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior NIG(0, 0, -1/2, 0).

l0

scalar (positive); hyperparameter of the prior NIG(mu0, l0, a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior NIG(0, 0, -1/2, 0).

a0

scalar (positive); hyperparameter of the prior NIG(mu0, l0, a0, b0). It needs to be a number. The default is -1/2 and it refers to the initial reference prior NIG(0, 0, -1/2, 0).

b0

scalar (positive); hyperparameter of the prior NIG(mu0, l0, a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior NIG(0, 0, -1/2, 0).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

k

scalar (positive); tuning parameter, which represents deviation between IC and OOC state. Precisely, if k>1 then the OOC state corresponds to a k standard deviations increase in the mean and if k<1 corresponds to a k standard deviations decrease. The default value is 1.

two.sided

logical; If TRUE, then a two sided PRC is employed with tuning parameters k and 1/k respectively. It is FALSE by default.

h

scalar (positive); Decision limit and we raise an alarm if the cumulative statistic exceeds it (or ?h for two sided shifts). The default value is log(100)=4.605, fow which we have a decisive cumulative evidence in favor of the OOC state.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PRC is applied, which is an exponentially decreasing adjustment for the initial fisrt tests, inflating the PRC statistics.

fFIR

non-negative number; It is used if FIR=TRUE. It represents the proportion of the inflation for the PRC statistic in the for the fisrt test. The default value is 1/2.

dFIR

a number between 0 and 1; It is used if FIR=TRUE. It is a smoothing parameter, specifying the exponential decay of the adjustment (the smaller the d the fastest the decay). The default value is 3/4.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PRC_PLOT

logical; if TRUE, the PRC plot is displayed. It is TRUE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "PRC cumulative statistics" and "PRC Binomial with unknown probability" respectively

Details

norm_mean2_PRC provides the Predictive Ratio CUSUM (PRC) process for the mean of Normal data, when both the mean and the variance are unknown. The PRC process is based on sequential comparison between the IC and OOC state, via their predictive distributions. The parameter k represents the deviance between these two states. The default value is k=1, which corresponds to one standard deviation increase in the mean. The testing starts as early as the second observation, apart from when using the default non-informative prior, without historical data. In this special case, the PCC testing starts at the third observation.

The initial prior for the unknown probability is a Normal Inverse Gamma: NIG(mu0, l0, a0, b0). Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior NIG(0, 0, -1/2, 0), without the use of historical data.

A FIR option is available by inlfating the first few PRC statistics. The choice of the decision limit h reflects the false alarm tolerance.

Examples

# the PRC process for the first application in
# "Design and properties of the Predictive Ratio Cusum (PRC) control charts"


### CD: Current data (New reagent)
### HD: Historical data (Previous reagent)

CD <- c( 31.0, 30.0, 32.0, 28.0, 33.2, 33.2, 35.1, 35.1, 33.9, 37.9,
         33.2, 36.5, 33.2, 35.1, 34.5, 36.5, 33.2, 35.1, 37.2, 32.6, 36.5 )
HD <- c( 31, 30, 33, 30, 33, 30, 31, 32, 32, 30, 33, 31, 34, 31, 34, 34, 36, 30,
         33, 29, 34, 32, 32, 28, 34, 32, 32, 30, 31, 29, 31, 29, 31, 32,34,34,32 )

N <- length(CD)
n0 <- length(HD)

### initial prior parameters

M0F <- 31.8
LF <- 1/2
AF <- 2
BF <- 2.1^2

norm_mean2_PRC( data = CD, historical_data = HD, alpha_0 = 1/n0, mu0 = M0F,
                l0 = LF, a0 = AF, b0 = BF, h = 3.749, two.sided = TRUE )



### a real data application to aPTT values

### CURRENT DATA aPTT
CD <- c( 29.0, 29.1, 28.7, 28.2, 28.0, 29.1, 28.6, 28.7, 28.6, 29.0, 28.4,
         28.1, 28.8, 29.7, 28.8, 29.8, 28.8, 29.4, 28.4, 28.7, 28.7, 29.5,
         28.5, 28.4, 28.1, 28.6, 28.2, 29.6, 28.9, 29.1, 29.0, 29.9, 28.6,
         29.3, 28.2, 28.6, 27.6, 27.3, 28.7, 27.2, 28.4, 28.0, 28.4, 27.8,
         28.4, 28.4, 27.7, 29.2, 27.5, 27.7)

### HISTORICAL DATA aPTT
HD <- c( 28.0, 28.9, 27.7, 29.3, 28.9, 29.5, 28.2, 27.5, 28.8, 28.9, 28.7,
         27.4, 28.6, 28.5, 29.6, 28.7, 21.3, 29.4, 28.1, 28.9, 28.3, 27.6,
         29.0, 29.2, 27.8, 29.1, 28.9, 29.4, 29.4, 28.9, 28.9, 29.2, 29.4,
         29.4, 28.1, 28.5, 29.7, 29.3, 28.6, 29.2, 29.3, 29.3, 29.3, 30.0,
         29.1, 29.1, 26.8, 29.0, 29.3, 28.3)


norm_mean2_PRC( data = CD, historical_data = HD, mu0 = 28.9,
                l0 = 1/4, a0 = 2, b0 = 0.49, two.sided = TRUE )

Derivation of the decision limit for the PRC for Normal data with unknown parameters (mean)

Description

norm_mean2_PRC_h is used to estimate the decision limit h for the Predictive Ratio CUSUM (PRC) for the mean of Normal data, when both the mean and the variance are unknown. The process controls the false alarms tolerance, providing the ARL_0 or the FAP, based on the standardized predictive distribution.

Usage

norm_mean2_PRC_h( ARL_0 = 370.4, FAP = NULL, N=NULL, historical_data = NULL,
                  l0 = 0, a0 = -1/2, alpha_0 = NULL, k = 1, it = 1e4,
                  ARL0tol = 10/it )

Arguments

ARL_0

scalar (positive); lower bound of the In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4.

FAP

scalar (between 0 and 1); lower bound of the False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0.

N

scalar (natural); number of N hypothesis tests. It is used for the FAP determination.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

l0

scalar (positive); shape hyperparameter of the prior Beta(a, b). It needs to be a number. The default is 0.

a0

scalar (positive); shape hyperparameter of the prior Beta(a, b). It needs to be a number. The default is -1/2.

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

k

scalar (positive); tuning parameter, which represents deviation between IC and OOC state. Precisely, if k>1 then the OOC state corresponds to a k standard deviations increase in the mean and if k<1 corresponds to a k standard deviations decrease. The default value is 1.

it

scalar (natural); iterations of the simulation. The default value is 10000.

ARL0tol

scalar (positive); relative tolerance of ARL_0 estimate. It represents the maximum amount of error which is allowed. The default value is 10/it.

Details

norm_mean2_PRC_h estimates the desicion limit h regarding the desired upper bound of false alarms tolerance for the Predictive Ratio CUSUM (PRC) process for the mean of Normal data, when both the mean and variance are unknown. The estimate concerns an one-sided PRC process and the default setup corresponds to one standard deviation increase in the mean. The estimate is based on the use of the standardized predictive distribution and the incorporation of historical data is possible via the power prior.

The default metric of the false alarms tolerance is ARL_0=370.4, while a FAP option is available. The desicion limit is obtained via the numerical method regula falsi when ARL_0 is selected, while simulated samples of fixed size are used when FAP is of interest.

Examples

# Derivation of the decision limit of the first application in
# "Design and properties of the Predictive Ratio Cusum (PRC) control charts"

CD <- c( 31.0, 30.0, 32.0, 28.0, 33.2, 33.2, 35.1, 35.1, 33.9, 37.9,
         33.2, 36.5, 33.2, 35.1, 34.5, 36.5, 33.2, 35.1, 37.2, 32.6, 36.5 )
HD <- c( 31, 30, 33, 30, 33, 30, 31, 32, 32, 30, 33, 31, 34, 31, 34, 34, 36, 30,
         33, 29, 34, 32, 32, 28, 34, 32, 32, 30, 31, 29, 31, 29, 31, 32, 34, 34, 32 )

N <- length(CD)
n0 <- length(HD)
Pa0 <- 1/n0
M0F <- 31.8
LF <- 1/2
AF <- 2
BF <- 2.1^2
M0F ; LF ; AF ; BF

# To replicate results from application set 'it = 1e5'
norm_mean2_PRC_h( ARL_0 = NULL, FAP = 0.05, N = N, l0 = LF, a0 = AF,
                  historical_data = HD, alpha_0 = Pa0, it = 1e4 )

PCC for Normal data with mean unknown

Description

norm1_PCC is used to derive the Predictive Control Chart (PCC) for Normal data, when the mean is unknown and the variance is known.

Usage

norm1_PCC(data = NULL, historical_data = NULL, sdl = NULL,
         mu0 = 0, sd0 = 10^6, alpha_0 = NULL,
         ARL_0 = 370.4, FAP = NULL, FIR = FALSE, fFIR = .99, aFIR=1/8,
         summary_list = TRUE, PCC_PLOT = TRUE, PriorPosterior_PLOT = FALSE,
         historical_data_PLOT = FALSE, pdf_report = FALSE, path_pdf_report = tempdir(),
         xlab = "Observations", ylab = "Quality characteristic Values",
         main="PCC Normal with unknown mean")

Arguments

data

vector; a dataset for PCC implementation. Data needs to be in a vector form.

historical_data

vector; an optional dataset of historical data. Historical data needs to be in a vector form.

sdl

scalar (positive); parameter of the likelihood. It is the known standand deviation of the data and needs to be a number.

mu0

scalar; hyperparameter of the prior N(mu0, sd0^2). It needs to be a number. The default is 0 and it refers to the initial reference prior N(0, \infty).

sd0

scalar (positive); hyperparameter of the prior N(mu0, sd0^2). It needs to be a number. The default is 10^6 and it refers to the initial reference prior N(0, \infty).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

ARL_0

scalar (positive); In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4

FAP

scalar (between 0 and 1); False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0. It is based on the Sidak's correction.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PCC is applied, which is an adjustment (narrows the PCC limits) for the initial fisrt tests.

fFIR

a number between 0 and 1; It is used if FIR=TRUE. The default value is 0.99 and represents the proportion of the adjusted PCC region over the initial one for the first test.

aFIR

non-negative number; It is used if FIR=TRUE. The default value is 0.125 and it is a smoothing parameter for the FIR adjustment.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PCC_PLOT

logical; if TRUE, the PCC plot is displayed. It is TRUE by default.

PriorPosterior_PLOT

logical; if TRUE, the Prior and Posterior distribution(s) of the parameter(s) are displayed. It is TRUE by default.

historical_data_PLOT

logical; if TRUE, the historical data are plotted precending the PCC plot. It is FALSE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "Quality characteristic Values" and "PCC Normal with unknown mean" respectively.

Details

norm1_PCC provides the Predictive Control Chart (PCC) process for Normal data, when the mean is unknown and the variance is known. The PCC process is based on the sequential testing of the future observable against the Highest Predictive Density (HPrD), which is obtained by the posterior predictive distribution. The PCC testing starts as early as the second observation.

The initial prior for the unknown mean is a Normal: N(mu0, sd0^2). Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior N(0, \infty), without the use of historical data.

A FIR option is available by narrowing the first few control limits. The metrics that can be used to control the false alarms tolerance are either ARL_0 or FAP.

Value

Runs the PCC process, while if FIR=T, then the FIR-PCC is implemented. If plot=T, then a data frame is provided with the data, the upper and the lower limits of the Highest Predictive Density or Mass (HPrD/M) region, and an indication in case of alarms. If PCC_PLOT=T, then the PCC process is visualized, while if historical_data_PLOT=T, the historical data are added to the plot. If PriorPosterior_PLOT = T, a plot with the prior and the posterior is provided. Finally, if pdf_report=T, all the output is reported and saved into a pdf file.

Examples

# 30 Normal observations introducing an outlier of 3*sd at the 15th observation
set.seed(1234)
out <- rnorm(30)
out[15] <- out[15] + 3
norm1_PCC(out, sdl = 1)

# Real data application
attach(aPTT)
norm1_PCC(data = aPTT_current, historical_data = aPTT_historical, sdl = 0.57)

PCC for Normal data with variance unknown

Description

norm2_PCC is used to derive the Predictive Control Chart (PCC) for Normal data, when the variance is unknown and the mean is known.

Usage

norm2_PCC(data = NULL, historical_data = NULL, ml = NULL,
          a0 = 0, b0 = 0, alpha_0 = NULL,
          ARL_0 = 370.4, FAP = NULL, FIR = FALSE, fFIR = .99, aFIR = 1/8,
          summary_list = TRUE, PCC_PLOT = TRUE, PriorPosterior_PLOT = FALSE,
          historical_data_PLOT = FALSE, pdf_report = FALSE, path_pdf_report = tempdir(),
          xlab = "Observation Order", ylab = "Quality characteristic Values",
          main = "PCC Normal with unknown variance")

Arguments

data

vector; a dataset for PCC implementation. Data needs to be in a vector form.

historical_data

vector; an optional dataset of historical data. Historical data needs to be in a vector form.

ml

scalar; parameter of the likelihood. It is the known mean of the data and needs to be a number.

a0

scalar (positive); hyperparameter of the prior IG(a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior IG(0, 0).

b0

scalar (positive); hyperparameter of the prior IG(a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior IG(0, 0).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

ARL_0

scalar (positive); In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4

FAP

scalar (between 0 and 1); False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0. It is based on the Sidak's correction.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PCC is applied, which is an adjustment (narrows the PCC limits) for the initial fisrt tests.

fFIR

a number between 0 and 1; It is used if FIR=TRUE. The default value is 0.99 and represents the proportion of the adjusted PCC region over the initial one for the first test.

aFIR

non-negative number; It is used if FIR=TRUE. The default value is 0.125 and it is a smoothing parameter for the FIR adjustment.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PCC_PLOT

logical; if TRUE, the PCC plot is displayed. It is TRUE by default.

PriorPosterior_PLOT

logical; if TRUE, the Prior and Posterior distribution(s) of the parameter(s) are displayed. It is TRUE by default.

historical_data_PLOT

logical; if TRUE, the historical data are plotted precending the PCC plot. It is FALSE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "Quality characteristic Values" and "PCC Normal with unknown variance" respectively

Details

norm2_PCC provides the Predictive Control Chart (PCC) process for Normal data, when the variance is unknown and the mean is known. The PCC process is based on the sequential testing of the future observable against the Highest Predictive Density (HPrD), which is obtained by the posterior predictive distribution. The PCC testing starts as early as the second observation.

The initial prior for the unknown variance is an Inverse Gamma: IG(a0, b0). Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior IG(0, 0), without the use of historical data.

A FIR option is available by narrowing the first few control limits. The metrics that can be used to control the false alarms tolerance are either ARL_0 or FAP.

Value

Runs the PCC process, while if FIR=T, then the FIR-PCC is implemented. If plot=T, then a data frame is provided with the data, the upper and the lower limits of the Highest Predictive Density or Mass (HPrD/M) region, and an indication in case of alarms. If PCC_PLOT=T, then the PCC process is visualized, while if historical_data_PLOT=T, the historical data are added to the plot. If PriorPosterior_PLOT = T, a plot with the prior and the posterior is provided. Finally, if pdf_report=T, all the output is reported and saved into a pdf file.

Examples

# 30 Normal observations introducing an outlier of 3*sd at the 15th observation
set.seed(1234)
out <- rnorm(30)
out[15] <- out[15] + 3
norm2_PCC(out, ml = 0)

# Real data application
attach(aPTT)
norm2_PCC(data = aPTT_current, historical_data = aPTT_historical, ml = 30)

PCC for Normal data with both parameters unknown

Description

norm3_PCC is used to derive the Predictive Control Chart (PCC) for Normal data, when both the mean and the variance are unknown.

Usage

norm3_PCC(data = NULL, historical_data = NULL,
          mu0 = 0, l0 = 0, a0 = -1/2, b0 = 0, alpha_0 = NULL,
          ARL_0 = 370.4, FAP = NULL, FIR = FALSE, fFIR = .99, aFIR = 1/8,
          summary_list = TRUE, PCC_PLOT = TRUE, PriorPosterior_PLOT = FALSE,
          historical_data_PLOT = FALSE, pdf_report = FALSE, path_pdf_report = tempdir(),
          xlab = "Observation Order", ylab = "Quality characteristic Values",
          main = "PCC Normal with unknown parameters")

Arguments

data

vector; a univariate dataset for PCC implementation. Data needs to be in a vector form.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

mu0

scalar; hyperparameter of the prior NIG(mu0, l0, a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior NIG(0, 0, -1/2, 0).

l0

scalar (positive); hyperparameter of the prior NIG(mu0, l0, a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior NIG(0, 0, -1/2, 0).

a0

scalar (positive); hyperparameter of the prior NIG(mu0, l0, a0, b0). It needs to be a number. The default is -1/2 and it refers to the initial reference prior NIG(0, 0, -1/2, 0).

b0

scalar (positive); hyperparameter of the prior NIG(mu0, l0, a0, b0). It needs to be a number. The default is 0 and it refers to the initial reference prior NIG(0, 0, -1/2, 0).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

ARL_0

scalar (positive); In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4

FAP

scalar (between 0 and 1); False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0. It is based on the Sidak's correction.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PCC is applied, which is an adjustment (narrows the PCC limits) for the initial fisrt tests.

fFIR

a number between 0 and 1; It is used if FIR=TRUE. The default value is 0.99 and represents the proportion of the adjusted PCC region over the initial one for the first test.

aFIR

non-negative number; It is used if FIR=TRUE. The default value is 0.125 and it is a smoothing parameter for the FIR adjustment.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PCC_PLOT

logical; if TRUE, the PCC plot is displayed. It is TRUE by default.

PriorPosterior_PLOT

logical; if TRUE, the Prior and Posterior distribution(s) of the parameter(s) are displayed. It is TRUE by default.

historical_data_PLOT

logical; if TRUE, the historical data are plotted precending the PCC plot. It is FALSE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "Quality characteristic Values" and "PCC Normal with unknown parameters" respectively.

Details

norm3_PCC provides the Predictive Control Chart (PCC) process for Normal data, when both the mean and the variance are unknown. The PCC process is based on the sequential testing of the future observable against the Highest Predictive Density (HPrD), which is obtained by the posterior predictive distribution. The PCC testing starts as early as the second observation.

The joint initial prior for the unknown parameters is a Normal Inverse Gamma: NIG(mu0, l0, a0, b0). Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior NIG(0, 0, -1/2, 0), without the use of historical data. In this special case, the PCC testing starts at the third observation.

A FIR option is available by narrowing the first few control limits. The metrics that can be used to control the false alarms tolerance are either ARL_0 or FAP.

Value

Runs the PCC process, while if FIR=T, then the FIR-PCC is implemented. If plot=T, then a data frame is provided with the data, the upper and the lower limits of the Highest Predictive Density or Mass (HPrD/M) region, and an indication in case of alarms. If PCC_PLOT=T, then the PCC process is visualized, while if historical_data_PLOT=T, the historical data are added to the plot. If PriorPosterior_PLOT = T, a plot with the prior and the posterior is provided. Finally, if pdf_report=T, all the output is reported and saved into a pdf file.

Examples

# 30 Normal observations introducing an outlier of 3*sd at the 15th observation
set.seed(1234)
out <- rnorm(30)
out[15] <- out[15] + 3
norm3_PCC(out)

# Real data application
attach(aPTT)
norm3_PCC(data = aPTT_current, historical_data = aPTT_historical)

PCC for Poisson data with rate parameter unknown

Description

pois_PCC is used to derive the Predictive Control Chart (PCC) for Poisson data, when the rate parameter is unknown.

Usage

pois_PCC( data = NULL, s = NULL, historical_data = NULL,
          historical_s = NULL, c0 = 1/2, d0 = 0, alpha_0 = NULL,
          ARL_0 = 370.4, FAP = NULL, FIR = FALSE, fFIR = .99, aFIR = 1/8,
          summary_list = TRUE, PCC_PLOT = TRUE, PriorPosterior_PLOT = FALSE,
          historical_data_PLOT = FALSE, pdf_report = FALSE, path_pdf_report = tempdir(),
          xlab = "Observation Order", ylab = "Quality characteristic Values",
          main = "PCC Poisson with rate unknown" )

Arguments

data

vector; a univariate dataset for PCC implementation. Data needs to be in a vector form.

s

vector; refers to the period of time or grouping of counts, if data are rate dataset. It needs to be in a vector form.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

historical_s

vector; refers to the period of time or grouping of counts, if historical_data are rate dataset. It needs to be in a vector form.

c0

scalar (positive); scalar (positive); hyperparameter of the prior G(c0, d0). It needs to be a number. The default is 1/2 and it refers to the initial reference prior G(1/2, 0).

d0

scalar (positive); scalar (positive); hyperparameter of the prior G(c0, d0). It needs to be a number. The default is 0 and it refers to the initial reference prior G(1/2, 0).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

ARL_0

scalar (positive); In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4

FAP

scalar (between 0 and 1); False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0. It is based on the Sidak's correction.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PCC is applied, which is an adjustment (narrows the PCC limits) for the initial fisrt tests.

fFIR

a number between 0 and 1; It is used if FIR=TRUE. The default value is 0.99 and represents the proportion of the adjusted PCC region over the initial one for the first test.

aFIR

non-negative number; It is used if FIR=TRUE. The default value is 0.125 and it is a smoothing parameter for the FIR adjustment.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PCC_PLOT

logical; if TRUE, the PCC plot is displayed. It is TRUE by default.

PriorPosterior_PLOT

logical; if TRUE, the Prior and Posterior distribution(s) of the parameter(s) are displayed. It is TRUE by default.

historical_data_PLOT

logical; if TRUE, the historical data are plotted precending the PCC plot. It is FALSE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "Quality characteristic Values" and "PCC Poisson" respectively

Details

pois_PCC provides the Predictive Control Chart (PCC) process for Poisson data, when the rate parameter is unknown. The PCC process is based on the sequential testing of the future observable against the Highest Predictive Density (HPrD), which is obtained by the posterior predictive distribution. The PCC testing starts as early as the second observation.

The initial prior for the unknown rate is a Gamma: G(c, d), where d is the rate parameter. Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior G(1/2, 0), without the use of historical data.

A FIR option is available by narrowing the first few control limits. The metrics that can be used to control the false alarms tolerance are either ARL_0 or FAP.

Value

Runs the PCC process, while if FIR=T, then the FIR-PCC is implemented. If plot=T, then a data frame is provided with the data, the upper and the lower limits of the Highest Predictive Density or Mass (HPrD/M) region, and an indication in case of alarms. If PCC_PLOT=T, then the PCC process is visualized, while if historical_data_PLOT=T, the historical data are added to the plot. If PriorPosterior_PLOT = T, a plot with the prior and the posterior is provided. Finally, if pdf_report=T, all the output is reported and saved into a pdf file.

Examples

# 30 Poisson observations introducing an outlier at the 15th observation
set.seed(1111)
out <- rpois(n = 30, lambda = 4)
out[15] <- out[15] + 6
pois_PCC(out)

# Real data application
attach(ECE)
pois_PCC(data = defect_counts, s = inspected_units)

PRC for Poisson data with rate parameter unknown

Description

pois_PRC is used to derive the Predictive Ratio CUSUM (PRC) for Poisson data, when the rate parameter is unknown.

Usage

pois_PRC( data = NULL, s = NULL, historical_data = NULL, historical_s = NULL,
          c0 = 1/2, d0 = 0, alpha_0 = NULL, k=2, two.sided=FALSE,
          h = log(100), FIR = FALSE, fFIR = 1/2, dFIR = 3/4,
          summary_list = TRUE, PRC_PLOT = TRUE, pdf_report = FALSE,
          path_pdf_report = tempdir(),
          xlab = "Observation Order", ylab = "PRC cumulative statistics",
          main = "PRC Poisson with unknown rate" )

Arguments

data

vector; a univariate dataset for PCC implementation. Data needs to be in a vector form.

s

vector; refers to the period of time or grouping of counts, if data are rate dataset. It needs to be in a vector form.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

historical_s

vector; refers to the period of time or grouping of counts, if historical_data are rate dataset. It needs to be in a vector form.

c0

scalar (positive); scalar (positive); hyperparameter of the prior G(c0, d0). It needs to be a number. The default is 1/2 and it refers to the initial reference prior G(1/2, 0).

d0

scalar (positive); scalar (positive); hyperparameter of the prior G(c0, d0). It needs to be a number. The default is 0 and it refers to the initial reference prior G(1/2, 0).

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

k

scalar (positive); tuning parameter, which represents deviation between IC and OOC state. Precisely, if k>1 then the OOC state corresponds to a (k-1)100% increase in the rate parameter and if k<1 corresponds (1-k)100% decrease. The dafault value is 2.

two.sided

logical; If TRUE, then a two sided PRC is employed with tuning parameters k and 1/k respectively. It is FALSE by default.

h

scalar (positive); Decision limit and we raise an alarm if the cumulative statistic exceeds it (or ?h for two sided shifts). The default value is log(100)=4.605, fow which we have a decisive cumulative evidence in favor of the OOC state.

FIR

logical; If TRUE, then the Fast Initial Response (FIR) PRC is applied, which is an exponentially decreasing adjustment for the initial fisrt tests, inflating the PRC statistics.

fFIR

non-negative number; It is used if FIR=TRUE. It represents the proportion of the inflation for the PRC statistic in the for the fisrt test. The default value is 1/2.

dFIR

a number between 0 and 1; It is used if FIR=TRUE. It is a smoothing parameter, specifying the exponential decay of the adjustment (the smaller the d the fastest the decay). The default value is 3/4.

summary_list

logical; If it is TRUE, then a data frame is provided, containing the data sequence, the PCC limits along with the possible occurence of an alarm. It is TRUE by default.

PRC_PLOT

logical; if TRUE, the PRC plot is displayed. It is TRUE by default.

pdf_report

logical; if TRUE then the summary list, PCC plot and Prior/Posterior distribution(s) of the parameter(s) are reported in a pdf file.

path_pdf_report

specified path to save pdf report if pdf_report=TRUE. The default path is the temporary direction tempdir().

xlab, ylab, main

The titles of the x-axis, y-axis and the overall title for the PCC plot. The default values are "Observation Order", "PRC cumulative statistics" and "PRC Binomial with unknown probability" respectively

Details

pois_PRC provides the Predictive Ratio CUSUM (PRC) process for Poisson data, when the rate parameter parameter is unknown. The PRC process is based on sequential comparison between the IC and OOC state, via their predictive distributions. The parameter k represents the deviance between these two states. The default value is k=2, which corresponds to a doubling of the rate parameter. The testing starts as early as the second observation.

The initial prior for the unknown probability is a Gamma: G(c0, d0). Furthermore, the direct use of available historical data is possible via the power prior, if they are available. In this case, the default value for the power prior parameter alpha_0 is the reciprocal of the length of the historical data, which conveys the weight of a single observation to the prior information. The default prior is the non-informative reference prior G(1/2, 0), without the use of historical data.

A FIR option is available by inlfating the first few PRC statistics. The choice of the decision limit h reflects the false alarm tolerance.

Examples

# the PRC process for the second application in
# "Design and properties of the Predictive Ratio Cusum (PRC) control charts"

### CURRENT DATA
CD <- c(1, 0, 0, 0, 1, 0, 3, 3, 3, 2, 5, 5, 2, 4, 4, 3, 4, 3, 8, 3, 2, 2)

### product exposures per million

sn <- c( 0.206, 0.313, 0.368, 0.678, 0.974, 0.927, 0.814, 0.696, 0.659, 0.775, 0.731,
         0.710, 0.705, 0.754, 0.682, 0.686, 0.763, 0.833, 0.738, 0.741, 0.843, 0.792 )

# regular process
pois_PRC(data = CD, s = sn)

# FIR process
pois_PRC(data = CD, s = sn, FIR = TRUE)

Derivation of the decision limit for the PRC for Poisson data with probability parameter unknown

Description

pois_PRC_h is used to estimate the decision limit h for the Predictive Ratio CUSUM (PRC) for Poisson data. The process controls the false alarms tolerance, providing a lower bound of ARL_0 or FAP, based on the marginal distribution.

Usage

pois_PRC_h( ARL_0 = 370.4, FAP = NULL, N = NULL, s = NULL,
            historical_data = NULL, historical_s = NULL,
            c0 = NULL, d0 = NULL, alpha_0 = NULL, k = 2,
            it = 1e4, ARL0tol = 10/it )

Arguments

ARL_0

scalar (positive); lower bound of the In Control (IC) Average Run Length (ARL). It is average number of IC data points that we will plot in the PCC before a false alarm occurs. The default value is 370.4.

FAP

scalar (between 0 and 1); lower bound of the False Alarm Probability (FAP). It is the probability of raising at least one false alarm out of a pre-determined number of N hypothesis tests and it can be used instead of ARL_0.

N

scalar (natural); number of N hypothesis tests. It is used for the FAP determination.

s

vector; refers to the period of time or grouping of counts, if data are rate dataset. It needs to be in a vector form.

historical_data

vector; an optional univariate dataset of historical data. Historical data needs to be in a vector form.

historical_s

vector; refers to the period of time or grouping of counts, if historical_data are rate dataset. It needs to be in a vector form.

c0

scalar (positive); scalar (positive); hyperparameter of the prior G(c0, d0). It needs to be a number.

d0

scalar (positive); scalar (positive); hyperparameter of the prior G(c0, d0). It needs to be a number.

alpha_0

scalar (non negative); It is a power prior parameter controlling the influence of the historical data on the posterior distribution. The default is 1/n_0, where n_0 is the size of the historical data.

k

scalar (positive); tuning parameter, which represents deviation between IC and OOC state. Precisely, if k>1 then the OOC state corresponds to a (k-1)100% increase in the rate parameter and if k<1 corresponds (1-k)100% decrease. The dafault value is 2.

it

scalar (natural); iterations of the simulation. The default value is 10000.

ARL0tol

scalar (positive); relative tolerance of ARL_0 estimate. It represents the maximum amount of error which is allowed. The default value is 10/it.

Details

pois_PRC_h estimates the desicion limit h regarding the desired upper bound of false alarms tolerance for the Predictive Ratio CUSUM (PRC) process for Binomial data, when the probability parameter is unknown. The estimate concerns an one-sided PRC process and the default setup corresponds to a doubling of the rate parameter (k=2). The estimate is based on the use of the marginal distribution (prior predictive) and the incorporation of historical data is possible via the power prior.

The default metric of the false alarms tolerance is ARL_0=370.4, while a FAP option is available. The desicion limit is obtained via the numerical method regula falsi when ARL_0 is selected, while simulated samples of fixed size are used when FAP is of interest.

Examples

pois_PRC_h(ARL_0 = 150, c0 = 40, d0 = 10, it = 1e3)

The Highest Density (HD) interval of Student's t distribution.

Description

t_HD is used to derive the narrowest interval of a predetermined coverage from a Student's t distribution, containing the Highest Density (HD) values.

Usage

t_HD( cover = NULL, df = NULL, mu = NULL, sdv = NULL, plot = FALSE,
      xlab = "x", ylab = "Density" )

Arguments

cover

scalar (between 0 and 1); The coverage (probability) of the Highest Density (HD).

df

scalar (positive); It is the degrees of freedom of the Student's t distribution and needs to be a number.

mu

scalar (real); It is the mean of the Student's t distribution and needs to be a number. The default value is 0.

sdv

scalar (positive); It is the scale parameter of the Student's t distribution and needs to be a number. The default value is 1.

plot

logical; if TRUE, the plot of the HD region is displayed. It is FALSE by default.

xlab, ylab

The titles of the x-axis and y-axis for the HD plot. The default values are "x" and "Density".

Details

t_HD provides the Highest Density (HD) of a Student's t distribution. HD is the narrowest interval with a pretermined coverage. The values included in HD have density larger than every point outside the region.

Value

Returns a data frame with the upper and the lower limits of the Highest Predictive Denisty or Mass (HPrD/M) region, the lower and the achieved coverage. If plot=T, then the HPrD/M is visualized.

Examples

t_HD( 0.95, df = 2, mu = 2, sdv = 3, plot = TRUE )