Learn R Programming

ADtools (version 0.5.4)

Automatic Differentiation Toolbox

Description

Implements the forward-mode automatic differentiation for multivariate functions using the matrix-calculus notation from Magnus and Neudecker (2019) . Two key features of the package are: (i) it incorporates various optimisation strategies to improve performance; this includes applying memoisation to cut down object construction time, using sparse matrix representation to speed up derivative calculation, and creating specialised matrix operations to reduce computation time; (ii) it supports differentiating random variates with respect to their parameters, targeting Markov chain Monte Carlo (MCMC) and general simulation-based applications.

Copy Link

Version

Install

install.packages('ADtools')

Monthly Downloads

10

Version

0.5.4

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Chun Fung Kwok

Last Published

November 9th, 2020

Functions in ADtools (0.5.4)

Diagonal

Diagonal matrix
IxCD

Compute (I %x% C) D
dWishart0

The density of the Wishart distribution
-,dual,missing-method

Subtraction of 'dual'-class objects (unary dual)
dmvnorm0

The density of the multivariate normal distribution
crossprod,dual,missing-method

Crossproduct of 'dual'-class objects
-,dual,dual-method

Subtraction of 'dual'-class objects (dual-dual)
dmvt0

The density of the multivariate t distribution
AIxC

Compute A (I %x% C)
%*%,dual,dual-method

Matrix multiplication of 'dual'-class objects (dual-dual)
head.dual

Return the First or Last Part of an Object
Diagonal0

Diagonal matrix (memoised)
%*%,ANY,dual-method

Matrix multiplication of 'dual'-class objects (ANY-dual)
log,dual-method

Element-wise logarithm of a dual object
add_vector_to_matrix_row

Add a column vector to each row of a matrix
dgamma0

The density of the gamma distribution
add_vector_to_matrix_column

Add a column vector to each column of a matrix
-,ANY,dual-method

Subtraction of 'dual'-class objects (dual-ANY)
nrow,dual-method

Number of rows
kronecker,ANY,dual-method

Kronecker multiplication of 'dual'-class objects (ANY-dual)
inverse_transform

Simulation by inverse transform
^,dual,dual-method

Powers of 'dual'-class objects (dual-dual)
colSums,dual-method

Column sum of a matrix.
rmvnorm0

Simulate multivariate normal random variates
^,dual,ANY-method

Powers of 'dual'-class objects (dual-ANY)
rchisq0,numeric,dual-method

Simulate Chi-square random variates
one_matrix

Matrix of ones
as.matrix.dual

Coerce the first component of the dual object into a matrix.
chol0

Cholesky decomposition
colMeans,dual-method

Column mean of a matrix.
as.vector,dual-method

Coerce the first component of the dual object into a vector.
mcm_optimal_order

Find the optimal order of multiplying a matrix chain
diag.dual

Diagonal matrix
rowSums,dual-method

Row sum of a matrix.
rchisq0

Simulate Chi-square random variates
/,dual,dual-method

(Element-wise) Division of 'dual'-class objects (dual-dual)
solve,dual,missing-method

Inverse of 'dual'-class objects
matrix

Matrices
auto_diff

Automatic differentiation
/,dual,ANY-method

(Element-wise) Division of 'dual'-class objects (dual-ANY)
commutation_matrix

Commutation matrix
det.dual

Determinant of a 'dual'-class object
rbind2,dual,dual-method

Combine 'dual'-class objects by Rows (dual-dual)
sqrt,dual-method

Element-wise square-root of a dual object
%*%,dual,ANY-method

Matrix multiplication of 'dual'-class objects (dual-ANY)
rgamma0

Simulate gamma random variates
dexp0

The density of the exponential distribution
cbind2,dual,ANY-method

Combine 'dual'-class objects by Columns (dual-ANY)
XBxA

Pre-multiplying a kronecker product
dnorm0

The density of the normal distribution
sum,dual-method

Sum of matrix elements
det,dual-method

Determinant of a 'dual'-class object
band_matrix

Band matrix
duals

Converting a list of parameters into a list of dual numbers
cbind2,dual,dual-method

Combine 'dual'-class objects by Columns (dual-dual)
commutation_matrix0

Commutation matrix (memoised)
rnorm0

Simulate univariate normal random variates
chol,dual-method

Cholesky decomposition of 'dual'-class objects
rmvnorm0_dual

Simulate multivariate normal random variates
matrix.dual

Coerce the first component of the dual object into a matrix.
cos,dual-method

Element-wise cosine of a dual object
dim,dual-method

Dimension of an Object
dchisq0

The density of the chi-squared distribution
vech

Half-vectorisation
rWishart0,dual,dual-method

Simulating from Wishart distribution using Bartlett decomposition
dt0

The density of the student-t distribution
dual

Dual number constructor
t.dual

Transpose of 'dual'-class objects
matrix_prod

Interface for optimal matrix chain multiplication
length,dual-method

Length of an Object
matrix_determinant

Determinant of a matrix
chol0,dual-method

Cholesky decomposition of 'dual'-class objects
finite_diff

Finite difference method
exp,dual-method

Element-wise exponential of a dual object
rWishart0

Simulate Wishart random variates
rt0

Simulate random variates from the student-t distribution
zero_matrix

Matrix of zeroes
^,ANY,dual-method

Powers of 'dual'-class objects (ANY-dual)
+,dual,dual-method

Addition of 'dual'-class objects (dual-dual)
randn

Generate a matrix randomly from a normal distribution
tan,dual-method

Element-wise tangent of a dual object
gamma,dual-method

Element-wise gamma of a dual object
elimination_matrix

Elimination matrix
randu

Generate a matrix randomly from a uniform distribution
dual-class

S4 class "dual"
dinvWishart0

The density of the inverse Wishart distribution
upper_tri_matrix

Construct an upper triangular matrix from a vector
init_dx

Initialise the dual component
zero_matrix0

Matrix of zeroes (memoised)
round,dual,integer-method

Rounding of Numbers
tcrossprod,dual,ANY-method

Crossproduct of 'dual'-class objects
rexp0,numeric,dual-method

Simulate exponential random variates
-,dual,ANY-method

Subtraction of 'dual'-class objects (dual-ANY)
Extract.dual

Extract parts of an object
elimination_matrix0

Elimination matrix (memoised)
rexp0

Simulate exponential random variates
lower_tri_matrix

Construct a lower triangular matrix from a vector
mean,dual-method

Mean of vector or matrix elements
ncol,dual-method

Number of columns
vec

Vectorisation
rbind2,ANY,dual-method

Combine 'dual'-class objects by Rows (ANY-dual)
*,dual,ANY-method

(Element-wise) Multiplication of 'dual'-class objects (dual-ANY)
+,ANY,dual-method

Addition of 'dual'-class objects (ANY-dual)
rgamma0,numeric,dual,dual-method

Simulate gamma random variates
vec,dual-method

Vectorisation
kronecker,dual,ANY-method

Kronecker multiplication of 'dual'-class objects (dual-ANY)
/,ANY,dual-method

(Element-wise) Division of 'dual'-class objects (ANY-dual)
*,dual,dual-method

(Element-wise) Multiplication of 'dual'-class objects (dual-dual)
one_matrix0

Matrix of ones (memoised)
kronecker,dual,dual-method

Kronecker product of 'dual'-class objects (dual-dual)
rbind2,dual,ANY-method

Combine 'dual'-class objects by Rows (dual-ANY)
+,dual,ANY-method

Addition of 'dual'-class objects (dual-ANY)
rt0,numeric,dual-method

Simulate random variates from the student-t distribution
optim_prod

Executing the matrix multiplication given the optimal order
rmvt0

Simulate random variates from the multivariate t distribution
rowMeans,dual-method

Row mean of a matrix.
round.dual

Rounding of Numbers
tidy_dx

Add rownames and colnames to the dual component
sin,dual-method

Element-wise sine of a dual object
tr,dual-method

Trace of a matrix
tail.dual

Return the First or Last Part of an Object
*,ANY,dual-method

(Element-wise) Multiplication of 'dual'-class objects (ANY-dual)
tr

Trace of a matrix
vech,dual-method

Half-vectorisation
ABxI

Compute A (B %x% I)
BxID

Compute (B %x% I) D
BxAZ

Post-multiplying a kronecker product
ADtools-package

ADtools: Automatic Differentiation
band_matrix0

Band matrix (memoised)
cbind2,ANY,dual-method

Combine 'dual'-class objects by Columns (ANY-dual)