hmmfilter:

Usage Arguments Examples

Usage

1
hmmfilter(sstL, fmat, ks = 29, sigma = 1)

Arguments

sstL
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
##---- 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 (sstL, fmat, ks = 29, sigma = 1) 
{
    allpost = sstL[[3]] * NaN
    lon = L$lon
    lat = L$lat
    xidx = which.min((fmat[1, 8] - (lon))^2)
    yidx = which.min((fmat[1, 9] - lat)^2)
    allpost[xidx, yidx, 1] = 1
    len = nrow(fmat)
    xidx = which.min((fmat[len, 8] - (lon))^2)
    yidx = which.min((fmat[len, 9] - lat)^2)
    allpost[xidx, yidx, len] = 1
    post = allpost[, , 1]
    post[is.nan(post)] = 0
    datediff = c(1, diff(as.numeric(mdy.date(fmat[, 2], fmat[, 
        3], fmat[, 1]))))
    f = gausskern(ks[1], sigma[1])
    f = f/sum(f)
    post = Image(post)
    P <- filter2(post, f)
    post = P@.Data
    post = normalise(post)
    normaliser = numeric(nrow(fmat) - 1) + 1
    time1 = Sys.time()
    for (i in 2:(nrow(fmat) - 1)) {
        print(i)
        if (fmat$behav[i - 1] == 1) {
            sig = sigma[1]
            kern = ks[1]
        }
        else {
            sig = sigma[2]
            kern = ks[2]
        }
        post[is.nan(post)] = 0
        f = gausskern(kern, sig)
        f = f/sum(f)
        P <- filter2(post, f)
        P = P@.Data
        post = P * sstL[[3]][, , i]
        normaliser[i - 1] = sum(post, na.rm = T)
        post = normalise(post)
        allpost[, , i] = post
    }
    print(Sys.time() - time1)
    allpost
  }

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