-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
63 lines (43 loc) · 2.27 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
title: "logitr"
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, cache = TRUE)
```
[![Build Status](https://travis-ci.org/MGallow/logitr.svg?branch=master)](https://travis-ci.org/MGallow/logitr)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/logitr)](https://cran.r-project.org/package=logitr)
### ***This package is experimental and not regularly maintained. It is recommended to use {glmnet} instead!
## Overview
`logitr` is an R package for linear and logistic regression with optional ridge and bridge regularization penalties. A (possibly incomplete) list of functions contained in the package can be found below:
* `logisticr()` computes the coefficient estimates for logistic regression (ridge and bridge regularization optional)
* `linearr()` computes the linear regression coefficient estimates (ridge regularization and weights optional)
* `predict.logisticr()` generates predictions and loss metrics for logistic regression
* `predict.linearr()` generates predictions and loss metric for linear regression
See [vignette](https://mgallow.github.io/logitr/) or [manual](https://github.com/MGallow/logitr/blob/master/logitr.pdf).
## Installation
```{r, eval = FALSE}
# The easiest way to install is from the development version from GitHub:
# install.packages("devtools")
devtools::install_github("MGallow/logitr")
```
If there are any issues/bugs, please let me know: [github](https://github.com/MGallow/logitr/issues). You can also contact me via my [website](https://mgallow.github.io/). Pull requests are welcome!
## Usage
```{r, message = FALSE}
library(logitr)
#we will use the iris data set
X = dplyr::select(iris, -c(Species, Sepal.Length))
y = dplyr::select(iris, Sepal.Length)
y_class = ifelse(dplyr::select(iris, Species) == "setosa", 1, 0)
#ridge regression (use CV for optimal lambda)
linearr(X, y, penalty = "ridge")
#ridge logistic regression (IRLS) (use CV for optimal lambda)
logisticr(X, y_class, penalty = "ridge")
#ridge logistic regression (MM)
logisticr(X, y_class, lam = 0.1, penalty = "ridge", method = "MM")
#bridge logistic regression (MM)
fit = logisticr(X, y_class, lam = 0.1, alpha = 1.2, penalty = "bridge")
fit
#predict using bridge logistic regression estimates
predict(fit, X[1:3,], y_class[1:3])
```