qemiss2: qemiss2

Description Usage Arguments Value Examples

Description

qemiss2 is the emission part of the Q function in E-step, i.e.: Sum_i,t,k log[fk(x_t)] * L^i_k(t). (with negative sign). qemiss2 calculates the target function for each k instead of all k.

Usage

1
qemiss2(pars, X, E, L, k)

Arguments

pars

a vector of length 2. c(alpha[k], beta[k])

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

k

a scalar indicating which state is calculated

Value

A scalar, the (negative) value of the target function that would later be minimized.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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)

qe <- 0
for (k in 1:21){
  qe <- qe + qemiss2(pars[c(k,21+k)],X,E,L,k)
}
print(qe)
print(qemiss(pars,X,E,L))

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