X-Git-Url: https://git.auder.net/?p=valse.git;a=blobdiff_plain;f=R%2FindicesSelection.R;h=7835430f3ad8c763d7c18b830fdb0f070ee0b6e8;hp=1adece69d2a0174381b171be02be06be739bc0cf;hb=e166ed4e1370aa7961f0d8609936591cfc6808cc;hpb=0b216f854a21821f9be375d07c2932b31e227e78 diff --git a/R/indicesSelection.R b/R/indicesSelection.R index 1adece6..7835430 100644 --- a/R/indicesSelection.R +++ b/R/indicesSelection.R @@ -4,33 +4,33 @@ #' @param thresh threshold to say a cofficient is equal to zero #' #' @return a list with A, a matrix with relevant indices (size = p*m) and B, a -#' matrix with irrelevant indices (size = p*m) +#' matrix with irrelevant indices (size = p*m) #' @export indicesSelection = function(phi, thresh = 1e-6) { - dim_phi = dim(phi) - p = dim_phi[1] - m = dim_phi[2] - - A = matrix(0, p, m) - B = matrix(0, p, m) - - for(j in 1:p) - { - cpt1 = 0 - cpt2 = 0 - for(mm in 1:m) - { - if(max(phi[j,mm,]) > thresh) - { - cpt1 = cpt1 + 1 - A[j,cpt] = mm - } else - { - cpt2 = cpt2+1 - B[j, cpt2] = mm - } - } - } - return (list(A=A,B=B)) + dim_phi = dim(phi) + p = dim_phi[1] + m = dim_phi[2] + + A = matrix(0, p, m) + B = matrix(0, p, m) + + for(j in 1:p) + { + cpt1 = 0 + cpt2 = 0 + for(mm in 1:m) + { + if(max(phi[j,mm,]) > thresh) + { + cpt1 = cpt1 + 1 + A[j,cpt] = mm + } else + { + cpt2 = cpt2+1 + B[j, cpt2] = mm + } + } + } + return (list(A=A,B=B)) }