- if (verbose)
- print(paste("Parameters initialization for k =",k))
- #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)
- grid_lambda <- computeGridLambda(P$phiInit, P$rhoInit, P$piInit, P$gamInit, X, Y,
- gamma, mini, maxi, eps)
- # TODO: 100 = magic number
- if (length(grid_lambda)>100)
- grid_lambda = grid_lambda[seq(1, length(grid_lambda), length.out = 100)]
+ if (verbose)
+ print(paste("Parameters initialization for k =", k))
+ # 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, fast)
+ if (length(grid_lambda) == 0)
+ {
+ 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)
+ grid_lambda <- grid_lambda[seq(1, length(grid_lambda), length.out = size_coll_mod)]