Skip to main content

Simple social-science-friendly OLS regression tools

Project description

sunlm

sunlm is a lightweight, social-science–friendly Python package that provides an intuitive OLS regression wrapper using formula syntax (similar to R's lm()), with standardized coefficients, semi-partial R² (sr²), and APA-style output.
It is designed for researchers in communication, psychology, marketing, and the social sciences who want simple but informative regression summaries without complex statistical coding.


🔧 Features

  • ✔️ Formula interface via patsy (y ~ x1 + x2)
  • ✔️ OLS estimation via statsmodels
  • ✔️ Unstandardized coefficients (B)
  • ✔️ Standardized coefficients (Beta, β)
  • ✔️ Semi-partial R² (sr²) for effect size
  • ✔️ Clean social-science–style regression summary
  • ✔️ Return results as a DataFrame for further formatting/export
  • ✔️ Easy to extend (robust SE, interactions, PROCESS-style mediation planned)

📥 Installation

From PyPI (once officially released)

pip install pysslm


# Quick Start Example
import pandas as pd
import sslm

# Example dataset
df = pd.DataFrame({
    "y":  [1, 2, 3, 4, 5],
    "x1": [2, 1, 4, 3, 5]
})

# Run regression
model = sslm.ols("y ~ x1", data=df)

# Print summary
model.summary()

# Sample Output
## 📊 SSLM Regression Summary
---------------------------------------------------------
           Unstd. B  Std. Err.  Std. β   t-value p-print  sr^2
Intercept       0.6   1.148913     NaN  0.522233   0.638   NaN
x1              0.8   0.346410     0.8  2.309401   0.104  0.64

## 📈 Model Fit Statistics
---------------------------------------------------------
Dependent variable           y
N                            5
R-squared                 0.64
Adjusted R-squared        0.52
F-statistic           5.333333
Prob (F-statistic)    0.104088
---------------------------------------------------------


# API Overview

sslm.ols(formula, data)

Runs OLS regression using formula syntax.

Parameters
		formula  string, e.g., "y ~ x1 + x2"
		data  pandas DataFrame

Returns
		SSLM_Model object

⸻

model.summary()

Prints APA-style regression output including:
		unstandardized coefficients (B)
		standard errors
		standardized beta (β)
		t-values & p-values
		semi-partial  (sr²)
		model-level fit stats (R², Adj. R², F, etc.)

⸻

model.as_dataframe()

Returns the full coefficient table as a pandas DataFrame
(ideal for exporting to Excel, LaTeX, or APA tables).

# Project Structure
sslm/
 ├─ sslm/
    ├─ __init__.py
    └─ core.py        # main implementation
 ├─ pyproject.toml
 └─ README.md

# Contributing
Pull requests, feature suggestions, and bug reports are welcome once the GitHub repository is available.

# License
MIT License

# Author
Seonwoo Kim
Northern Arizona University
Designed for students, researchers, and anyone needing a clean statistical pipeline in Python.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sunlm-0.1.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sunlm-0.1.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file sunlm-0.1.2.tar.gz.

File metadata

  • Download URL: sunlm-0.1.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for sunlm-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d10a27bed380e02e7c3f1d34723238f735e3fb487a8bc843be37ad6db5f4d550
MD5 6ded8e145d4751962c781ae9e3d5f32e
BLAKE2b-256 4afeee0c20343780e9fbbd08ed4319fe78fc74fc4638e9cf920e8ef25086b0af

See more details on using hashes here.

File details

Details for the file sunlm-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sunlm-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for sunlm-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cc9e40afb64a07e93d9cf231ebd4205b854682721603d1023e021e9efea0ba87
MD5 b57689ee5afc890188853ab9d07c5ad4
BLAKE2b-256 30d79728ee976113c2a313993efb50677871e7c5a987b13e553f8cbae21f324a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page