Computational Provenance & Reproducibility Record

RAISINS - R and AI Solutions for INferential Statistics · Online Statistical Analysis Platform for Agricultural Research

Computational Provenance & Reproducibility Record Regression Analysis · 2.0.0 · DOI 10.5281/zenodo.21318613

Computational Provenance & Reproducibility Record

RAISINS · Regression Analysis Module

This Computational Provenance Record documents the statistical computing environment, software dependencies, computational provenance, and bibliographic references associated with the RAISINS Regression Analysis module. It is intended to support computational reproducibility and software transparency. Detailed statistical methodology, mathematical derivations, and user guidance are provided separately in the official module documentation.

Any issues or updates required please comment here

Go to the App from here

1 Module Metadata

Parameter Specification
Module Regression Analysis
Module Version 2.0.0
DOI 10.5281/zenodo.21318613
Document Type Computational workflow
Statistical Engine R
R Version 4.5.2
Reproducibility Execution Environment: Posit Connect · GCR · renv-locked

2 Statistical Dependency Manifest

Package Version Repository Core Statistical Functions
MASS 7.3-65 CRAN stepAIC()
car 3.1-5 CRAN vif(), ncvTest()
lmtest 0.9-40 CRAN dwtest()
effectsize 1.0.2 CRAN standardize_parameters()
DAAG 1.25.7 CRAN press() (leave-one-out PRESS statistic)
moments 0.14.1 CRAN jarque.test() (residual normality for n > 5000)
broom 1.0.13 CRAN augment(), tidy() (diagnostic quantities and tidy test output)
stats 4.5.2 Base R lm(), summary(), confint(), anova(), predict(), AIC(), BIC(), hatvalues(), cooks.distance(), rstandard(), rstudent(), dffits(), shapiro.test()

3 Statistical Function Registry

Analytical Role Primary Function(s)
Model fitting stats::lm()
Variable selection MASS::stepAIC()
Coefficient inference base::summary(), stats::confint(), effectsize::standardize_parameters()
Regression ANOVA & fit stats::anova(), stats::AIC(), stats::BIC()
Predictive error (PRESS) DAAG::press()
Multicollinearity car::vif()
Heteroscedasticity car::ncvTest()
Residual normality stats::shapiro.test() (3 ≤ n ≤ 5000); moments::jarque.test() (n > 5000)
Autocorrelation lmtest::dwtest(alternative = "two.sided")
Influence diagnostics stats::hatvalues(), stats::cooks.distance(), stats::rstandard(), stats::rstudent(), stats::dffits()
Diagnostic quantities broom::augment(), broom::tidy()
Prediction stats::predict()
Hold-out validation (ML mode) base::sample() split + stats::predict(); RMSE, MSE, SSE, test R²

4 Default Methods & Parameters

Analysis Step / Parameter Default Method / Value
Model Fitting Method Ordinary least squares multiple linear regression via lm(); rows with missing values are removed listwise (na.omit()) before fitting
Model terms (optional) Polynomial terms I(x^k) for selected numeric predictors, degree 2–4 (default 2); user-selected two-way interactions xi:xj
Response transformation (optional) log, log10, sqrt, inverse 1/Y, or square Y^2. A transformation that is invalid for the data (e.g. log with non-positive Y) is skipped and the untransformed model is fitted. Predictions are back-transformed to the original scale; log back-transformation yields the median, not the mean, response
Variable Selection Stepwise (optional) AIC-based MASS::stepAIC(); direction both (default), forward, or backward; initial and final AIC are reported. Reported p-values and confidence intervals do not account for the selection step
Coefficient
Inference
Estimates Estimate, standard error, t value, and p-value from summary()
Significance Star codes assigned with symnum() at cut points 0.001 / 0.01 / 0.05
Intervals & standardised 95% confidence intervals via confint(); standardised coefficients via effectsize::standardize_parameters(method = "refit")
Model Fit ANOVA Sequential (Type I) decomposition via anova()
Metrics R², adjusted R², residual standard error, F-statistic and p-value, AIC, BIC, RMSE, MAE, and the leave-one-out PRESS statistic (DAAG::press()). All are computed on the model (possibly transformed) scale
Regression
Assumptions
Multicollinearity car::vif() (VIF; GVIF for categorical predictors); low < 5, moderate 5–10, high > 10; computed only when the model has more than two coefficients. For the GVIF case the reported GVIF^(1/(2·Df)) is squared before these thresholds are applied
Heteroscedasticity car::ncvTest() non-constant error variance score test (Breusch-Pagan); p < 0.05 indicates heteroscedasticity
Residual normality Shapiro-Wilk on residuals (shapiro.test()) for 3 ≤ n ≤ 5000; moments::jarque.test() for n > 5000
Autocorrelation Durbin-Watson test, two-sided (lmtest::dwtest(alternative = "two.sided")); the verdict follows the test p-value, with the statistic (≈ 2 independent, < 2 positive, > 2 negative) giving the direction. ACF of residuals is computed when n ≥ 10
Influence
Diagnostics
Measures & thresholds Leverage (hatvalues(), flag > 2p/n), Cook's distance (flag > 4/n), standardised and studentised residuals (|studentised| > 2 potential, > 3 extreme), and DFFITS
Hold-out
Validation

(ML mode, optional)
Split Random train/test split of the complete-case data; training fraction user-set, default 80% (clamped to 50–95%); set.seed(123) for reproducibility
Test metrics RMSE, MSE, test-set SSE, test R² = 1 − SSE/SST, and an approximate adjusted test R², computed on predictions back-transformed to the original response scale. Distinct from the leave-one-out PRESS reported under Model Fit
Prediction Intervals predict(); the fitted regression line is displayed with a 95% confidence band

5 R Code for Key Analytical Steps

The code blocks below demonstrate the exact computation behind each reported result using the mtcars dataset from the datasets package.

5.1 Model Fitting and Variable Selection

data(mtcars)
model_full <- lm(mpg ~ wt + hp + disp, data = mtcars)

# optional AIC-based stepwise selection
# direction: "both" (default), "forward", or "backward"
model <- MASS::stepAIC(model_full, direction = "both", trace = FALSE)
AIC(model_full); AIC(model)

5.2 Coefficients, Intervals and Regression ANOVA

summary(model)$coefficients          # estimate, std. error, t value, p-value
confint(model, level = 0.95)         # 95% confidence intervals
effectsize::standardize_parameters(model, method = "refit")  # standardised betas
anova(model)                         # sequential (Type I) ANOVA

5.3 Model Fit Metrics

sm  <- summary(model)
res <- residuals(model)
sm$r.squared; sm$adj.r.squared; sm$sigma   # R2, adjusted R2, residual std. error
sm$fstatistic                              # F, df1, df2 (overall model test)
sqrt(mean(res^2))                          # RMSE
mean(abs(res))                             # MAE
AIC(model); BIC(model)
DAAG::press(model)                         # leave-one-out PRESS statistic

5.4 Regression Assumption Tests

car::vif(model)                 # multicollinearity (VIF / GVIF)
car::ncvTest(model)             # non-constant error variance (heteroscedasticity)

# normality of residuals: Shapiro-Wilk up to n = 5000, Jarque-Bera beyond
r <- residuals(model)
if (length(r) > 5000) moments::jarque.test(as.numeric(r)) else shapiro.test(r)

lmtest::dwtest(model, alternative = "two.sided")  # autocorrelation (Durbin-Watson)
acf(residuals(model), plot = FALSE)               # ACF of residuals (n >= 10)

For a GVIF matrix (categorical predictors) the last column, GVIF^(1/(2·Df)), is on a standard-deviation scale and is squared before the usual VIF thresholds (5 / 10) are applied:

v <- car::vif(model)
if (is.matrix(v)) v[, ncol(v)]^2 else v   # values on the VIF scale

5.5 Influence and Outlier Diagnostics

n <- nobs(model); p <- length(coef(model))
hatvalues(model)        # leverage        (flag > 2p/n)
cooks.distance(model)   # Cook's distance (flag > 4/n)
rstandard(model)        # standardised residuals
rstudent(model)         # studentised residuals (|.| > 3 extreme)
dffits(model)           # DFFITS

5.6 Response Transformation and Back-Transformation

# a transformation is applied on the model's left-hand side, e.g. log(mpg) ~ ...
model_log <- lm(log(mpg) ~ wt + hp, data = mtcars)

# predictions are returned to the original response scale for reporting;
# note that exp() of a log-scale prediction estimates the MEDIAN response
pred_log <- predict(model_log, newdata = mtcars)
exp(pred_log)

5.7 Prediction

newdata <- data.frame(wt = 3.0, hp = 120, disp = 160)
predict(model, newdata)                                  # fitted value
predict(model, newdata, interval = "confidence", level = 0.95)  # mean response
# the regression-line plot displays the 95% confidence band around the fit

5.8 Hold-out Validation (Machine-Learning Mode)

df <- na.omit(mtcars)
n  <- nrow(df)

set.seed(123)                              # reproducible split
train_pct  <- 80                           # user-set, clamped to 50-95
idx        <- sample(seq_len(n), size = floor((train_pct / 100) * n))
trainSet   <- df[idx, ]
testSet    <- df[-idx, ]

fit   <- lm(mpg ~ wt + hp + disp, data = trainSet)
preds <- predict(fit, newdata = testSet)   # back-transformed if Y was transformed

actual <- testSet$mpg
ss_res <- sum((actual - preds)^2)
ss_tot <- sum((actual - mean(actual))^2)

sqrt(mean((actual - preds)^2))   # RMSE
mean((actual - preds)^2)         # MSE
ss_res                           # test-set SSE (not leave-one-out PRESS)
1 - ss_res / ss_tot              # test R-squared

Explore the entire Regression Analysis module in preview mode using our demo datasets. To submit suggestions or report a workflow issue, please use the discussion section below, or visit the official RAISINS website.

6 RAISINS Native Statistical Framework

RAISINS uses R for all its statistical computations. Every package used to generate major results is listed and demonstrated with examples, so results can be reproduced independently. These results are then organized and formatted on the RAISINS website along with visualisation to make them easier to use and interpret. RAISINS also has its own custom-built statistical tools for managing workflows, validating results, and generating reports. Details of these are not fully covered here, they’re shared with outside researchers only on request, and are subject to licensing terms.

7 Package References

R Core Team. (2025). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. https://www.R-project.org/

Venables, W. N., & Ripley, B. D. (2002). Modern Applied Statistics with S (4th ed.). Springer. https://www.stats.ox.ac.uk/pub/MASS4/

Fox, J., & Weisberg, S. (2019). An R Companion to Applied Regression (3rd ed.). Sage. https://socialsciences.mcmaster.ca/jfox/Books/Companion/

Zeileis, A., & Hothorn, T. (2002). Diagnostic Checking in Regression Relationships. R News, 2(3), 7-10. https://CRAN.R-project.org/doc/Rnews/

Ben-Shachar, M. S., Lüdecke, D., & Makowski, D. (2020). effectsize: Estimation of Effect Size Indices and Standardized Parameters. Journal of Open Source Software, 5(56), 2815. https://doi.org/10.21105/joss.02815

Maindonald, J. H., & Braun, W. J. (2024). DAAG: Data Analysis and Graphics Data and Functions (R package version 1.25.7). https://CRAN.R-project.org/package=DAAG

Komsta, L., & Novomestky, F. (2022). moments: Moments, Cumulants, Skewness, Kurtosis and Related Tests (R package version 0.14.1). https://CRAN.R-project.org/package=moments

Robinson, D., Hayes, A., & Couch, S. (2025). broom: Convert Statistical Objects into Tidy Tibbles (R package version 1.0.13). https://CRAN.R-project.org/package=broom

Allaire, J. J., Xie, Y., Dervieux, C., McPherson, J., Luraschi, J., Ushey, K., Atkins, A., Wickham, H., Cheng, J., Chang, W., & Iannone, R. (2026). rmarkdown: Dynamic Documents for R (R package version 2.31). https://github.com/rstudio/rmarkdown

Feedback & Discussion