Diff of /classnb.R [000000] .. [81de4e]

Switch to unified view

a b/classnb.R
1
classnb <- function (x, y, xte = NULL, beta = 1,  type = c("mle", 
2
    "deseq", "quantile"), prior = NULL) 
3
{
4
5
    if (is.null(prior)) 
6
        prior <- rep(1/length(unique(y)), length(unique(y)))
7
8
    null.out <- NullModel(x, type = type)
9
    ns <- null.out$n
10
    nste <- NullModelTest(null.out, x, xte, type = type)$nste
11
12
    uniq <- sort(unique(y))
13
14
        ds <- GetDnb(ns, x, y, beta)
15
16
        #disperhat=rep(truephi,ncol(nste))
17
        phihat <- as.numeric(disperhat)
18
        discriminant <- matrix(NA, nrow = nrow(xte), ncol = length(uniq))
19
20
        for (k in 1:length(uniq)) {
21
22
            for(l in 1:nrow(xte))   {
23
24
                 dstar = ds[k,]
25
                 part2=1+nste[l,]*dstar*phihat 
26
                 part1=dstar/part2 
27
28
                 discriminant[l, k]<- sum(xte[l,]*log(part1))-sum((1/phihat)*log(part2))+log(prior[k])
29
30
             }
31
         }
32
        save <- list(ns = ns, nste = nste, ds = ds, discriminant = discriminant, 
33
            ytehat = uniq[apply(discriminant, 1, which.max)], 
34
            x = x, y = y, xte = xte, 
35
            type = type)
36
37
        return(save)
38
39
}
40
41
42
43