hmmsmooth:

Usage Arguments Examples

Usage

1
hmmsmooth(allpost, fmat, ks, sigma)

Arguments

allpost
fmat
ks
sigma

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (allpost, fmat, ks, sigma) 
{
    time1 = Sys.time()
    allpost[is.nan(allpost)] = 0
    allpost2 = allpost * 0
    post = allpost[, , dim(allpost)[3]]
    allpost2[, , dim(allpost)[3]] = post
    allpost2[, , 1] = allpost[, , 1]
    for (i in rev(2:dim(allpost)[3])) {
        if (fmat$behav[i] == 1) {
            sig = sigma[1]
            kern = ks[1]
        }
        else {
            sig = sigma[2]
            kern = ks[2]
        }
        print(i)
        post[is.nan(post)] = 0
        f = gausskern(kern, sig)
        f = f/sum(f)
        rat = filter2(allpost[, , i - 1], f)
        ratio = (allpost2[, , i]/(rat@.Data + 1e-20))
        S <- filter2(ratio, f)
        S <- S@.Data
        post = S * allpost[, , i - 1]
        allpost2[, , i - 1] = normalise(post)
    }
    print(Sys.time() - time1)
    allpost2
  }

galuardi/hmmwoa documentation built on May 16, 2019, 5:37 p.m.