From: devijvee Date: Sat, 14 Mar 2020 17:31:27 +0000 (+0100) Subject: update Emilie X-Git-Url: https://git.auder.net/js/doc/%7B%7B%20asset%28%27mixstore/css/base.css%27%29%20%7D%7D?a=commitdiff_plain;h=8b28401096c8f1b95a4d83b34b47548ae1b2a425;p=valse.git update Emilie --- diff --git a/TODO b/TODO index d9f02eb..c662bec 100644 --- a/TODO +++ b/TODO @@ -1,12 +1,18 @@ -n = 100; m = 70; p = 5 +n = 50; m = 10; p = 5 X = matrix(runif(n*p, -10, 10), nrow=n) Y = matrix(runif(n*m, -5, 15), nrow=n) - -V1 = valse::valse(X, Y, fast=FALSE) +beta = array(0, dim=c(p,m,2)) +beta[,,1] = 1 +beta[,,2] = 2 +data = generateXY(n, c(0.4,0.6), rep(0,p), beta, diag(0.5, p), diag(0.5, m)) +X = data$X +Y = data$Y +class = data$class +V1 = runValse(X, Y, fast=FALSE) Error in while (!pi2AllPositive) { : missing value where TRUE/FALSE needed -V2 = valse::valse(X, Y, fast=TRUE) +V2 = runValse(X, Y, fast=TRUE) list() Error in out[[ind_uniq[l]]] : attempt to select less than one element in get1index diff --git a/pkg/R/generateXY.R b/pkg/R/generateXY.R index d2e00ef..fde4b0f 100644 --- a/pkg/R/generateXY.R +++ b/pkg/R/generateXY.R @@ -3,26 +3,26 @@ #' Generate a sample of (X,Y) of size n #' #' @param n sample size -#' @param p proportion for each cluster +#' @param prop proportion for each cluster #' @param meanX matrix of group means for covariates (of size p) #' @param covX covariance for covariates (of size p*p) #' @param beta regression matrix, of size p*m*k -#' @param covY covariance for the response vector (of size m*m*K) +#' @param covY covariance for the response vector (of size m*m) #' #' @return list with X and Y #' #' @export -generateXY <- function(n, p, meanX, beta, covX, covY) +generateXY <- function(n, prop, meanX, beta, covX, covY) { p <- dim(covX)[1] m <- dim(covY)[1] - k <- dim(covY)[3] + k <- dim(beta)[3] X <- matrix(nrow = 0, ncol = p) Y <- matrix(nrow = 0, ncol = m) # random generation of the size of each population in X~Y (unordered) - sizePop <- stats::rmultinom(1, n, p) + sizePop <- stats::rmultinom(1, n, prop) class <- c() #map i in 1:n --> index of class in 1:k for (i in 1:k) @@ -31,7 +31,7 @@ generateXY <- function(n, p, meanX, beta, covX, covY) newBlockX <- MASS::mvrnorm(sizePop[i], meanX, covX) X <- rbind(X, newBlockX) Y <- rbind(Y, t(apply(newBlockX, 1, function(row) MASS::mvrnorm(1, row %*% - beta[, , i], covY[, , i])))) + beta[, , i], covY[,])))) } shuffle <- sample(n)