qemiss_gr: qemiss_gr

Description Usage Arguments Value Examples

Description

qemiss_gr calculates the gradient of qemiss.

Usage

1
qemiss_gr(pars, X, E, L)

Arguments

pars

a vector of length 42. c(alpha, beta)

X

a list of vectors of observed states x

E

a vector of normalizing constant for each observed chain in X

L

a list of matrix L from computeL

Value

A vector of length 42, the gradient for qemiss.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
df <- uORF
X <- L <- list()
E <- c()
for (i in 1:2){
  X[[i]] <- df[[i]]$x
  RNA <- df[[i]]$RNA
  E[i]=df[[i]]$E;   trans=df[[i]]$trans;
  a=df[[i]]$v;      b=df[[i]]$v/df[[i]]$m
  la <- forwardAlg(X[[i]], RNA, trans, a, b, E[i])
  lb <- backwardAlg(X[[i]], RNA, trans, a, b, E[i])
  L[[i]] <- computeL(la, lb)
}
pars <- c(df[[1]]$v, df[[1]]$v/df[[1]]$m)

# check by comparing with numeric approximation
D1 <- qemiss_gr(pars,X,E,L)
require(numDeriv)
D2 <- grad(function(u) qemiss(u,X,E,L) , pars)
print(round(D1-D2, 10))

shimlab/riboHMM2 documentation built on May 19, 2019, 6:23 p.m.