alphak:

Usage Arguments Examples

View source: R/alphak.R

Usage

1

Arguments

tkx
Xijh
Y
Xquali

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
##---- 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 (tkx, Xijh, Y, Xquali) 
{
    alpha_k <- as.list(unique(Y))
    for (k in 1:length(alpha_k)) {
        variables <- as.list(seq_len(length(Xijh)))
        for (j in 1:length(variables)) {
            X <- vector("list", length(levels(Xquali[, j])))
            h_index <- 1
            for (h in sort(levels(Xquali[, j]))) {
                s <- 0
                for (i in 1:nrow(Xquali)) {
                  s <- s + tkx[i, k] * Xijh[[j]][i, -ncol(Xijh[[j]])][h_index]
                }
                X[[h_index]] <- s
                h_index <- h_index + 1
            }
            variables[[j]] <- data.frame(proba = unlist(X)/sum(unlist(X)))
        }
        alpha_k[[k]] <- variables
    }
    return(alpha_k)
  }

SaraTouzani/EM documentation built on Dec. 16, 2019, 12:31 a.m.