File: condLogLikDerDelta.R

package info (click to toggle)
r-bioc-edger 3.40.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,484 kB
  • sloc: cpp: 1,425; ansic: 1,109; sh: 21; makefile: 5
file content (22 lines) | stat: -rw-r--r-- 741 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
condLogLikDerDelta <- function(y,delta,der=1L)
# Derivatives of log-likelihood function wrt to delta
# r=1/dispersion and delta=1/(1+r)=dispersion/(1+dispersion)
# der is order of derivative required (0th deriv is the function)
# Written by Mark Robinson, edited by Davis McCarthy, February 2009
{
#	Vector interpreted as matrix of one row, i.e., one gene
	if (is.vector(y)) {
		y <- matrix(y,nrow=1)
	} else {
		y <- as.matrix(y)
	}
	if( !(length(delta)==1 | length(delta)==nrow(y)) ) stop("delta must be of length 1 or nrow(y)")

	r <- (1/delta)-1
	switch(der+1L,
		condLogLikDerSize(y,r,der=0L),
		condLogLikDerSize(y,r,der=1L)*(-delta^(-2)),
		condLogLikDerSize(y,r,der=1L)*2*(delta^(-3))+condLogLikDerSize(y,r,der=2)*(delta^(-4))
	)
}