gradient: Differential calculus

Description Usage Arguments Details Note Author(s) See Also Examples

Description

The gradient of the log-likelihood of a hyper2 object, at a specific point in probability space

Usage

1
gradient(H, probs)

Arguments

H

A hyper2 object

probs

A vector of probabilities

Details

Function gradient() returns the gradient of the log-likelihood function. If the hyper2 object is of size n, then argument probs must be a vector of length n-1.

Note

This functionality is peculiarly susceptible to off-by-one errors.

Author(s)

Robin K. S. Hankin

See Also

differentiate

Examples

1
2
3
4
5
6
7
8
data(chess)
p <- c(1/2,1/3)
delta <- rnorm(2)/1e5  # delta needs to be quite small

deltaL  <- lhyper2(chess,p+delta) - lhyper2(chess,p)
deltaLn <- sum(delta*gradient(chess,p + delta/2))   # numeric

deltaL - deltaLn  # should be small

hyper2 documentation built on July 6, 2017, 9:02 a.m.