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.3.tar.gz (5.1 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.3-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sunlm-0.1.3.tar.gz
  • Upload date:
  • Size: 5.1 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.3.tar.gz
Algorithm Hash digest
SHA256 776e2ac98ac57ea72f45dc73b4c547c466c9c897ba7edc5e6908580d44e4e48b
MD5 245c95ffac9c380247cd85a779d6b05f
BLAKE2b-256 1ad733356f8bcd8403832805fa49d612d9d85ac509febffcb620b38a9cfded3f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sunlm-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 86e2ed2bd2736d5ffd5e9b1930bd38869710db720d952fc255bfca47b7a32841
MD5 eb45db5ae3cd96319cd7d53122306902
BLAKE2b-256 aa32aed89b542200703a0853c5ae545655028d1d0a5405701e4fdeba239462a3

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