Package {OLSengine}


Title: Transparent and Assisted Linear Modeling Engine
Version: 1.0.0
Description: A transparent, modular, and base-R implemented statistical engine for linear regression (OLS), analysis of variance (ANOVA), and logistic regression (Logit). Designed under the principle of "assisted simplicity", it features an integrated methodological "customs" (Aduana) that automatically audits mathematical assumptions (e.g., multicollinearity, heteroskedasticity, normality, and perfect separation) and outputs publication-ready, APA-formatted tables. It deliberately avoids hidden heuristics and external dependencies, ensuring computational transparency and reproducibility for applied research.
License: MIT + file LICENSE
URL: https://github.com/msoto-perez/OLSEngine
BugReports: https://github.com/msoto-perez/OLSEngine/issues
Encoding: UTF-8
RoxygenNote: 7.3.3
VignetteBuilder: knitr
Suggests: knitr, rmarkdown
NeedsCompilation: no
Packaged: 2026-05-10 13:12:55 UTC; msoto
Author: Manuel Soto-Pérez [aut, cre]
Maintainer: Manuel Soto-Pérez <msoto@up.edu.mx>
Repository: CRAN
Date/Publication: 2026-05-14 09:10:07 UTC

Transparent and Assisted Linear Modeling Engine

Description

Estimates OLS regression, ANOVA/t-tests, or binary logistic regression models using pure base R matrix algebra. Automatically audits statistical assumptions through an integrated methodological customs layer and returns publication-ready APA-formatted tables. Designed for applied researchers and early-career academics who need a single, transparent workflow from estimation to reporting.

Usage

paper_engine(
  formula,
  data,
  model = "ols",
  robust = FALSE,
  non_parametric = FALSE,
  paired = FALSE,
  digits = 2
)

Arguments

formula

A formula object specifying the model (e.g., y ~ x1 + x2).

data

A data frame containing all variables referenced in formula.

model

A character string indicating the estimation engine. One of "ols" (default), "anova", or "logit".

robust

Logical or "auto". Controls heteroskedasticity-robust standard errors (HC3) for OLS models. If TRUE, HC3 SEs are always applied. If "auto", they are applied only when the Breusch-Pagan test detects heteroskedasticity (p < .05). Default is FALSE.

non_parametric

Logical or "auto". Controls non-parametric fallback for ANOVA/t-test models. If TRUE, Kruskal-Wallis or Wilcoxon tests are used. If "auto", transition occurs when Shapiro-Wilk detects non-normality (p < .05). Default is FALSE.

paired

Logical. If TRUE, assumes paired/dependent samples for ANOVA/t-test models (pre-post designs). Default is FALSE.

digits

Integer. Number of decimal places in output tables. Default is 2.

Value

An object of class basic_model, which is a list containing:

tables

A list of formatted data frames with estimation results.

diagnostics

A list of raw diagnostic statistics (p-values, fit indices).

messages

A character vector of methodological guidance messages from the customs layer.

method

A character string indicating the engine used ("ols", "anova", or "logit").

data

The cleaned data frame used for estimation (after listwise deletion).

Examples

# OLS example
set.seed(42)
df <- data.frame(y = rnorm(100), x1 = rnorm(100), x2 = rnorm(100))
result <- paper_engine(y ~ x1 + x2, data = df, model = "ols")
print(result$tables)
print(result$messages)

# ANOVA example
df2 <- data.frame(score = c(rnorm(30, 5), rnorm(30, 7)),
                  group = rep(c("A", "B"), each = 30))
result2 <- paper_engine(score ~ group, data = df2, model = "anova")
print(result2$tables)

# Logit example
df3 <- data.frame(y = rbinom(100, 1, 0.5), x = rnorm(100))
result3 <- paper_engine(y ~ x, data = df3, model = "logit")
print(result3$tables)


Generate Publication-Ready Plots for Basic Models

Description

Produces minimalist APA-style plots from a basic_model object returned by paper_engine. The plot type is selected automatically based on the estimation method: a forest plot of coefficients with 95% CI for OLS, a group means plot with 95% CI error bars for ANOVA, and a logistic probability curve for logistic regression.

Usage

plot_engine(model_object, y_label = NULL, x_label = NULL)

Arguments

model_object

An object of class basic_model generated by paper_engine.

y_label

A character string for the Y-axis label. If NULL (default), a label is generated automatically from the model type.

x_label

A character string for the X-axis label. If NULL (default), a label is generated automatically from the model type.

Value

A base R plot rendered in the active graphics device. The function is called for its side effect (the plot) and returns NULL invisibly.

Examples

set.seed(42)
df <- data.frame(y = rnorm(100), x1 = rnorm(100), x2 = rnorm(100))
result <- paper_engine(y ~ x1 + x2, data = df, model = "ols")
plot_engine(result, y_label = "Outcome", x_label = "Predictors")