Commit | Line | Data |
---|---|---|
d1531659 | 1 | #' Among a collection of models, this function constructs a subcollection of models with |
ef67d338 | 2 | #' models having strictly different dimensions, keeping the model which minimizes |
d1531659 | 3 | #' the likelihood if there were several with the same dimension |
4 | #' | |
5 | #' @param LLF a matrix, the first column corresponds to likelihoods for several models | |
e166ed4e | 6 | #' the second column corresponds to the dimensions of the corresponding models. |
d1531659 | 7 | #' |
ef67d338 | 8 | #' @return a list with indices, a vector of indices selected models, |
e166ed4e | 9 | #' and D1, a vector of corresponding dimensions |
d1531659 | 10 | #' @export |
11 | #' | |
d1531659 | 12 | modelSelection = function(LLF) |
13 | { | |
e166ed4e BA |
14 | D = LLF[,2] |
15 | D1 = unique(D) | |
16 | ||
17 | indices = rep(1, length(D1)) | |
18 | #select argmax MLE | |
19 | if (length(D1)>2) | |
20 | { | |
21 | for (i in 1:length(D1)) | |
22 | { | |
23 | A = c() | |
24 | for (j in 1:length(D)) | |
25 | { | |
26 | if(D[[j]]==D1[[i]]) | |
27 | a = c(a, LLF[j,1]) | |
28 | } | |
29 | b = max(a) | |
30 | #indices[i] : first indices of the binary vector where u_i ==1 | |
c3bc4705 | 31 | indices[i] = which.max(LLF == b) |
e166ed4e BA |
32 | } |
33 | } | |
34 | ||
35 | return (list(indices=indices,D1=D1)) | |
d1531659 | 36 | } |
ef67d338 BA |
37 | |
38 | #TODO: | |
39 | ## Programme qui sélectionne un modèle | |
40 | ## proposer à l'utilisation différents critères (BIC, AIC, slope heuristic) |