BetterReg

BetterReg: An R package for Useful Regression Statistics - Published in JOSS (2022)

https://github.com/chrisaberson/betterreg

Science Score: 95.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
    1 of 2 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Scientific Fields

Earth and Environmental Sciences Physical Sciences - 40% confidence
Last synced: 4 months ago · JSON representation

Repository

Better statistics for regression (OLS and logistic)

Basic Info
  • Host: GitHub
  • Owner: chrisaberson
  • License: other
  • Language: R
  • Default Branch: main
  • Size: 715 KB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • Open Issues: 0
  • Releases: 3
Created almost 4 years ago · Last pushed over 3 years ago
Metadata Files
Readme License

README.md

BetterReg Readme

Chris Aberson May 25, 2022

BetterReg

This package provides tools for statistics that are not provided in base R packages for linear regression and logistic regression. Functions provide squared semi-partial correlations, tolerance, Mahalanobis Distances, Likelihood Ratio Chi-square, and Pseudo R-square.

Prerequisites

I built this under R 4.2.0

Authors

Dependencies

car (>= 3.0-0), stats (>= 3.5.0), dplyr (>= 0.8.0)

Issues and Contributions

Please post issues using the link above (titled "issues"). Those interested in contributing to further development should create a pull request. For feature requests, submit an issue.

License

This project is licensed under GNU General Public License version 3.

Installation

The package is available on CRAN. Use the command install.packages("BetterReg"). This respository will usually include a beta version for the next release. To install from GitHub - in R issue the command below.

devtools::install_github("chrisaberson/BetterReg")

Paper

DOI

Example 1: OLS Regression

Using data from Aberson (2007), the analyses that follow predict support for Affirmative Action (AA) in year 4 of college from incomming attitudes, personal experience with discrimination, liberality, gender, and economic concern for the future. In a later example, I add perceptions of the prevalence of discrimination, endorsement of meritocracy, and partipation in campus diversity events.

The part function requires an existing LM model and indication of number of predictors.

First, build the model:
xx<-lm(formula = AA_DV ~ AA_Initial+pers_exp+liberal+female+economic, data = hand5) Then, using the parts command, provide the model name and the number of predictors
``` parts(model=xx, pred=5)

Predictor 1: semi partial = 0.333; squared semipartial = 0.111
Predictor 2: semi partial = 0.032; squared semipartial = 0.001
Predictor 3: semi partial = 0.197; squared semipartial = 0.039
Predictor 4: semi partial = 0.095; squared semipartial = 0.009
Predictor 5: semi partial = 0.032; squared semipartial = 0.001
The `Mahal` function provides Mahalanobis values and requires input of model and predictors as well as the number of values to return (10 is the default). Mahal(model=xx, pred=5, values=10)

 60      247      639      703      133      157      129      431     24      655

11.08698 11.08698 11.77189 11.93773 12.34983 13.68620 14.15117 14.50515 14.72140 15.27508
```

The tolerance command requires only the model name. ``` tolerance(model=xx)

AAInitial persexp liberal female economic
0.9464682 0.9904156 0.9058256 0 9418196 0.9910559
```

R2change compares two models. Below, I added merit, discrimination, and diversity participation to the model (xx2).
the R2change command takes model1 (xx) and compares it to model2 (xx2). Note that this approach is only for models that are adding variables to a previous model. ``` xx2<-lm(formula = AADV ~ AAInitial+persexp+liberal+female+economic+merit+discrim+divpart, data = hand5) R2change(model1=xx, model2=xx2)

R-square change = 0.181

F(3,704) = 70.537, p = 6.81538788796511e-40 ```

The depbcomp function allows for comparisons of dependent coefficients. These are coefficients in the same model.
``` depbcomp(data=sample1,y="AADV",x1="divpart",x2="merit", x3="discrim",numpred=3,comps="abs")

Pred 1 vs. Pred 2 : t = 4.633, p = 4.28730081880602e-06
Pred 1 vs. Pred 3 : t = 9.614, p = 0
Pred 2 vs. Pred 3 : t = 5.371, p = 1.0627416191511e-07
`` Theindbcomp` function compares predictors from two (identical) model. Note that the model object should be a summary of the model.

``` model1<-summary(lm(AADV~ divpart+merit+ discrim, data=hand5))
model2<-summary(lm(AADV~ divpart+merit+ discrim, data=sample2))
indbcomp(model1=model1, model2=model2, pred=3, comp="abs")

Predictor 1: t = 110.812, p = 0
Predictor 2: t = 13.623, p = 0
Predictor 3: t = 23.958, p = 0
```

Example 2: Logistic Regression functions

In this example, taken from Cohen, Cohen, West, and Aiken (2015), women's compliance with mammography recommendations (i.e., yearly screening in this case) is predicted from physicians recommendation, knowledge of mammography, perceived barriers, and perceived benifits.

First, run a logistic regression model. Model4<-glm(comply~physrec+knowledg+benefits+barriers, data=logistic2, family = binomial()) The LRchi command requires the name of the dataset, definition of all variables in mode (y, x1, x2, etc.), and the number of model predictors. ``` LRchi(data=logistic2, y="comply",x1="physrec", x2="knowledg", x3="benefits",x4="barriers", numpred=4)

Predictor: physrec; LR squared 16.67, p= 0
Predictor: knowledg; LR squared 0.01, p= 0.94
Predictor: benefits; LR squared 5.29, p= 0.02
Predictor: barriers; LR squared 13.77, p= 0
The `pseudo` function requires only an existing model as input. pseudo(model = Model4)

Likelihood Ratio R-squared (McFadden, Recommended) = 0.26
Cox-Snell R-squared = 0.301
Nagelkerk R-squared = 0.402
```

Owner

  • Login: chrisaberson
  • Kind: user

JOSS Publication

BetterReg: An R package for Useful Regression Statistics
Published
June 02, 2022
Volume 7, Issue 74, Page 4280
Authors
Christopher L. Aberson ORCID
Cal Poly Humboldt
Editor
Mehmet Hakan Satman ORCID
Tags
OLS Regression Logistic Regression

GitHub Events

Total
Last Year

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 147
  • Total Committers: 2
  • Avg Commits per committer: 73.5
  • Development Distribution Score (DDS): 0.027
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
chrisaberson c****8@h****u 143
Mehmet Hakan Satman m****n@g****m 4
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 6
  • Total pull requests: 5
  • Average time to close issues: 9 days
  • Average time to close pull requests: 3 days
  • Total issue authors: 2
  • Total pull request authors: 2
  • Average comments per issue: 2.17
  • Average comments per pull request: 1.2
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • brunomontezano (5)
  • chrisaberson (1)
Pull Request Authors
  • jbytecode (3)
  • brunomontezano (2)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

DESCRIPTION cran
  • R >= 3.5.0 depends
  • car >= 3.0 imports
  • dplyr >= 0.8.0 imports
  • stats >= 3.5.0 imports