From 7defe6fb042cf3d4b912ecdf9d7342b68536a6ea Mon Sep 17 00:00:00 2001 From: Said el Bouhaddani Date: Tue, 20 Feb 2024 16:28:13 +0100 Subject: [PATCH] Update PO2PLS_gen3.R --- R/PO2PLS_gen3.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/R/PO2PLS_gen3.R b/R/PO2PLS_gen3.R index 3845942..426c532 100644 --- a/R/PO2PLS_gen3.R +++ b/R/PO2PLS_gen3.R @@ -34,7 +34,7 @@ gen_par3 <- function(p1, p2, p3, r, rx1, rx2, rx3, alpha = 0.1){ ) } -gen_dat3 <- function(N, params, alpha_out = 0.1){ +gen_dat3 <- function(N, params, alpha_out = 0.1, sparse = FALSE){ W1 <- params$W1 W2 <- params$W2 W3 <- params$W3 @@ -50,6 +50,13 @@ gen_dat3 <- function(N, params, alpha_out = 0.1){ p2 <- nrow(W2) p3 <- nrow(W3) + if(sparse){ + W1[-(1:(p1/4)),] <- 0 + W2[-(1:(p2/4)),] <- 0 + W3[-(1:(p3/4)),] <- 0 + } + # print(W1) + SigT = params$SigT SigTo1 = params$SigTo1 + 1e-06 * SigT[1] * (params$SigTo1[1] == 0) SigTo2 = params$SigTo2 + 1e-06 * SigT[1] * (params$SigTo2[1] == 0) @@ -93,7 +100,7 @@ gen_dat3 <- function(N, params, alpha_out = 0.1){ # prm <- gen_par3(10, 11, 12, 2, 1, 1, 1, alpha = 0.1) -# dat <- gen_dat3(100, prm) +# dat <- gen_dat3(100, prm, sparse = TRUE)