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.post1.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.post1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sunlm-0.1.3.post1.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.post1.tar.gz
Algorithm Hash digest
SHA256 644203de275e29a50adacadd25551eef32fbc7f122461773ba58d1e75c454438
MD5 67bf413ac80087bf6ca7493594fe3e2e
BLAKE2b-256 47bbd3ae7392fdaa371d4aabc093d9077d2807ef45fbc45ecadac6ed240c3399

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sunlm-0.1.3.post1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 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.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8ce5561ccb12ce43386fb0e4d09fe52698b11dedd47b2515988baf46882daa0
MD5 dc977ddedf88f5254278968e111e0666
BLAKE2b-256 224c6b05190d4144ed7fcab4d830c59a0f03882854c445a2983bdde77296ae08

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