Learn R Programming

xactonomial (version 1.0.3)

calc_prob_null_gradient: Gradient of the multinomial likelihood sum

Description

Gradient of the multinomial likelihood sum

Usage

calc_prob_null_gradient(theta_cands, SSpacearr, II)

Value

A matrix the same dimension as theta_cands

Arguments

theta_cands

A matrix with samples in the rows and the parameters in the columns

SSpacearr

A matrix with the sample space for the given size of the problem

II

logical vector of sample space psi being more extreme than the observed psi

Examples

Run this code
calc_prob_null_gradient(t(c(.28, .32, .4)),
matrix(c(2, 2, 1, 1, 2, 2, 0, 3, 2), ncol = 3),
rep(TRUE, 3))

# numerically
testenv <- new.env()
testenv$SSpacearr <- matrix(c(2, 2, 1, 1, 2, 2, 0, 3, 2), ncol = 3)
testenv$thistheta <- c(.28, .32, .4)
numericDeriv(quote(sum(exp((.colSums(t(SSpacearr) * log(thistheta), m = 3, n = 3))))),
    theta = "thistheta", rho = testenv, central = TRUE)


Run the code above in your browser using DataLab