Calculate and Compare Multiple Definitions of Coefficient of Determination
Overview
Calculate nine types of coefficients of determination (R-squared) based on the classification by Kvalseth (1985) doi:10.1080/00031305.1985.10479448. This package is designed for educational purposes to demonstrate how R-squared values can fluctuate depending on the choice of formula, particularly in power regression models or linear models without an intercept. By providing a comprehensive list of definitions, it helps users understand the mathematical sensitivity of goodness-of-fit indices.
New Features
- Added
model_info()function to extract metadata used for calculations, such as regression type (linear/power), sample size ($n$), and degrees of freedom ($k$, $df_{res}$). - The
print()methods forr2_kvr2andcomp_kvr2objects now display model information at the end of the output by default. - Added a new argument
model_info(default isTRUE) toprint()methods, allowing users to toggle the display of model metadata. - Added
comp_model()to contrast intercept and no-intercept versions of the same model using QR-decomposition for robust re-calculation. - Added a set of plot functions that visually display the difference between the actual and predicted values of the dependent variable in the model and the coefficient of determination.
Improvements
- Improved the auto-detection logic for power regression models. It now correctly distinguishes between a variable named "log" and the
log()function call (e.g.,lm(log(y) ~ x)is correctly identified whilelm(log ~ x)is treated as linear). - Internal calculations now explicitly store model attributes to ensure consistency between
r2()andmodel_info().
Bug Fixes
- Fixed several typographical errors in the output and documentation. Notably, corrected "RMES" to "RMSE" (Root Mean Square Error) in the output of
comp_fit(). - Fixed a misclassification issue where models with a dependent variable named "log" were incorrectly identified as power regression when using
type = "auto".
Show all changes in 0.2.0Hide the rest of the changes in 0.2.0
- Corrected "liner" to "linear" in various internal labels and documentation to ensure consistency with standard statistical terminology.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-06-09
- ERROR12 OK, 1 ERROR2026-06-08
- OK14 OK2026-03-10
Documentation
- Help pages
- 11
- Examples that run
- 100%8 run in a plain check
- Exported functions with examples
- 86%
- Documented parameters
- 100%
- Return-value docs
- 100%
- Help pages citing references
- 36%
Downloads
Repository
8 development-tooling and community-health practices detected across 4 families in the upstream repository
Checks run against github.com/indenkun/kvr2 on 2026-10-22.
GitHub Pages site last deployed 2026-03-10 · The repository has a site deploy workflow
pkgdown site last built 2026-03-11
Dependencies
Code & Tests
People & History
Pick two releases to compare their code metrics.
- RR 4.6.0 released · 2026-04-24
- 0.2.0Latest2026-03-10 · current release · diff ↗ ·
added 4 exports
comp_model, model_info, plot_diagnostic, plot_kvr2 - 0.1.02026-02-12
- RR 4.5.0 released · 2025-04-11
Package metadata
- First published
- 2026-02-12
- Total releases
- 2 / 1 yrs
- License
- MIT + file LICENSE OSI
- Download size
- 149 KB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("kvr2")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-23, which the citation names so these numbers can be found later. More on citing and the projects behind them.