| Title: | Random Forest Regression with Power Xgamma Distribution Error Model |
|---|---|
| Description: | Implements Random Forest regression under the Power Xgamma distribution error model. Provides core distribution functions (density, cumulative distribution, quantile, random generation, hazard, survival), parameter estimation via Expectation-Maximization (EM) and Markov Chain Monte Carlo (MCMC), non-parametric bootstrap confidence intervals (at 90%, 95%, and 99% levels), Highest Posterior Density (HPD) intervals, Heidelberger and Welch's MCMC convergence diagnostic, convergence probability, model evaluation metrics (estimated values, bias, mean squared error, risk value), homoscedastic prediction intervals, and goodness-of-fit diagnostic tests (Kolmogorov-Smirnov and Anderson-Darling tests, Akaike Information Criterion, and Bayesian Information Criterion). References: Tyagi et al. (2022, Int. J. Stat. Reliab. Eng., 9(1), 51-60); Breiman (2001) <doi:10.1023/A:1010933404324>; Wright and Ziegler (2017) <doi:10.18637/jss.v077.i01>; Heidelberger and Welch (1983) <doi:10.1287/opre.31.6.1109>; Sen et al. (2016) <doi:10.22237/jmasm/1462076400>. |
| Authors: | Shikhar Tyagi [aut, cre] (ORCID: <https://orcid.org/0000-0003-1606-0844>), Aruna Rajballie [aut], Vrijesh Tripathi [aut] |
| Maintainer: | Shikhar Tyagi <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.0 |
| Built: | 2026-09-21 09:42:00 UTC |
| Source: | https://github.com/cran/PowerXgammaRF |
Evaluates model goodness-of-fit using the Kolmogorov-Smirnov and Anderson-Darling tests, computes Information Criteria (AIC, BIC), and formats summary and diagnostic graphics.
ks_powerxgamma(r, eta, zeta) ad_powerxgamma(r, eta, zeta) ## S3 method for class 'rf_powerxgamma' print(x, ...) ## S3 method for class 'rf_powerxgamma' summary(object, ...) ## S3 method for class 'summary.rf_powerxgamma' print(x, ...) ## S3 method for class 'rf_powerxgamma' plot(x, which = c(1, 2), ...)ks_powerxgamma(r, eta, zeta) ad_powerxgamma(r, eta, zeta) ## S3 method for class 'rf_powerxgamma' print(x, ...) ## S3 method for class 'rf_powerxgamma' summary(object, ...) ## S3 method for class 'summary.rf_powerxgamma' print(x, ...) ## S3 method for class 'rf_powerxgamma' plot(x, which = c(1, 2), ...)
r |
Vector of absolute residuals. |
eta |
Scale parameter |
zeta |
Shape/power parameter |
x, object
|
Object of class |
... |
Additional graphical or formatting parameters. |
which |
Integer vector indicating which plots to produce: |
Goodness-of-fit for the Power Xgamma distribution on absolute residuals is evaluated using the Kolmogorov-Smirnov test (ks.test) and the tail-sensitive Anderson-Darling test (ad.test).
Information criteria are defined as and , where for the Power Xgamma parameters .
Missing Values Handling:
Missing values (NA, NaN) in input residuals r are omitted automatically.
ks_powerxgammaReturns an object of class "htest" containing Kolmogorov-Smirnov test statistic and associated p-value.
ad_powerxgammaReturns an object of class "htest" containing Anderson-Darling test statistic and associated p-value.
summary.rf_powerxgammaReturns an object of class "summary.rf_powerxgamma" summarizing model performance, distribution parameters, bootstrap or HPD intervals, Heidelberger-Welch convergence diagnostics, and goodness-of-fit statistics.
Anderson, T. W., & Darling, D. A. (1954). A test of goodness of fit. Journal of the American Statistical Association, 49(268), 765–769. <doi:10.1080/01621459.1954.10501232>
Tyagi, S., Kumar, S., Pandey, A., Saha, S., & Bagariya, H. (2022). Power xgamma distribution: properties and its applications to cancer data. International Journal of Statistics and Reliability Engineering, 9(1), 51–60.
set.seed(123) r_sample <- rpowerxgamma(50, eta = 0.5, zeta = 1.2) ks_res <- ks_powerxgamma(r_sample, eta = 0.5, zeta = 1.2) print(ks_res)set.seed(123) r_sample <- rpowerxgamma(50, eta = 0.5, zeta = 1.2) ks_res <- ks_powerxgamma(r_sample, eta = 0.5, zeta = 1.2) print(ks_res)
Estimates the Power Xgamma distribution parameters eta and zeta using Markov Chain Monte Carlo (MCMC) sampling, and computes Highest Posterior Density (HPD) intervals at 90
mcmc_pxg( r, n_iter = 5000, burn_in = NULL, thin = 2, init_par = NULL, seed = NULL )mcmc_pxg( r, n_iter = 5000, burn_in = NULL, thin = 2, init_par = NULL, seed = NULL )
r |
Vector of absolute residuals. |
n_iter |
Total number of MCMC iterations (default |
burn_in |
Number of initial burn-in iterations to discard. If |
thin |
Thinning interval for posterior chain (default |
init_par |
Initial parameter vector |
seed |
Optional random seed for reproducible sampling. |
MCMC sampling is performed using an adaptive Metropolis-Hastings algorithm on the log-scale of and () to ensure strict positivity and numerical stability.
Weakly informative priors are placed on and .
Convergence Diagnostics & Uncertainty Quantification:
HPD Intervals: Computed using HPDinterval at 90
Heidelberger and Welch's Diagnostic: Evaluated using heidel.diag to assess stationarity and calculate relative half-width accuracy.
Convergence Probability: Computed as the average Cramer-von Mises stationarity test p-value across parameter chains.
Missing Values Handling:
Missing values (NA, NaN) in input residuals r are omitted automatically.
A list containing:
Posterior mean estimates of and .
Posterior median estimates of and .
Highest Posterior Density intervals at 90% level.
Highest Posterior Density intervals at 95% level.
Highest Posterior Density intervals at 99% level.
Heidelberger and Welch's diagnostic output from heidel.diag.
Named binary vector indicating whether stationarity test was passed (1 = passed, 0 = failed).
p-values for Cramer-von Mises stationarity test.
Named binary vector indicating whether half-width test was passed (1 = passed, 0 = failed).
Average convergence probability across parameter chains.
Empirical acceptance rate of the Metropolis-Hastings sampler.
mcmc object of retained posterior samples.
Heidelberger, P., & Welch, P. D. (1983). Simulation run length control in the presence of an initial transient. Operations Research, 31(6), 1109–1144. <doi:10.1287/opre.31.6.1109>
Tyagi, S., Kumar, S., Pandey, A., Saha, S., & Bagariya, H. (2022). Power xgamma distribution: properties and its applications to cancer data. International Journal of Statistics and Reliability Engineering, 9(1), 51–60.
set.seed(123) r_sample <- rpowerxgamma(50, eta = 0.5, zeta = 1.2) mcmc_fit <- mcmc_pxg(r_sample, n_iter = 1000, burn_in = 200) print(mcmc_fit$posterior_mean) print(mcmc_fit$hpd_95) print(mcmc_fit$convergence_probability)set.seed(123) r_sample <- rpowerxgamma(50, eta = 0.5, zeta = 1.2) mcmc_fit <- mcmc_pxg(r_sample, n_iter = 1000, burn_in = 200) print(mcmc_fit$posterior_mean) print(mcmc_fit$hpd_95) print(mcmc_fit$convergence_probability)
Computes Maximum Likelihood Estimates (MLE) / Expectation-Maximization (EM) point estimates for the Power Xgamma distribution parameters eta and zeta, and nonparametric bootstrap confidence intervals.
pxg_mle(r, tol = 1e-09, max_iter = 1000) bootstrap_ci( y, X, n_boot = 100, conf_levels = c(0.9, 0.95, 0.99), num.trees = 100, seed = NULL )pxg_mle(r, tol = 1e-09, max_iter = 1000) bootstrap_ci( y, X, n_boot = 100, conf_levels = c(0.9, 0.95, 0.99), num.trees = 100, seed = NULL )
r |
Vector of non-negative absolute residuals. |
tol |
Numerical tolerance for optimization convergence (default |
max_iter |
Maximum number of optimization iterations (default |
y |
Response vector for bootstrap estimation. |
X |
Predictor matrix or data frame. |
n_boot |
Number of bootstrap samples (default |
conf_levels |
Vector of nominal confidence levels (default |
num.trees |
Number of trees for ranger in bootstrap fits (default |
seed |
Optional random seed for reproducibility. |
Given absolute residuals , the concentrated log-likelihood for is:
Bootstrap Resampling: Under the EM/MLE framework, non-parametric bootstrap resampling is utilized to construct empirical confidence intervals at 90
Missing Values Handling:
Missing values (NA, NaN) in input residuals r are omitted automatically using na.omit. Non-positive values are bounded away from zero by .Machine$double.eps to maintain numerical stability.
pxg_mleReturns a named numeric vector of length 2 containing the MLE estimates for eta and zeta.
bootstrap_ciReturns a list containing:
eta_ciMatrix of lower and upper bounds for eta at 90%, 95%, and 99% confidence levels.
zeta_ciMatrix of lower and upper bounds for zeta at 90%, 95%, and 99% confidence levels.
mse_ciMatrix of lower and upper bounds for MSE at 90%, 95%, and 99% confidence levels.
bias_ciMatrix of lower and upper bounds for model bias at 90%, 95%, and 99% confidence levels.
risk_ciMatrix of lower and upper bounds for empirical risk at 90%, 95%, and 99% confidence levels.
boot_etaNumeric vector of bootstrap estimates for eta.
boot_zetaNumeric vector of bootstrap estimates for zeta.
boot_mseNumeric vector of bootstrap estimates for MSE.
boot_biasNumeric vector of bootstrap estimates for bias.
boot_riskNumeric vector of bootstrap estimates for empirical risk.
Tyagi, S., Kumar, S., Pandey, A., Saha, S., & Bagariya, H. (2022). Power xgamma distribution: properties and its applications to cancer data. International Journal of Statistics and Reliability Engineering, 9(1), 51–60.
set.seed(123) r_sample <- rpowerxgamma(50, eta = 0.5, zeta = 1.2) est_pars <- pxg_mle(r_sample) print(est_pars)set.seed(123) r_sample <- rpowerxgamma(50, eta = 0.5, zeta = 1.2) est_pars <- pxg_mle(r_sample) print(est_pars)
Density, distribution function, quantile function, random generation, hazard function, and survival function for the Power Xgamma distribution with scale parameter eta and shape/power parameter zeta.
dpowerxgamma(x, eta, zeta, log = FALSE) dpxg(x, eta, zeta, log = FALSE) ppowerxgamma(q, eta, zeta, lower.tail = TRUE, log.p = FALSE) ppxg(q, eta, zeta, lower.tail = TRUE, log.p = FALSE) qpowerxgamma(p, eta, zeta, lower.tail = TRUE, log.p = FALSE) qpxg(p, eta, zeta, lower.tail = TRUE, log.p = FALSE) rpowerxgamma(n, eta, zeta) rpxg(n, eta, zeta) hpowerxgamma(x, eta, zeta) hpxg(x, eta, zeta) spowerxgamma(x, eta, zeta) spxg(x, eta, zeta)dpowerxgamma(x, eta, zeta, log = FALSE) dpxg(x, eta, zeta, log = FALSE) ppowerxgamma(q, eta, zeta, lower.tail = TRUE, log.p = FALSE) ppxg(q, eta, zeta, lower.tail = TRUE, log.p = FALSE) qpowerxgamma(p, eta, zeta, lower.tail = TRUE, log.p = FALSE) qpxg(p, eta, zeta, lower.tail = TRUE, log.p = FALSE) rpowerxgamma(n, eta, zeta) rpxg(n, eta, zeta) hpowerxgamma(x, eta, zeta) hpxg(x, eta, zeta) spowerxgamma(x, eta, zeta) spxg(x, eta, zeta)
x, q
|
Vector of quantiles. |
eta |
Scale parameter ( |
zeta |
Shape/power parameter ( |
log, log.p
|
Logical or character string ( |
lower.tail |
Logical or character string ( |
p |
Vector of probabilities. |
n |
Number of observations. If |
The Power Xgamma distribution is a flexible continuous lifetime distribution defined on with scale parameter and shape/power parameter (Tyagi et al., 2022).
Mathematical Formulation:
Probability Density Function (PDF):
Cumulative Distribution Function (CDF):
Survival Function:
Hazard Rate Function:
Handling of Missing and Non-Positive Values:
Missing values (NA, NaN) in x, q, or p are preserved and return NA_real_.
Values where x < 0 or q < 0 return 0 for density and CDF without producing warnings.
Values where p < 0 return 0 and p > 1 return Inf in quantile functions.
Boolean Parsing:
Boolean parameters (log, log.p, lower.tail) accept standard logical values (TRUE / FALSE) or character string representations ("TRUE" / "FALSE", "T" / "F").
dpowerxgamma (and dpxg)Returns a numeric vector of probability density values.
ppowerxgamma (and ppxg)Returns a numeric vector of cumulative probabilities.
qpowerxgamma (and qpxg)Returns a numeric vector of quantiles.
rpowerxgamma (and rpxg)Returns a numeric vector of n random deviates from the Power Xgamma distribution.
hpowerxgamma (and hpxg)Returns a numeric vector of hazard rate values.
spowerxgamma (and spxg)Returns a numeric vector of survival probabilities.
Tyagi, S., Kumar, S., Pandey, A., Saha, S., & Bagariya, H. (2022). Power xgamma distribution: properties and its applications to cancer data. International Journal of Statistics and Reliability Engineering, 9(1), 51–60.
Sen, S., Maiti, S. S., & Chandra, N. (2016). The xgamma distribution: statistical properties and application. Journal of Modern Applied Statistical Methods, 15(1), 774–788. <doi:10.22237/jmasm/1462076400>
# PDF, CDF, Survival, and Hazard evaluations dpowerxgamma(1.5, eta = 0.5, zeta = 1.2) ppowerxgamma(1.5, eta = 0.5, zeta = 1.2) spowerxgamma(1.5, eta = 0.5, zeta = 1.2) hpowerxgamma(1.5, eta = 0.5, zeta = 1.2) # Quantiles qpowerxgamma(c(0.90, 0.95, 0.99), eta = 0.5, zeta = 1.2) # Random variate generation set.seed(123) r_samples <- rpowerxgamma(10, eta = 0.5, zeta = 1.2) print(r_samples) # Using character string booleans dpowerxgamma(1.5, eta = 0.5, zeta = 1.2, log = "TRUE") ppowerxgamma(1.5, eta = 0.5, zeta = 1.2, lower.tail = "FALSE")# PDF, CDF, Survival, and Hazard evaluations dpowerxgamma(1.5, eta = 0.5, zeta = 1.2) ppowerxgamma(1.5, eta = 0.5, zeta = 1.2) spowerxgamma(1.5, eta = 0.5, zeta = 1.2) hpowerxgamma(1.5, eta = 0.5, zeta = 1.2) # Quantiles qpowerxgamma(c(0.90, 0.95, 0.99), eta = 0.5, zeta = 1.2) # Random variate generation set.seed(123) r_samples <- rpowerxgamma(10, eta = 0.5, zeta = 1.2) print(r_samples) # Using character string booleans dpowerxgamma(1.5, eta = 0.5, zeta = 1.2, log = "TRUE") ppowerxgamma(1.5, eta = 0.5, zeta = 1.2, lower.tail = "FALSE")
Generates point predictions and calibrated homoscedastic prediction intervals at specified significance levels (90
## S3 method for class 'rf_powerxgamma' predict(object, newdata = NULL, conf_levels = c(0.9, 0.95, 0.99), ...)## S3 method for class 'rf_powerxgamma' predict(object, newdata = NULL, conf_levels = c(0.9, 0.95, 0.99), ...)
object |
Fitted object of class |
newdata |
Data frame of new observations for prediction. If omitted, predictions for the training data are returned. |
conf_levels |
Vector of nominal confidence levels (default |
... |
Additional arguments passed to |
For an unobserved response , the Random Forest ensemble produces point prediction .
Under the Power Xgamma error distribution , the exact prediction interval is:
where is the -th quantile of the Power Xgamma distribution.
Missing Values Handling:
If newdata contains missing values in predictor columns, behavior is governed by the underlying ranger prediction mechanism.
A data frame containing:
Numeric vector of point predictions .
Lower and upper bounds for 90% prediction intervals.
Lower and upper bounds for 95% prediction intervals.
Lower and upper bounds for 99% prediction intervals.
Tyagi, S., Kumar, S., Pandey, A., Saha, S., & Bagariya, H. (2022). Power xgamma distribution: properties and its applications to cancer data. International Journal of Statistics and Reliability Engineering, 9(1), 51–60.
set.seed(123) train_dat <- data.frame( x1 = stats::rnorm(50), x2 = stats::runif(50), y = stats::rnorm(50, mean = 10, sd = 2) ) test_dat <- data.frame( x1 = stats::rnorm(10), x2 = stats::runif(10) ) fit <- rf_powerxgamma(y ~ x1 + x2, data = train_dat, method = "em", num.trees = 50, n_boot = 10) preds <- predict(fit, newdata = test_dat, conf_levels = c(0.90, 0.95, 0.99)) print(preds)set.seed(123) train_dat <- data.frame( x1 = stats::rnorm(50), x2 = stats::runif(50), y = stats::rnorm(50, mean = 10, sd = 2) ) test_dat <- data.frame( x1 = stats::rnorm(10), x2 = stats::runif(10) ) fit <- rf_powerxgamma(y ~ x1 + x2, data = train_dat, method = "em", num.trees = 50, n_boot = 10) preds <- predict(fit, newdata = test_dat, conf_levels = c(0.90, 0.95, 0.99)) print(preds)
Fits a Random Forest regression model and models the absolute residuals using the Power Xgamma distribution. Supports Expectation-Maximization (EM) / Maximum Likelihood Estimation with non-parametric bootstrap confidence intervals, and Bayesian Markov Chain Monte Carlo (MCMC) inference with Highest Posterior Density (HPD) intervals and Heidelberger-Welch convergence diagnostics.
rf_powerxgamma( formula, data, method = c("em", "mcmc"), num.trees = 500, n_boot = 100, n_iter = 5000, burn_in = NULL, thin = 2, conf_levels = c(0.9, 0.95, 0.99), na.action = stats::na.omit, seed = NULL, ... )rf_powerxgamma( formula, data, method = c("em", "mcmc"), num.trees = 500, n_boot = 100, n_iter = 5000, burn_in = NULL, thin = 2, conf_levels = c(0.9, 0.95, 0.99), na.action = stats::na.omit, seed = NULL, ... )
formula |
Object of class |
data |
Data frame containing response and explanatory variables. |
method |
Estimation method: |
num.trees |
Number of trees to grow in the Random Forest ensemble (default |
n_boot |
Number of bootstrap iterations for confidence intervals when |
n_iter |
Number of MCMC iterations when |
burn_in |
Number of MCMC burn-in iterations when |
thin |
MCMC thinning rate (default |
conf_levels |
Vector of nominal confidence levels (default |
na.action |
Function specifying how to handle missing values (default |
seed |
Optional random seed for reproducible results. |
... |
Additional arguments passed to |
The model is formulated in two stages:
Stage 1 (Random Forest Non-Parametric Fitting): The regression surface is estimated non-parametrically using a Random Forest ensemble (ranger).
Stage 2 (Power Xgamma Error Modeling): Absolute residuals are modeled under the Power Xgamma distribution .
Estimation Methods:
EM / MLE Method (method = "em"): Estimates and by maximizing the concentrated log-likelihood. Non-parametric bootstrap resampling is performed to calculate empirical confidence intervals for parameter estimates, model bias, MSE, and risk at 90
Bayesian MCMC Method (method = "mcmc"): Performs adaptive Metropolis-Hastings posterior sampling, extracting HPD intervals at 90
Missing Values Handling:
Handled using na.action (default na.omit). Rows containing missing values in predictor variables or the response are omitted prior to model training.
An object of class "rf_powerxgamma" containing:
Fitted response predictions .
Model residuals .
Absolute residuals .
Estimated scale parameter .
Estimated shape/power parameter .
Empirical model bias .
Mean squared error .
Root mean squared error.
Mean absolute error.
Empirical risk value under squared error loss.
Vector of confidence levels evaluated (90%, 95%, 99%).
Selected estimation method ("em" or "mcmc").
Bootstrap estimation and confidence interval results (when method = "em").
MCMC posterior results, HPD intervals, and Heidelberger-Welch convergence diagnostics (when method = "mcmc").
Underlying ranger regression model object.
Terms object from the model formula.
Matched function call.
Breiman, L. (2001). Random forests. Machine Learning, 45(1), 5–32. <doi:10.1023/A:1010933404324>
Heidelberger, P., & Welch, P. D. (1983). Simulation run length control in the presence of an initial transient. Operations Research, 31(6), 1109–1144. <doi:10.1287/opre.31.6.1109>
Tyagi, S., Kumar, S., Pandey, A., Saha, S., & Bagariya, H. (2022). Power xgamma distribution: properties and its applications to cancer data. International Journal of Statistics and Reliability Engineering, 9(1), 51–60.
Wright, M. N., & Ziegler, A. (2017). ranger: A fast implementation of random forests for high dimensional data in C++ and R. Journal of Statistical Software, 77(1), 1–17. <doi:10.18637/jss.v077.i01>
set.seed(123) dat <- data.frame( x1 = stats::rnorm(60), x2 = stats::runif(60), y = stats::rnorm(60, mean = 10, sd = 2) ) # Fit model using EM/MLE method with bootstrap CIs fit_em <- rf_powerxgamma(y ~ x1 + x2, data = dat, method = "em", num.trees = 50, n_boot = 20) summary(fit_em) # Fit model using Bayesian MCMC method with HPD intervals fit_mcmc <- rf_powerxgamma(y ~ x1 + x2, data = dat, method = "mcmc", num.trees = 50, n_iter = 500) summary(fit_mcmc)set.seed(123) dat <- data.frame( x1 = stats::rnorm(60), x2 = stats::runif(60), y = stats::rnorm(60, mean = 10, sd = 2) ) # Fit model using EM/MLE method with bootstrap CIs fit_em <- rf_powerxgamma(y ~ x1 + x2, data = dat, method = "em", num.trees = 50, n_boot = 20) summary(fit_em) # Fit model using Bayesian MCMC method with HPD intervals fit_mcmc <- rf_powerxgamma(y ~ x1 + x2, data = dat, method = "mcmc", num.trees = 50, n_iter = 500) summary(fit_mcmc)