An open API service indexing awesome lists of open source software.

https://github.com/shixiangwang/regport

Regression Model Processing Port
https://github.com/shixiangwang/regport

batch-processing r-package regression-models rstats

Last synced: 8 months ago
JSON representation

Regression Model Processing Port

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# regport

[![CRAN status](https://www.r-pkg.org/badges/version/regport)](https://cran.r-project.org/package=regport)
[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![R-CMD-check](https://github.com/ShixiangWang/regport/workflows/R-CMD-check/badge.svg)](https://github.com/ShixiangWang/regport/actions)
[![](https://cranlogs.r-pkg.org/badges/grand-total/regport?color=orange)](https://cran.r-project.org/package=regport)

The goal of regport is to provides R6 classes, methods and utilities to construct,
analyze, summarize, and visualize regression models (CoxPH and GLMs).

> This package is been superseded by [bregr](https://cran.r-project.org/package=bregr).

## Installation

You can install the development version of regport like so:

```r
remotes::install_github("ShixiangWang/regport")
```

## Simple case

This is a basic example which shows you how to build and visualize a Cox model.

Prepare data:

```{r}
library(regport)
library(survival)

lung = survival::lung
lung$sex = factor(lung$sex)
```
Create a model:

```{r}
model = REGModel$new(
lung,
recipe = list(
x = c("age", "sex"),
y = c("time", "status")
)
)

model
```

You can also create it with formula:

```{r}
model = REGModel$new(
lung,
recipe = Surv(time, status) ~ age + sex
)

model
```

Take a look at the model result (package `see` is required):

```{r, fig.width=4, fig.width=6}
model$plot()
```

Visualize with more nice forest plot.

```{r dpi=300}
model$get_forest_data()
model$plot_forest()
```

## Batch processing models

For building a list of regression model, unlike above, a lazy building approach
is used, i.e., `$build()` must manually typed after creating `REGModelList` object.
(This also means you can check or modify the setting before building if necessary)

```{r dpi=300}
ml <- REGModelList$new(
data = mtcars,
y = "mpg",
x = c("factor(cyl)", colnames(mtcars)[3:5]),
covars = c(colnames(mtcars)[8:9], "factor(gear)")
)
ml
ml$build(f = "gaussian")
str(ml$result)
str(ml$forest_data)

ml$plot_forest(ref_line = 0, xlim = c(-15, 8))
```

## Coverage

```{r}
covr::package_coverage()
```

## LICENSE

(MIT) Copyright (c) 2022 Shixiang Wang