X-Git-Url: https://git.auder.net/?p=valse.git;a=blobdiff_plain;f=pkg%2FR%2Fmain.R;h=e741d65f4ed3b43037dc8978a96f20e76cda0523;hp=64e058629859e8b1442e5a1110a2eb8670b554bf;hb=ea5860f1b4fc91f06e371a0b26915198474a849d;hpb=1b698c1619dbcf5b3a0608dc894d249945d2bce3 diff --git a/pkg/R/main.R b/pkg/R/main.R index 64e0586..e741d65 100644 --- a/pkg/R/main.R +++ b/pkg/R/main.R @@ -31,9 +31,9 @@ valse <- function(X, Y, procedure = "LassoMLE", selecMod = "DDSE", gamma = 1, mi ncores_inner = 1, thresh = 1e-08, size_coll_mod = 10, fast = TRUE, verbose = FALSE, plot = TRUE) { - p <- dim(X)[2] - m <- dim(Y)[2] - n <- dim(X)[1] + n <- nrow(X) + p <- ncol(X) + m <- ncol(Y) if (verbose) print("main loop: over all k and all lambda") @@ -57,7 +57,7 @@ valse <- function(X, Y, procedure = "LassoMLE", selecMod = "DDSE", gamma = 1, mi # smallEM initializes parameters by k-means and regression model in each # component, doing this 20 times, and keeping the values maximizing the # likelihood after 10 iterations of the EM algorithm. - P <- initSmallEM(k, X, Y) + P <- initSmallEM(k, X, Y, fast) grid_lambda <- computeGridLambda(P$phiInit, P$rhoInit, P$piInit, P$gamInit, X, Y, gamma, mini, maxi, eps, fast) if (length(grid_lambda) > size_coll_mod) @@ -138,7 +138,7 @@ valse <- function(X, Y, procedure = "LassoMLE", selecMod = "DDSE", gamma = 1, mi for (r in 1:length(modelSel$pi)) { sqNorm2 <- sum((Y[i, ] %*% modelSel$rho[, , r] - X[i, ] %*% modelSel$phi[, , r])^2) - Gam[i, r] <- modelSel$pi[r] * exp(-0.5 * sqNorm2) * det(modelSel$rho[, , r]) + Gam[i, r] <- modelSel$pi[r] * exp(-0.5 * sqNorm2) * gdet(modelSel$rho[, , r]) } } Gam <- Gam/rowSums(Gam)