Skip to content

Commit

Permalink
Merge pull request #46 from USCbiostats/gw-update-readme
Browse files Browse the repository at this point in the history
update readme properly
  • Loading branch information
gmweaver authored Jun 26, 2024
2 parents dedd057 + c779a7d commit 30138bb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ knitr::opts_chunk$set(
)
```

[![Travis Build Status](https://travis-ci.org/USCbiostats/xrnet.svg?branch=master)](https://travis-ci.org/USCbiostats/xrnet)
[![Build status](https://ci.appveyor.com/api/projects/status/vvlithictabcik9o/branch/master?svg=true)](https://ci.appveyor.com/project/gmweaver/xrnet/branch/master)
[![codecov](https://codecov.io/gh/USCbiostats/xrnet/branch/master/graph/badge.svg)](https://codecov.io/gh/USCbiostats/xrnet)
[![R-CMD-check](https://github.com/USCbiostats/xrnet/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/USCbiostats/xrnet/actions/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/USCbiostats/xrnet/branch/master/graph/badge.svg)](https://app.codecov.io/gh/USCbiostats/xrnet?branch=master)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/xrnet)](https://cran.r-project.org/package=xrnet)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.01761/status.svg)](https://doi.org/10.21105/joss.01761)

Expand Down
56 changes: 31 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# xrnet: R Package for Hierarchical Regularized Regression to Incorporate External Data <img src="man/figures/logo.png" align="right" height="180px"/>

<!-- README.md is generated from README.Rmd. Please edit that file -->
Expand All @@ -13,9 +14,9 @@ coverage](https://codecov.io/gh/USCbiostats/xrnet/branch/master/graph/badge.svg)
The **xrnet** R package is an extension of regularized regression
(i.e. ridge regression) that enables the incorporation of external data
that may be informative for the effects of predictors on an outcome of
interest. Let *y* be an n-dimensional observed outcome vector, *X* be a
interest. Let $y$ be an n-dimensional observed outcome vector, $X$ be a
set of *p* potential predictors observed on the *n* observations, and
*Z* be a set of *q* external features available for the *p* predictors.
$Z$ be a set of *q* external features available for the *p* predictors.
Our model builds off the standard two-level hierarchical regression
model,

Expand All @@ -35,13 +36,12 @@ following objective function (ignoring intercept terms):
![](man/figures/eqn3.gif)

Note that our model allows for the predictor coefficients, beta, to
shrink towards potentially informative values based on the matrix *Z*.
shrink towards potentially informative values based on the matrix $Z$.
In the event the external data is not informative, we can shrink alpha
towards zero, returning back to a standard regularized regression. To
efficiently fit the model, we rewrite this convex optimization with the
variable substitution
*g**a**m**m**a* = *b**e**t**a* − *Z*\**a**l**p**h**a*. The problem is
then solved as a standard regularized regression in which we allow the
variable substitution $gamma = beta - Z * alpha$. The problem is then
solved as a standard regularized regression in which we allow the
penalty value and type (ridge / lasso) to be variable-specific:

![](man/figures/eqn4.gif)
Expand All @@ -63,15 +63,15 @@ install.packages("xrnet")
#### From Github (most up-to-date)

1. OS-specific prerequisites
- *Windows*: Install
[RTools](https://cran.r-project.org/bin/windows/Rtools/) (not an
R package)
- *Mac*: If using R version &gt;= 3.6.0, verify your GNU Fortran
version is &gt;= 6.1. If you have an older version, go
[here](https://cran.r-project.org/bin/macosx/tools/) to install
the required version
- *Windows*: Install
[RTools](https://cran.r-project.org/bin/windows/Rtools/) (not an R
package)
- *Mac*: If using R version \>= 3.6.0, verify your GNU Fortran
version is \>= 6.1. If you have an older version, go
[here](https://cran.r-project.org/bin/macosx/tools/) to install
the required version
2. Install the R package [devtools](https://github.com/hadley/devtools)
3. Install the **xrnet** package with the *install\_github()* function
3. Install the **xrnet** package with the *install_github()* function
(optionally install potentially unstable development branch)

``` r
Expand Down Expand Up @@ -120,25 +120,25 @@ predictors or external data, you can use the `define_penalty` function.
This function allows you to configure the following regularization
attributes:

- Regularization type
- Ridge = 0
- Elastic Net = (0, 1)
- Lasso / Quantile = 1 (additional parameter `quantile` used to
specify quantile, not currently implemented)
- Penalty path
- Number of penalty values in the full penalty path (default = 20)
- Ratio of min(penalty) / max(penalty)
- User-defined set of penalties
- Regularization type
- Ridge = 0
- Elastic Net = (0, 1)
- Lasso / Quantile = 1 (additional parameter `quantile` used to
specify quantile, not currently implemented)
- Penalty path
- Number of penalty values in the full penalty path (default = 20)
- Ratio of min(penalty) / max(penalty)
- User-defined set of penalties

As an example, we may want to apply a ridge penalty to the x variables
and a lasso penalty to the external data variables. In addition, we may
want to have 30 penalty values computed for the regularization path
associated with both x and external. We modify our model call to `xrnet`
follows.

1. `penalty_main` is used to specify the regularization for the x
1) `penalty_main` is used to specify the regularization for the x
variables
2. `penalty_external` is used to specify the regularization for the
2) `penalty_external` is used to specify the regularization for the
external variables

``` r
Expand Down Expand Up @@ -247,8 +247,14 @@ xrnet_model_big <- xrnet(

all.equal(xrnet_model$beta0, xrnet_model_big$beta0)
#> [1] TRUE
```

``` r
all.equal(xrnet_model$betas, xrnet_model_big$betas)
#> [1] TRUE
```

``` r
all.equal(xrnet_model$alphas, xrnet_model_big$alphas)
#> [1] TRUE
```
Expand Down

0 comments on commit 30138bb

Please sign in to comment.