X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=R%2FbasicInitParameters.R;h=980122924725ba3dfed07747c77022ce52cdcd67;hb=d1531659214edd6eaef0ac9ec835455614bba16c;hp=b70edab719936405469463d78996f82c41436ec4;hpb=493a35bfea6d1210c94ced8fbfe3e572f0389ea5;p=valse.git diff --git a/R/basicInitParameters.R b/R/basicInitParameters.R index b70edab..9801229 100644 --- a/R/basicInitParameters.R +++ b/R/basicInitParameters.R @@ -1,29 +1,28 @@ -basic_Init_Parameters = function(n,p,m,k){ +#----------------------------------------------------------------------- +#' Initialize the parameters in a basic way (zero for the conditional mean, +#' uniform for weights, identity for covariance matrices, and uniformly distributed forthe clustering) +#' @param n sample size +#' @param p number of covariates +#' @param m size of the response +#' @param k number of clusters +#' @return list with phiInit, rhoInit,piInit,gamInit +#' @export +#----------------------------------------------------------------------- +basic_Init_Parameters = function(n,p,m,k) +{ phiInit = array(0, dim=c(p,m,k)) - piInit = (1.0/k)*rep.int(1,k) + piInit = (1./k)*rep.int(1,k) rhoInit = array(0, dim=c(m,m,k)) - - for(i in 1:k){ + for(i in 1:k) rhoInit[,,i] = diag(m) - } gamInit = 0.1*array(1, dim=c(n,k)) - - R = sample(1:k,n, replace= TRUE) - - for(i in 1:n){ + R = sample(1:k,n, replace=TRUE) + for(i in 1:n) gamInit[i,R[i]] = 0.9 - } gamInit = gamInit/sum(gamInit[1,]) - - return(list(phiInit, rhoInit, piInit, gamInit)) + return (data = list(phiInit = phiInit, rhoInit = rhoInit, piInit = piInit, gamInit = gamInit)) } - -n= 10 -p = 10 -m = 5 -k = 5 -list_param = basic_Init_Parameters(n,p,m,k)