A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/braunm/sparseHessianFD/ below:

braunm/sparseHessianFD: R package for estimate sparse Hessians

title output

The sparseHessianFD package

md_document variant

markdown_github

Why use the sparseHessianFD package?

Suppose you have a scalar-valued objective function of N variables. You have an R function that returns the function value, and another that returns the gradient. You still need the Hessian, which would be hard to derive analytically, and translate into an R function. If N is very large, it can take a long time to estimate the Hessian numerically, and a lot of memory to store all N^2 elements.

This scalability problem comes up in at least two areas of statistics:

  1. using derivative-based algorithms for nonlinear optimization; and
  2. sampling from, and estimating the density of, high-dimensional multivariate normal distributions.

The sparseHessianFD package solves this problem when the Hessian is sparse, and the sparsity pattern is known in advance. The sparsity pattern is just the row and column indices of the non-zero elements in the lower triangle of the Hessian. Sparse Hessians arise, for example, in hierarchical models in which parameters are conditionally independent across heterogeneous units. In that case, we know which cross-partial derivatives are zero.

See the vignette for more about sparsity patterns in Hessians.

The package is available on CRAN, so a simple

install.packages("sparseHessianFD")

should suffice. The package is being developed on Github and you can get development branches there.

To use the package, you need at least the following:

The sparseHessianFD function returns an object of class sparseHessianFD. This class contains methods to return the function value, gradient and Hessian. The Hessian is returned in a sparse, compressed format as a dgCMatrix object (defined in the Matrix package).

A typical usage might look like this.

P <- rnorm(N) ## random "starting value" for initialization
obj <- sparseHessianFD(P, f, df, rows, cols)
X <- rnorm(N) ## another set of variables at which the function is evaluated
val <- obj$fn(X) ## function value
gr <- obj$gr(X) ## gradient
hess <- obj$hessian(X)  ## Hessian, as a sparse dgCMatrix object

See the vignette and reference pages for more details, options, convenience functions, etc.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4