| Title: | Statistical Process Control Based on Gamma-Frailty AFT Models |
|---|---|
| Description: | Implements statistical process control ('SPC') monitoring schemes for heterogeneous reliability observations using Accelerated Failure Time ('AFT') models integrated with continuous gamma frailty. It accommodates both uncensored and right-censored reliability observations in the presence of observed and unobserved covariates. Provides Phase I maximum likelihood estimation of Weibull 'AFT' gamma frailty model parameters, and Phase II monitoring procedures including probability-limits-based control charts, exponentially weighted moving average ('EWMA') charts with conditional expected values, and likelihood-ratio cumulative sum ('CUSUM') control charts. Competing 'CUSUM' schemes (ignoring unobserved frailty or both covariates) and Average Run Length ('ARL') simulation utilities are also provided. The statistical methodology is based on Asadzadeh (2022) <doi:10.1080/00949655.2021.1959582>. |
| Authors: | Shikhar Tyagi [aut, cre] (ORCID: <https://orcid.org/0000-0003-1606-0844>), Arvind Pandey [aut], Bhupendra Singh [aut], Vrijesh Tripathi [aut] |
| Maintainer: | Shikhar Tyagi <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-10-08 10:12:43 UTC |
| Source: | https://github.com/cran/GammaFrailtySPC |
Density, distribution function, quantile function, and random generation for the Weibull Accelerated Failure Time (AFT) distribution integrated with gamma frailty as defined in Asadzadeh (2022).
dgamma_aft( x, beta0, beta1, covariates = 0, shape_kappa, frailty_lambda, log = FALSE ) pgamma_aft( q, beta0, beta1, covariates = 0, shape_kappa, frailty_lambda, lower.tail = TRUE, log.p = FALSE ) qgamma_aft( p, beta0, beta1, covariates = 0, shape_kappa, frailty_lambda, lower.tail = TRUE, log.p = FALSE ) rgamma_aft(n, beta0, beta1, covariates = 0, shape_kappa, frailty_lambda)dgamma_aft( x, beta0, beta1, covariates = 0, shape_kappa, frailty_lambda, log = FALSE ) pgamma_aft( q, beta0, beta1, covariates = 0, shape_kappa, frailty_lambda, lower.tail = TRUE, log.p = FALSE ) qgamma_aft( p, beta0, beta1, covariates = 0, shape_kappa, frailty_lambda, lower.tail = TRUE, log.p = FALSE ) rgamma_aft(n, beta0, beta1, covariates = 0, shape_kappa, frailty_lambda)
x |
Vector of non-negative quantiles or random generation sample size ( |
beta0 |
Intercept parameter of the AFT log-scale model ( |
beta1 |
Vector or scalar of regression coefficients ( |
covariates |
Matrix or vector of observed covariate values matching |
shape_kappa |
Positive shape parameter of the Weibull baseline distribution ( |
frailty_lambda |
Positive parameter of the gamma frailty distribution ( |
log, log.p
|
Logical; if TRUE, probabilities/densities |
q |
Vector of quantiles. |
lower.tail |
Logical; if TRUE (default), probabilities are |
p |
Vector of probabilities. |
n |
Number of observations for random generation. |
dgamma_aft gives the density, pgamma_aft gives the distribution function,
qgamma_aft gives the quantile function, and rgamma_aft generates random deviates.
Asadzadeh, S. (2022). Statistical process control based on gamma-frailty models for heterogeneous reliability observations. *Journal of Statistical Computation and Simulation*, 92(2), 337-351. doi:10.1080/00949655.2021.1959582
# Density calculation dgamma_aft(x = 10, beta0 = 4.12, beta1 = -0.15, covariates = 3, shape_kappa = 1.72, frailty_lambda = 1.17) # Cumulative distribution calculation pgamma_aft(q = 10, beta0 = 4.12, beta1 = -0.15, covariates = 3, shape_kappa = 1.72, frailty_lambda = 1.17) # Quantile calculation qgamma_aft(p = 0.5, beta0 = 4.12, beta1 = -0.15, covariates = 3, shape_kappa = 1.72, frailty_lambda = 1.17) # Random sample generation set.seed(123) rgamma_aft(n = 5, beta0 = 4.12, beta1 = -0.15, covariates = rep(3, 5), shape_kappa = 1.72, frailty_lambda = 1.17)# Density calculation dgamma_aft(x = 10, beta0 = 4.12, beta1 = -0.15, covariates = 3, shape_kappa = 1.72, frailty_lambda = 1.17) # Cumulative distribution calculation pgamma_aft(q = 10, beta0 = 4.12, beta1 = -0.15, covariates = 3, shape_kappa = 1.72, frailty_lambda = 1.17) # Quantile calculation qgamma_aft(p = 0.5, beta0 = 4.12, beta1 = -0.15, covariates = 3, shape_kappa = 1.72, frailty_lambda = 1.17) # Random sample generation set.seed(123) rgamma_aft(n = 5, beta0 = 4.12, beta1 = -0.15, covariates = rep(3, 5), shape_kappa = 1.72, frailty_lambda = 1.17)
Evaluates the detectability and performance of the PrL, EWMA, and CUSUM control schemes
under various mean shift sizes () and censoring rates via Monte Carlo simulation
as detailed in Section 4 of Asadzadeh (2022).
spc_arl_sim( n_sim = 100, max_rl = 1000, beta0 = 4.12, beta1 = -0.15, shape_kappa = 1.72, frailty_lambda = 1.17, shifts = c(1, 0.975, 0.95, 0.9, 0.8, 0.7), censor_rate = 0, chart_type = c("cusum", "ewma", "prl"), lcl = -2.5, omega = 0.05, alpha = 0.005, seed = NULL )spc_arl_sim( n_sim = 100, max_rl = 1000, beta0 = 4.12, beta1 = -0.15, shape_kappa = 1.72, frailty_lambda = 1.17, shifts = c(1, 0.975, 0.95, 0.9, 0.8, 0.7), censor_rate = 0, chart_type = c("cusum", "ewma", "prl"), lcl = -2.5, omega = 0.05, alpha = 0.005, seed = NULL )
n_sim |
Number of simulation replicates (default 100 for fast checks, 10000 for paper-exact precision). |
max_rl |
Maximum run length cap to prevent infinite loops (default 1000). |
beta0 |
Intercept parameter |
beta1 |
Regression coefficient |
shape_kappa |
Weibull shape parameter |
frailty_lambda |
Gamma frailty parameter |
shifts |
Vector of scale parameter shift multipliers |
censor_rate |
Target right-censoring rate (0 for uncensored, 0.2, 0.5, 0.8). |
chart_type |
Control chart type to evaluate: |
lcl |
Lower control limit for the specified chart. |
omega |
Smoothing parameter for EWMA chart (default 0.05). |
alpha |
False alarm probability for PrL chart (default 0.005). |
seed |
Random seed for reproducibility. |
A data frame containing shift sizes ('upsilon_prime'), calculated 'ARL', and standard errors ('SE').
Asadzadeh, S. (2022). Statistical process control based on gamma-frailty models for heterogeneous reliability observations. *Journal of Statistical Computation and Simulation*, 92(2), 337-351. doi:10.1080/00949655.2021.1959582
# Fast demonstration with 10 simulation replicates res_cusum <- spc_arl_sim(n_sim = 10, shifts = c(1.0, 0.95), chart_type = "cusum", lcl = -2.5, seed = 123) print(res_cusum)# Fast demonstration with 10 simulation replicates res_cusum <- spc_arl_sim(n_sim = 10, shifts = c(1.0, 0.95), chart_type = "cusum", lcl = -2.5, seed = 123) print(res_cusum)
Computes the likelihood-ratio based one-sided Cumulative Sum (CUSUM) control chart
statistics for monitoring downward mean shifts under the Weibull AFT gamma frailty model
as derived in Asadzadeh (2022). Also supports competing CUSUM schemes: "iuc"
(ignoring unobserved frailty) and "iuoc" (ignoring both unobserved frailty and observed covariates).
spc_cusum( y, x, delta = NULL, fit = NULL, beta0 = NULL, beta1 = NULL, shape_kappa = NULL, frailty_lambda = NULL, upsilon = 0.95, lcl = -2.5, type = c("proposed", "iuc", "iuoc") )spc_cusum( y, x, delta = NULL, fit = NULL, beta0 = NULL, beta1 = NULL, shape_kappa = NULL, frailty_lambda = NULL, upsilon = 0.95, lcl = -2.5, type = c("proposed", "iuc", "iuoc") )
y |
Vector of observed lifetimes (or censoring thresholds). |
x |
Matrix or vector of observed covariate values. |
delta |
Vector of event indicators (1 for observed event/uncensored, 0 for right-censored). If NULL, all observations are assumed uncensored. |
fit |
Optional |
beta0 |
Intercept parameter |
beta1 |
Vector or scalar of regression coefficients |
shape_kappa |
Weibull shape parameter |
frailty_lambda |
Gamma frailty parameter |
upsilon |
Shift magnitude factor |
lcl |
Lower control limit threshold (default -2.5). |
type |
Type of CUSUM chart to compute: |
An S3 object of class 'spc_cusum' containing:
- 't_stat': CUSUM control statistics .
- 'scores': Computed score sequence .
- 'lcl': Lower control limit threshold.
- 'signals': Logical vector indicating out-of-control signals ('t_stat < lcl').
- 'signal_indices': Indices of out-of-control observations.
- 'upsilon': Shift magnitude factor .
- 'type': Type of CUSUM chart computed.
Asadzadeh, S. (2022). Statistical process control based on gamma-frailty models for heterogeneous reliability observations. *Journal of Statistical Computation and Simulation*, 92(2), 337-351. doi:10.1080/00949655.2021.1959582
set.seed(123) x_val <- rnorm(30, mean = 3, sd = 1) y_val <- rgamma_aft(n = 30, beta0 = 4.12, beta1 = -0.15, covariates = x_val, shape_kappa = 1.72, frailty_lambda = 1.17) cusum_res <- spc_cusum(y = y_val, x = x_val, beta0 = 4.12, beta1 = -0.15, shape_kappa = 1.72, frailty_lambda = 1.17, upsilon = 0.95, lcl = -2.5) print(cusum_res)set.seed(123) x_val <- rnorm(30, mean = 3, sd = 1) y_val <- rgamma_aft(n = 30, beta0 = 4.12, beta1 = -0.15, covariates = x_val, shape_kappa = 1.72, frailty_lambda = 1.17) cusum_res <- spc_cusum(y = y_val, x = x_val, beta0 = 4.12, beta1 = -0.15, shape_kappa = 1.72, frailty_lambda = 1.17, upsilon = 0.95, lcl = -2.5) print(cusum_res)
Computes exponentially weighted moving average (EWMA) control statistics with Conditional Expected Values (CEV) for right-censored observations under the Weibull AFT gamma frailty model as proposed by Asadzadeh (2022).
spc_ewma( y, x, delta = NULL, fit = NULL, beta0 = NULL, beta1 = NULL, shape_kappa = NULL, frailty_lambda = NULL, omega = 0.05, lcl = -3 )spc_ewma( y, x, delta = NULL, fit = NULL, beta0 = NULL, beta1 = NULL, shape_kappa = NULL, frailty_lambda = NULL, omega = 0.05, lcl = -3 )
y |
Vector of observed lifetimes (or censoring thresholds). |
x |
Matrix or vector of observed covariate values. |
delta |
Vector of event indicators (1 for observed event/uncensored, 0 for right-censored). If NULL, all observations are assumed uncensored. |
fit |
Optional |
beta0 |
Intercept parameter |
beta1 |
Vector or scalar of regression coefficients |
shape_kappa |
Weibull shape parameter |
frailty_lambda |
Gamma frailty parameter |
omega |
Smoothing parameter |
lcl |
Lower control limit threshold (default -3.0). |
An S3 object of class 'spc_ewma' containing:
- 'q_stat': EWMA statistics .
- 'cev': Conditional expected values for observations.
- 'y_std': Standardized variables .
- 'lcl': Lower control limit threshold.
- 'signals': Logical vector indicating out-of-control signals ('q_stat < lcl').
- 'signal_indices': Indices of out-of-control observations.
- 'omega': Smoothing parameter .
Asadzadeh, S. (2022). Statistical process control based on gamma-frailty models for heterogeneous reliability observations. *Journal of Statistical Computation and Simulation*, 92(2), 337-351. doi:10.1080/00949655.2021.1959582
set.seed(123) x_val <- rnorm(30, mean = 3, sd = 1) y_val <- rgamma_aft(n = 30, beta0 = 4.12, beta1 = -0.15, covariates = x_val, shape_kappa = 1.72, frailty_lambda = 1.17) ewma_res <- spc_ewma(y = y_val, x = x_val, beta0 = 4.12, beta1 = -0.15, shape_kappa = 1.72, frailty_lambda = 1.17, omega = 0.05, lcl = -2.5) print(ewma_res)set.seed(123) x_val <- rnorm(30, mean = 3, sd = 1) y_val <- rgamma_aft(n = 30, beta0 = 4.12, beta1 = -0.15, covariates = x_val, shape_kappa = 1.72, frailty_lambda = 1.17) ewma_res <- spc_ewma(y = y_val, x = x_val, beta0 = 4.12, beta1 = -0.15, shape_kappa = 1.72, frailty_lambda = 1.17, omega = 0.05, lcl = -2.5) print(ewma_res)
Master function for performing statistical process control (SPC) analysis on heterogeneous reliability observations using Weibull AFT Gamma Frailty models. Fits Phase I model parameters (or accepts user-provided parameters) and constructs Phase II control charts: Probability Limits (PrL), EWMA with CEV, and likelihood-based CUSUM.
spc_gamma_frailty( y, x, delta = NULL, phase1_y = NULL, phase1_x = NULL, phase1_delta = NULL, fit = NULL, beta0 = NULL, beta1 = NULL, shape_kappa = NULL, frailty_lambda = NULL, alpha = 0.005, omega = 0.05, ewma_lcl = -3, upsilon = 0.95, cusum_lcl = -2.5 )spc_gamma_frailty( y, x, delta = NULL, phase1_y = NULL, phase1_x = NULL, phase1_delta = NULL, fit = NULL, beta0 = NULL, beta1 = NULL, shape_kappa = NULL, frailty_lambda = NULL, alpha = 0.005, omega = 0.05, ewma_lcl = -3, upsilon = 0.95, cusum_lcl = -2.5 )
y |
Vector of Phase II response lifetimes. |
x |
Matrix or vector of Phase II observed covariates. |
delta |
Vector of Phase II event indicators (1 for observed event, 0 for right-censored). If NULL, all Phase II observations are assumed uncensored. |
phase1_y |
Optional Phase I historical lifetime vector for parameter estimation. |
phase1_x |
Optional Phase I covariate matrix/vector for parameter estimation. |
phase1_delta |
Optional Phase I event indicator vector for parameter estimation. |
fit |
Optional pre-fitted |
beta0 |
Intercept parameter |
beta1 |
Regression coefficients |
shape_kappa |
Weibull shape parameter |
frailty_lambda |
Gamma frailty parameter |
alpha |
False alarm rate for PrL chart (default 0.005). |
omega |
Smoothing parameter for EWMA chart (default 0.05). |
ewma_lcl |
Lower control limit for EWMA chart (default -3.0). |
upsilon |
Shift magnitude factor for CUSUM chart (default 0.95). |
cusum_lcl |
Lower control limit for CUSUM chart (default -2.5). |
An S3 object of class 'spc_gf' containing: - 'fit': Phase I model fit object ('spc_fit'). - 'prl': PrL control chart results ('spc_prl'). - 'ewma': EWMA control chart results ('spc_ewma'). - 'cusum': CUSUM control chart results ('spc_cusum'). - 'summary_stats': Data frame of per-observation statistics and signals across all charts. - 'call': The matched function call.
Asadzadeh, S. (2022). Statistical process control based on gamma-frailty models for heterogeneous reliability observations. *Journal of Statistical Computation and Simulation*, 92(2), 337-351. doi:10.1080/00949655.2021.1959582
# Generate synthetic Phase I and Phase II datasets set.seed(456) p1_x <- rnorm(100, mean = 3, sd = 1) p1_y <- rgamma_aft(n = 100, beta0 = 4.12, beta1 = -0.15, covariates = p1_x, shape_kappa = 1.72, frailty_lambda = 1.17) p1_d <- ifelse(p1_y <= 60, 1, 0) p1_y <- pmin(p1_y, 60) p2_x <- rnorm(40, mean = 3, sd = 1) p2_y <- rgamma_aft(n = 40, beta0 = 4.12, beta1 = -0.15, covariates = p2_x, shape_kappa = 1.72, frailty_lambda = 1.17) # Introduce a 10% downward shift after observation 20 p2_y[21:40] <- p2_y[21:40] * 0.90 res <- spc_gamma_frailty(y = p2_y, x = p2_x, phase1_y = p1_y, phase1_x = p1_x, phase1_delta = p1_d) print(res) summary(res) plot(res)# Generate synthetic Phase I and Phase II datasets set.seed(456) p1_x <- rnorm(100, mean = 3, sd = 1) p1_y <- rgamma_aft(n = 100, beta0 = 4.12, beta1 = -0.15, covariates = p1_x, shape_kappa = 1.72, frailty_lambda = 1.17) p1_d <- ifelse(p1_y <= 60, 1, 0) p1_y <- pmin(p1_y, 60) p2_x <- rnorm(40, mean = 3, sd = 1) p2_y <- rgamma_aft(n = 40, beta0 = 4.12, beta1 = -0.15, covariates = p2_x, shape_kappa = 1.72, frailty_lambda = 1.17) # Introduce a 10% downward shift after observation 20 p2_y[21:40] <- p2_y[21:40] * 0.90 res <- spc_gamma_frailty(y = p2_y, x = p2_x, phase1_y = p1_y, phase1_x = p1_x, phase1_delta = p1_d) print(res) summary(res) plot(res)
Estimates the parameters of the Weibull Accelerated Failure Time (AFT) model integrated with continuous gamma frailty for complete or right-censored Phase I dataset using Maximum Likelihood Estimation (MLE) as described in Asadzadeh (2022).
spc_gamma_frailty_fit(y, x, delta = NULL, init = NULL)spc_gamma_frailty_fit(y, x, delta = NULL, init = NULL)
y |
Vector of observed lifetimes (or censoring times). |
x |
Matrix, data frame, or vector of observed covariates. |
delta |
Vector of event indicators (1 for observed event/uncensored, 0 for right-censored). If NULL, all observations are assumed uncensored. |
init |
Initial parameter values for optimization ( |
An S3 object of class 'spc_fit' containing:
- 'coefficients': Estimated parameters (, , shape_kappa, frailty_lambda).
- 'se': Standard errors of parameter estimates.
- 'vcov': Variance-covariance matrix of parameter estimates.
- 'loglik': Maximum log-likelihood value.
- 'aic': Akaike Information Criterion.
- 'bic': Bayesian Information Criterion.
- 'n_obs': Total number of observations.
- 'n_events': Number of uncensored events.
- 'call': The matched function call.
Asadzadeh, S. (2022). Statistical process control based on gamma-frailty models for heterogeneous reliability observations. *Journal of Statistical Computation and Simulation*, 92(2), 337-351. doi:10.1080/00949655.2021.1959582
set.seed(123) x_val <- rnorm(100, mean = 3, sd = 1) y_val <- rgamma_aft(n = 100, beta0 = 4.12, beta1 = -0.15, covariates = x_val, shape_kappa = 1.72, frailty_lambda = 1.17) delta_val <- ifelse(y_val <= 60, 1, 0) y_obs <- pmin(y_val, 60) fit <- spc_gamma_frailty_fit(y = y_obs, x = x_val, delta = delta_val) print(fit) summary(fit)set.seed(123) x_val <- rnorm(100, mean = 3, sd = 1) y_val <- rgamma_aft(n = 100, beta0 = 4.12, beta1 = -0.15, covariates = x_val, shape_kappa = 1.72, frailty_lambda = 1.17) delta_val <- ifelse(y_val <= 60, 1, 0) y_obs <- pmin(y_val, 60) fit <- spc_gamma_frailty_fit(y = y_obs, x = x_val, delta = delta_val) print(fit) summary(fit)
Standard S3 print, summary, and plot methods for fitted models and control chart objects
generated by GammaFrailtySPC.
## S3 method for class 'spc_fit' print(x, ...) ## S3 method for class 'spc_fit' summary(object, ...) ## S3 method for class 'spc_prl' print(x, ...) ## S3 method for class 'spc_ewma' print(x, ...) ## S3 method for class 'spc_cusum' print(x, ...) ## S3 method for class 'spc_gf' print(x, ...) ## S3 method for class 'spc_gf' summary(object, ...) ## S3 method for class 'spc_gf' plot(x, ...)## S3 method for class 'spc_fit' print(x, ...) ## S3 method for class 'spc_fit' summary(object, ...) ## S3 method for class 'spc_prl' print(x, ...) ## S3 method for class 'spc_ewma' print(x, ...) ## S3 method for class 'spc_cusum' print(x, ...) ## S3 method for class 'spc_gf' print(x, ...) ## S3 method for class 'spc_gf' summary(object, ...) ## S3 method for class 'spc_gf' plot(x, ...)
x |
An object of class |
... |
Additional arguments passed to low-level functions. |
object |
An object of class |
Invisibly returns the input object x or object.
Computes the probability-limits-based control chart (PrL) statistics and lower control limits (LCL) for monitoring reliability data under the Weibull AFT gamma frailty model as derived in Asadzadeh (2022).
spc_prl( y, x, fit = NULL, beta0 = NULL, beta1 = NULL, shape_kappa = NULL, frailty_lambda = NULL, alpha = 0.005 )spc_prl( y, x, fit = NULL, beta0 = NULL, beta1 = NULL, shape_kappa = NULL, frailty_lambda = NULL, alpha = 0.005 )
y |
Vector of Phase II response quality observations (lifetimes). |
x |
Matrix or vector of observed covariate values. |
fit |
Optional |
beta0 |
Intercept parameter |
beta1 |
Vector or scalar of regression coefficients |
shape_kappa |
Weibull shape parameter |
frailty_lambda |
Gamma frailty parameter |
alpha |
Desired false alarm probability (default 0.005). |
An S3 object of class 'spc_prl' containing:
- 'y': Observed lifetime values.
- 'lcl': Computed lower control limit values .
- 'signals': Logical vector indicating out-of-control signals ('y < lcl').
- 'signal_indices': Indices of out-of-control observations.
- 'alpha': Specified false alarm probability.
Asadzadeh, S. (2022). Statistical process control based on gamma-frailty models for heterogeneous reliability observations. *Journal of Statistical Computation and Simulation*, 92(2), 337-351. doi:10.1080/00949655.2021.1959582
set.seed(123) x_val <- rnorm(30, mean = 3, sd = 1) y_val <- rgamma_aft(n = 30, beta0 = 4.12, beta1 = -0.15, covariates = x_val, shape_kappa = 1.72, frailty_lambda = 1.17) prl_res <- spc_prl(y = y_val, x = x_val, beta0 = 4.12, beta1 = -0.15, shape_kappa = 1.72, frailty_lambda = 1.17, alpha = 0.005) print(prl_res)set.seed(123) x_val <- rnorm(30, mean = 3, sd = 1) y_val <- rgamma_aft(n = 30, beta0 = 4.12, beta1 = -0.15, covariates = x_val, shape_kappa = 1.72, frailty_lambda = 1.17) prl_res <- spc_prl(y = y_val, x = x_val, beta0 = 4.12, beta1 = -0.15, shape_kappa = 1.72, frailty_lambda = 1.17, alpha = 0.005) print(prl_res)
Data from a textile company in Kashan, Iran, analyzing thread tensile strength (response lifetime $Y$, in cN) as a function of the proportion of polyester to wool ratio (observed covariate $X$) under unobserved fiber maturity (gamma frailty), as presented in Section 5 of Asadzadeh (2022).
textile_datatextile_data
A data frame with 150 rows and 4 variables:
Thread tensile strength endurance lifetime (in cN).
Proportion of polyester to wool ratio (observed covariate).
Censoring indicator (1 = uncensored event, 0 = right-censored observation).
Phase indicator ("PhaseI" for the first 100 observations used for parameter estimation, and "PhaseII" for the subsequent 50 observations monitored for process shifts).
Asadzadeh, S. (2022). Statistical process control based on gamma-frailty models for heterogeneous reliability observations. *Journal of Statistical Computation and Simulation*, 92(2), 337-351. doi:10.1080/00949655.2021.1959582
data(textile_data) head(textile_data) summary(textile_data)data(textile_data) head(textile_data) summary(textile_data)