Giter Club home page Giter Club logo

relgam's Introduction

CRAN status CRAN_Download_Badge

relgam

relgam is a package implementing Reluctant Generalized Additive Modeling (RGAM), a new technique for fitting sparse generalized additive models (GAMs). RGAMs are computationally scalable and work with continuous, binary, count and survival data. For the mathematical details, please see the preprint. For a short tutorial on how to use the package, please see the vignette on CRAN.

At a high level, RGAM is fit in the following way: letting y denote the response variable and X denote the design matrix,

  1. Fit the lasso of y on X using the glmnet package. Compute the residuals r at the lambda hyperparameter selected by cross-validation.
  2. For each of the original features, fit a smoothing spline with d degrees of freedom of r on the feature to get a new, non-linear feature. Let F denote the matrix of new features.
  3. Fit the lasso of y on X and F using the glmnet package.

Updates on top of the CRAN version

This section lists the updates that we have since the CRAN version of the package. This development version is v1.1.

  • Made Step 2 more generic. Previously Step 2 was restricted to fitting a degree smoothing spline with d degrees of freedom of r on each original feature. Now, the user can specify the univariate fitting method for Step 2 using the new nl_maker option in rgam(). Additional arguments for the nl_maker function can be passed to rgam() as well: they are passed down to nl_maker via the .... The default fitting function is the smoothing spline with d degrees of freedom (as before).
  • Added basic tests.
  • Simplified code for plot.rgam().
  • Fixed bug in getf() (some issue with standardization of variables when computing the non-linear component).

An example

Here is a simple example to illustrate how to use this package. First, let’s generate some data:

set.seed(1)
n <- 100; p <- 12
x = matrix(rnorm((n) * p), ncol = p)
f4 = 2 * x[,4]^2 + 4 * x[,4] - 2
f5 = -2 * x[, 5]^2 + 2
f6 = 0.5 * x[, 6]^3
mu = rowSums(x[, 1:3]) + f4 + f5 + f6
y = mu + sqrt(var(mu) / 4) * rnorm(n)

We can fit an RGAM using the rgam() function:

library(relgam)
fit <- rgam(x, y, verbose = FALSE)
#  init_nz not specified: setting to default (all features)
#  using default value of gamma for RGAM: 0.6

(If verbose = TRUE (default), model-fitting is tracked with a progress bar in the console.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.