OLSengine is an open-source R package designed for applied researchers in social sciences. It provides a comprehensive, zero-dependency mathematical engine for fundamental statistical methods and modern causal inference techniques.
Built under the philosophy of “Assisted Simplicity”, OLSengine acts as a methodological customs filter (“Aduana”). It unifies model estimation and diagnostics in a single step, alerting researchers to violations of mathematical assumptions and guiding them toward robust alternatives without making automatic decisions behind their backs.
ggplot2.Install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("msoto-perez/OLSengine")The package revolves around a single, powerful wrapper function:
paper_engine().
Detects heteroskedasticity and multicollinearity. HC3 robust standard errors available.
library(OLSengine)
# Standard OLS
model_ols <- paper_engine(y ~ x1 + x2, data = my_data, model = "ols")
# With HC3 Robust Standard Errors
model_robust <- paper_engine(y ~ x1 + x2, data = my_data, model = "ols", robust = TRUE)
# View results
model_robust$tables$Table2_OLS_Estimation
model_robust$messages
# Generate forest plot
plot_engine(model_robust)Handles independent or paired designs, parametric and non-parametric tests.
# Auto-pilot: switches to non-parametric if normality fails
model_anova <- paper_engine(score ~ group, data = experiment_data,
model = "anova", non_parametric = "auto")
# Generate group means plot with 95% CI
plot_engine(model_anova)Reports Odds Ratios, McFadden’s and Nagelkerke’s Pseudo R², classification accuracy.
model_logit <- paper_engine(purchased ~ age + income, data = consumer_data,
model = "logit")
# Generate predicted probability curve
plot_engine(model_logit)Hausman test automatically selects between fixed and random effects.
model_panel <- paper_engine(wage ~ experience + education,
data = panel_data,
model = "panel",
entity_id = "worker_id",
time_id = "year",
method = "auto") # Hausman test decides
plot_engine(model_panel)Detects weak instruments (Stock & Yogo, 2005) and tests overidentification (Sargan).
model_iv <- paper_engine(education ~ income,
data = wage_data,
model = "iv",
instruments = ~ father_education + region)
# Diagnostics include first-stage F-stat
model_iv$messages
plot_engine(model_iv)Tests parallel trends assumption and visualizes treatment effects.
model_did <- paper_engine(outcome ~ 1,
data = policy_data,
model = "did",
treatment_var = "treated",
time_var = "period",
treatment_level = "Treated",
post_level = "Post")
# Plot shows parallel trends and treatment effect
plot_engine(model_did)The package includes academic_salaries, a real dataset
of 397 U.S. college professors:
data(academic_salaries)
# Explore salary determinants
salary_model <- paper_engine(salary ~ rank + discipline + years_since_phd + sex,
data = academic_salaries,
model = "ols",
robust = "auto")All engines have been validated against standard R packages
(lm, aov, glm, plm,
ivreg) with numerical precision < 0.001. See
validation.R for complete verification.
To cite OLSengine in publications:
Soto-Pérez, M. (2025). OLSengine: Transparent linear and causal inference
models for social sciences (v1.1.0). R package.
https://github.com/msoto-perez/OLSengine
Issues and pull requests are welcome at: https://github.com/msoto-perez/OLSengine/issues
MIT License - see LICENSE file for details.