From: Benjamin Auder Date: Sat, 18 Mar 2017 02:38:30 +0000 (+0100) Subject: Necessary changes to generate/run C tests. X-Git-Url: https://git.auder.net/variants/Chakart/img/current/css/assets/%7B%7B%20targetUrl%20%7D%7D?a=commitdiff_plain;h=f72201cc938d66d8a3bf71f990a34731305a0fa9;p=valse.git Necessary changes to generate/run C tests. WARNING: still problem with det(rho) in EMGLLF.R --- diff --git a/pkg/R/generateSampleInputs.R b/pkg/R/generateSampleInputs.R index 8edd031..7ec361f 100644 --- a/pkg/R/generateSampleInputs.R +++ b/pkg/R/generateSampleInputs.R @@ -1,10 +1,10 @@ #' Generate a sample of (X,Y) of size n -#' @param meanX matrix of group means for covariates (of size p) -#' @param covX covariance for covariates (of size p*p) -#' @param covY covariance for the response vector (of size m*m*K) -#' @param pi proportion for each cluster +#' @param meanX matrix of group means for covariates (p x K) +#' @param covX covariance for covariates (p x p x K) +#' @param covY covariance for the response vector (m x m x K) +#' @param pi proportion for each cluster #' @param beta regression matrix, of size p*m*k -#' @param n sample size +#' @param n sample size #' #' @return list with X and Y #' @export @@ -22,9 +22,7 @@ generateXY = function(meanX, covX, covY, pi, beta, n) for (i in 1:n) { class[i] = sample(1:k, 1, prob=pi) - X[i,] = mvrnorm(1, meanX, covX) - print(X[i,]) - print(beta[,,class[i]]) + X[i,] = mvrnorm(1, meanX[,class[i]], covX[,,class[i]]) Y[i,] = mvrnorm(1, X[i,] %*% beta[,,class[i]], covY[,,class[i]]) } diff --git a/reports/essai16mars.R b/reports/essai16mars.R index 88659ab..59bbb53 100644 --- a/reports/essai16mars.R +++ b/reports/essai16mars.R @@ -3,8 +3,13 @@ q = 8 k = 2 D = 20 -meanX = rep(0,p) -covX = 0.1*diag(p) +meanX = matrix(nrow=p,ncol=k) +meanX[,1] = rep(0,p) +meanX[,2] = rep(1,p) + +covX = array(dim=c(p,p,k)) +covX[,,1] = 0.1*diag(p) +covX[,,2] = 0.5*diag(p) covY = array(dim = c(q,q,k)) covY[,,1] = 0.1*diag(q) diff --git a/test/generate_test_data/EMGLLF.R b/test/generate_test_data/EMGLLF.R index 41eb7cf..fc3220f 100644 --- a/test/generate_test_data/EMGLLF.R +++ b/test/generate_test_data/EMGLLF.R @@ -128,7 +128,7 @@ EMGLLF_R = function(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,ta sumLLF1 = 0.0; for (r in 1:k) { - Gam[i,r] = pi[r] * exp(-0.5*sqNorm2[r])* det(rho[,,r]) + Gam[i,r] = pi[r] * exp(-0.5*sqNorm2[r]) #* det(rho[,,r]) #FIXME: still issues here ?!?! sumLLF1 = sumLLF1 + Gam[i,r] / (2*base::pi)^(m/2) } sumLogLLF2 = sumLogLLF2 + log(sumLLF1)