| Title: | Random Forest Regression with Arvind Distribution Error Model |
|---|---|
| Description: | Implements Random Forest regression under the Arvind 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, 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: Breiman (2001) <doi:10.1023/A:1010933404324>; Wright and Ziegler (2017) <doi:10.18637/jss.v077.i01>. |
| 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:40:05 UTC |
| Source: | https://github.com/cran/ArvindRF |
Density, distribution function, quantile function, random generation, hazard function, and survival function for the Arvind distribution with parameter theta.
darvind(x, theta, log = FALSE) parvind(q, theta, lower.tail = TRUE, log.p = FALSE) qarvind(p, theta, lower.tail = TRUE, log.p = FALSE) rarvind(n, theta) harvind(x, theta) sarvind(x, theta)darvind(x, theta, log = FALSE) parvind(q, theta, lower.tail = TRUE, log.p = FALSE) qarvind(p, theta, lower.tail = TRUE, log.p = FALSE) rarvind(n, theta) harvind(x, theta) sarvind(x, theta)
x, q
|
Vector of quantiles. |
theta |
Scale parameter ( |
log, log.p
|
Logical or character string indicating boolean evaluation ( |
lower.tail |
Logical or character string indicating boolean evaluation. If |
p |
Vector of probabilities. |
n |
Number of observations. If |
The Arvind distribution is a continuous distribution on with scale parameter .
Its probability density function (PDF) is given by:
Its cumulative distribution function (CDF) is:
Its survival function is:
Its hazard function is:
Quantiles are calculated using root-finding via uniroot, and random values are generated via inversion sampling.
darvind gives the density, parvind gives the distribution function, qarvind gives the quantile function, rarvind generates random deviates, harvind gives the hazard function, and sarvind gives the survival function.
# Evaluate PDF and CDF at x = 1, theta = 0.5 darvind(1, theta = 0.5) parvind(1, theta = 0.5) # Quantile function qarvind(0.95, theta = 0.5) # Survival and hazard functions sarvind(1, theta = 0.5) harvind(1, theta = 0.5) # Generate random samples set.seed(123) r_samples <- rarvind(10, theta = 0.5) print(r_samples)# Evaluate PDF and CDF at x = 1, theta = 0.5 darvind(1, theta = 0.5) parvind(1, theta = 0.5) # Quantile function qarvind(0.95, theta = 0.5) # Survival and hazard functions sarvind(1, theta = 0.5) harvind(1, theta = 0.5) # Generate random samples set.seed(123) r_samples <- rarvind(10, theta = 0.5) print(r_samples)
Evaluates Kolmogorov-Smirnov (KS) and Anderson-Darling (AD) goodness-of-fit diagnostic tests, information-theoretic criteria (AIC, BIC), and provides summary, print, and plot methods for rf_arvind objects.
ks_arvind(r, theta) ad_arvind(r, theta) ## S3 method for class 'rf_arvind' print(x, ...) ## S3 method for class 'rf_arvind' summary(object, ...) ## S3 method for class 'summary.rf_arvind' print(x, ...) ## S3 method for class 'rf_arvind' plot(x, ...)ks_arvind(r, theta) ad_arvind(r, theta) ## S3 method for class 'rf_arvind' print(x, ...) ## S3 method for class 'rf_arvind' summary(object, ...) ## S3 method for class 'summary.rf_arvind' print(x, ...) ## S3 method for class 'rf_arvind' plot(x, ...)
r |
Vector of absolute residuals. |
theta |
Estimated Arvind distribution parameter |
... |
Additional arguments passed to default methods. |
object, x
|
Object of class |
Goodness-of-fit of absolute residuals to the Arvind distribution is evaluated via:
Kolmogorov-Smirnov Test: Compares empirical CDF against Arvind CDF .
Anderson-Darling Test: Evaluates tail-weighted goodness-of-fit using ad.test.
AIC and BIC: Calculated as and with parameter count .
For ks_arvind and ad_arvind, a list containing test statistics and p-values.
For summary.rf_arvind, a summary list object printed cleanly.
For plot.rf_arvind, produces diagnostic plots.
set.seed(123) df <- data.frame( y = 5 + 2 * rnorm(50), x1 = rnorm(50), x2 = runif(50) ) fit <- rf_arvind(y ~ x1 + x2, data = df, num.trees = 50) summary(fit) plot(fit)set.seed(123) df <- data.frame( y = 5 + 2 * rnorm(50), x1 = rnorm(50), x2 = runif(50) ) fit <- rf_arvind(y ~ x1 + x2, data = df, num.trees = 50) summary(fit) plot(fit)
Estimates the Arvind distribution parameter theta using Markov Chain Monte Carlo (MCMC) sampling, and computes Highest Posterior Density (HPD) intervals at 90
mcmc_arvind( r, n_iter = 5000, burn_in = 1000, thin = 2, init_theta = NULL, seed = NULL )mcmc_arvind( r, n_iter = 5000, burn_in = 1000, thin = 2, init_theta = 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 (default |
thin |
Thinning interval for posterior chain (default |
init_theta |
Initial value for |
seed |
Optional random seed. |
MCMC sampling is performed using an adaptive Metropolis-Hastings algorithm on the log-scale of () to ensure positivity and numerical stability.
A weakly informative Gamma(0.001, 0.001) prior is placed on .
The posterior chain is analyzed using HPDinterval to extract HPD intervals at 90
A list containing:
Posterior mean estimate of .
Posterior median estimate of .
Highest Posterior Density interval at 90% level.
Highest Posterior Density interval at 95% level.
Highest Posterior Density interval at 99% level.
Acceptance rate of the MCMC sampler.
mcmc object of posterior samples.
set.seed(123) r_sample <- rarvind(50, theta = 0.5) mcmc_fit <- mcmc_arvind(r_sample, n_iter = 2000, burn_in = 500) print(mcmc_fit$posterior_mean) print(mcmc_fit$hpd_95)set.seed(123) r_sample <- rarvind(50, theta = 0.5) mcmc_fit <- mcmc_arvind(r_sample, n_iter = 2000, burn_in = 500) print(mcmc_fit$posterior_mean) print(mcmc_fit$hpd_95)
Functions to compute the Maximum Likelihood Estimate (MLE) / Expectation-Maximization (EM) point estimate for the Arvind distribution parameter theta, and nonparametric bootstrap confidence intervals.
arvind_mle(r, tol = 1e-09, max_iter = 100) bootstrap_ci( y, X, n_boot = 100, conf_levels = c(0.9, 0.95, 0.99), num.trees = 100, seed = NULL )arvind_mle(r, tol = 1e-09, max_iter = 100) 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 convergence (default |
max_iter |
Maximum number of 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 confidence levels (default |
num.trees |
Number of trees for ranger in bootstrap fits (default |
seed |
Optional random seed. |
The score equation for given absolute residuals is:
This equation is solved iteratively using Newton-Raphson / EM optimization. Under the EM/MLE method, confidence intervals for parameters and performance metrics (bias, MSE, risk) are obtained using non-parametric bootstrap resampling at 90
For arvind_mle, a single scalar estimate of .
For bootstrap_ci, a list containing point estimates, bootstrap samples, and lower/upper bounds for confidence intervals at the specified confidence levels (90
set.seed(123) r_sample <- rarvind(50, theta = 0.5) est_theta <- arvind_mle(r_sample) print(est_theta)set.seed(123) r_sample <- rarvind(50, theta = 0.5) est_theta <- arvind_mle(r_sample) print(est_theta)
Obtains point predictions and homoscedastic prediction intervals (at 90
## S3 method for class 'rf_arvind' predict(object, newdata = NULL, conf_levels = c(0.9, 0.95, 0.99), ...)## S3 method for class 'rf_arvind' predict(object, newdata = NULL, conf_levels = c(0.9, 0.95, 0.99), ...)
object |
Object of class |
newdata |
Data frame of new predictor observations. If omitted, fitted training values are used. |
conf_levels |
Vector of confidence levels for prediction intervals (default |
... |
Additional arguments passed to |
Under the Arvind error distribution, the prediction interval for a new response at predictor is given by:
where is the -th quantile of the Arvind distribution computed via qarvind.
A data frame containing:
fit |
Point predictions |
Columns for lower and upper prediction interval bounds for each requested level (e.g. PI_90_Lower, PI_90_Upper, PI_95_Lower, PI_95_Upper, PI_99_Lower, PI_99_Upper).
set.seed(123) df <- data.frame( y = 5 + 2 * rnorm(50), x1 = rnorm(50), x2 = runif(50) ) fit <- rf_arvind(y ~ x1 + x2, data = df, num.trees = 50) preds <- predict(fit, newdata = df[1:5, ]) print(preds)set.seed(123) df <- data.frame( y = 5 + 2 * rnorm(50), x1 = rnorm(50), x2 = runif(50) ) fit <- rf_arvind(y ~ x1 + x2, data = df, num.trees = 50) preds <- predict(fit, newdata = df[1:5, ]) print(preds)
Fits a Random Forest regression model combined with an Arvind distribution error model. Supports parameter estimation via EM algorithm (with bootstrap confidence intervals at 90
rf_arvind( formula, data, method = c("em", "mcmc"), num.trees = 500, n_boot = 100, n_iter = 5000, burn_in = 1000, conf_levels = c(0.9, 0.95, 0.99), na.action = stats::na.omit, seed = NULL, ... )rf_arvind( formula, data, method = c("em", "mcmc"), num.trees = 500, n_boot = 100, n_iter = 5000, burn_in = 1000, conf_levels = c(0.9, 0.95, 0.99), na.action = stats::na.omit, seed = NULL, ... )
formula |
Object of class |
data |
Data frame containing the variables in the model. |
method |
Estimation method: |
num.trees |
Number of trees in the Random Forest ensemble (default |
n_boot |
Number of bootstrap iterations for EM confidence intervals (default |
n_iter |
Number of MCMC iterations for Bayesian estimation (default |
burn_in |
Number of burn-in MCMC iterations (default |
conf_levels |
Confidence levels for intervals (default |
na.action |
Function specifying action for missing values (default |
seed |
Optional integer seed for reproducibility. |
... |
Additional arguments passed to |
The RF-Arvind regression model assumes:
where is estimated by a Random Forest predictor, and absolute errors follow the Arvind distribution with scale parameter .
In Stage 1, Random Forest regression is fitted using ranger under the mean squared error criterion to predict point estimates .
In Stage 2, absolute residuals are modeled using the Arvind error distribution.
Parameter estimation can be performed via:
EM Algorithm (method = "em"): Computes maximum likelihood point estimate and uses non-parametric bootstrap resampling to evaluate confidence intervals at 90
Bayesian MCMC (method = "mcmc"): Draws MCMC posterior samples for via adaptive Metropolis-Hastings and computes Highest Posterior Density (HPD) intervals at 90
Missing values are processed according to the specified na.action. Logical parameters accept both standard R boolean flags (TRUE/FALSE) and character representations ("TRUE"/"FALSE").
An S3 object of class "rf_arvind", containing:
The fitted ranger Random Forest object.
Estimated Arvind scale parameter .
Estimation method used ("em" or "mcmc").
Fitted point predictions .
Raw residuals .
Absolute residuals .
Estimated model bias.
Mean squared error.
Root mean squared error.
Mean absolute error.
Model risk value (empirical squared loss).
Bootstrap confidence intervals (for EM) or HPD intervals (for MCMC) at 90%, 95%, and 99% levels.
Detailed bootstrap outputs if method = "em".
Detailed MCMC sampler outputs if method = "mcmc".
Model formula.
Processed training data frame.
Name of response variable.
Vector of predictor variable names.
# Fit RF-Arvind model on synthetic regression data set.seed(123) df <- data.frame( y = 5 + 2 * rnorm(50), x1 = rnorm(50), x2 = runif(50) ) fit_em <- rf_arvind(y ~ x1 + x2, data = df, method = "em", num.trees = 50, n_boot = 30, seed = 123) print(fit_em)# Fit RF-Arvind model on synthetic regression data set.seed(123) df <- data.frame( y = 5 + 2 * rnorm(50), x1 = rnorm(50), x2 = runif(50) ) fit_em <- rf_arvind(y ~ x1 + x2, data = df, method = "em", num.trees = 50, n_boot = 30, seed = 123) print(fit_em)