Skip to content

feat: moderndive R argument parity (correlation methods, newdata, …)#18

Merged
ismayc merged 4 commits into
mainfrom
feat/moderndive-arg-parity
Jun 20, 2026
Merged

feat: moderndive R argument parity (correlation methods, newdata, …)#18
ismayc merged 4 commits into
mainfrom
feat/moderndive-arg-parity

Conversation

@ismayc

@ismayc ismayc commented Jun 20, 2026

Copy link
Copy Markdown
Member

First of two PRs closing the remaining R argument-level gaps (functions all already existed). This one covers moderndive:

  • get_correlation(method=, na_rm=) — Spearman and Kendall rank correlations (via scipy), in addition to Pearson; na_rm toggles per-pair null dropping.
  • get_regression_points(newdata=, ID=) — apply the model to a held-out set (a residual is included when the outcome is present in newdata), and use a column as the row identifier.
  • get_regression_table(default_categorical_levels=True) — keep the raw statsmodels factor-level term names instead of the prettified "var: level" form.
  • gg_parallel_slopes(alpha=) — point transparency (both engines).

Tests cover scipy-matching for each correlation method, na_rm=Falsenan, newdata with/without outcome, ID from a source column and from newdata, all error paths, raw vs prettified terms, and the alpha plots. Docs updated (correlation methods + newdata prediction). 291 tests, 100% coverage, ruff clean, docs -W clean.

The companion infer arg-parity PR (median point null, prop_test options, weighted sampling, generate(variables=), shade fill, dens_color) is next.

🤖 Generated with Claude Code

- get_correlation(method="spearman"|"kendall", na_rm=): rank correlations via
  scipy; na_rm toggles per-pair null dropping.
- get_regression_points(newdata=, ID=): predict on a held-out frame (residual
  included when the outcome is present) and use a column as the identifier.
- get_regression_table(default_categorical_levels=True): keep raw statsmodels
  factor-level term names instead of the prettified "var: level" form.
- gg_parallel_slopes(alpha=): point transparency (both engines).

Docs (correlation methods + newdata prediction) and CHANGELOG updated. 291 tests,
100% coverage, ruff clean, docs build -W clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017CTL1QSTg1DmDUpqYuPEog
ismayc and others added 3 commits June 20, 2026 13:58
…arity

# Conflicts:
#	CHANGELOG.md
#	doc/_build/html/.doctrees/api.doctree
#	doc/_build/html/.doctrees/environment.pickle
#	doc/_build/html/.doctrees/getting-started.doctree
#	doc/_build/html/.doctrees/guides/confidence-intervals.doctree
#	doc/_build/html/.doctrees/guides/hypothesis-testing.doctree
#	doc/_build/html/.doctrees/guides/plotting.doctree
#	doc/_build/html/.doctrees/guides/regression.doctree
#	doc/_build/html/.doctrees/guides/theory-based.doctree
#	doc/_build/html/.doctrees/index.doctree
#	doc/_build/html/searchindex.js
#	doc/_build/jupyter_execute/datasets.ipynb
#	doc/_build/jupyter_execute/getting-started.ipynb
#	doc/_build/jupyter_execute/guides/confidence-intervals.ipynb
#	doc/_build/jupyter_execute/guides/hypothesis-testing.ipynb
#	doc/_build/jupyter_execute/guides/messages.ipynb
#	doc/_build/jupyter_execute/guides/plotting.ipynb
#	doc/_build/jupyter_execute/guides/regression.ipynb
#	doc/_build/jupyter_execute/guides/sampling.ipynb
#	doc/_build/jupyter_execute/guides/theory-based.ipynb
#	doc/_build/jupyter_execute/index.ipynb
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017CTL1QSTg1DmDUpqYuPEog
@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b4944a0) to head (98d4c8c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main       #18   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines         1492      1546   +54     
=========================================
+ Hits          1492      1546   +54     
Files with missing lines Coverage Δ
moderndive/correlation.py 100.00% <100.00%> (ø)
moderndive/modeling.py 100.00% <100.00%> (ø)
moderndive/plots/models.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ismayc ismayc merged commit 2f5a652 into main Jun 20, 2026
8 checks passed
@ismayc ismayc deleted the feat/moderndive-arg-parity branch June 20, 2026 22:20
ismayc added a commit that referenced this pull request Jun 20, 2026
#20)

* docs+test: NEWS.md, R-compatibility notes, and R-reference value tests

- NEWS.md summarizing the current state under 0.1.0.
- doc/r-compatibility.md documenting the deliberate choices made to match R
  results that differ from "typical" Python (pop_sd ddof=0, regression-summary
  mse denominator, prop_test chi-square+Yates+Wilson CI, get_p_value two-sided
  convention, UTC datetimes, derived early_january_2023_weather, plotly default,
  correlation na_rm default, etc.).
- tests/test_r_reference.py: cross-package checks asserting the Python results
  equal R's exact values on a fixed dataset (get_regression_table/summaries,
  get_correlation, pop_sd, t_test). New-argument R validations live with their
  feature tests (#18/#19).

279 tests, 100% coverage, ruff clean, docs build -W clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017CTL1QSTg1DmDUpqYuPEog

* docs: rebuild HTML after merging main (#19)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017CTL1QSTg1DmDUpqYuPEog

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant