X-Git-Url: https://git.auder.net/?p=morpheus.git;a=blobdiff_plain;f=pkg%2Ftests%2Ftestthat%2Ftest-computeMu.R;fp=pkg%2Ftests%2Ftestthat%2Ftest-computeMu.R;h=ba1de74dcaf6fb657c5c0c6797256b5a7d6149cc;hp=fccef55fbfa3f49841a69ae575642b050d2eedd4;hb=2b3a6af5c55ac121405e3a8da721626ddf46b28b;hpb=2989133a738da99b78594cb00afdd3d87916b8bd diff --git a/pkg/tests/testthat/test-computeMu.R b/pkg/tests/testthat/test-computeMu.R index fccef55..ba1de74 100644 --- a/pkg/tests/testthat/test-computeMu.R +++ b/pkg/tests/testthat/test-computeMu.R @@ -2,22 +2,22 @@ context("computeMu") test_that("on input of sufficient size, β/||β|| is estimated accurately enough", { - n = 100000 - d = 2 - K = 2 - p = 1/2 + n <- 100000 + d <- 2 + K <- 2 + p <- 1/2 - βs_ref = array( c(1,0,0,1 , 1,-2,3,1), dim=c(d,K,2) ) + βs_ref <- array( c(1,0,0,1 , 1,-2,3,1), dim=c(d,K,2) ) for (i in 1:(dim(βs_ref)[3])) { - μ_ref = normalize(βs_ref[,,i]) - for (model in c("logit","probit")) + μ_ref <- normalize(βs_ref[,,i]) + for (link in c("logit","probit")) { - cat("\n\n",model," :\n",sep="") + cat("\n\n",link," :\n",sep="") - io = generateSampleIO(n, p, βs_ref[,,i], rep(0,K), model) - μ = computeMu(io$X, io$Y, list(K=K)) - μ_aligned = alignMatrices(list(μ), ref=μ_ref, ls_mode="exact")[[1]] + io <- generateSampleIO(n, p, βs_ref[,,i], rep(0,K), link) + μ <- computeMu(io$X, io$Y, list(K=K)) + μ_aligned <- alignMatrices(list(μ), ref=μ_ref, ls_mode="exact")[[1]] #Some traces: 0 is not well estimated, but others are OK cat("Reference normalized matrix:\n") @@ -25,7 +25,7 @@ test_that("on input of sufficient size, β/||β|| is estimated accurately enough cat("Estimated normalized matrix:\n") print(μ_aligned) cat("Difference norm (Matrix norm ||.||_1, max. abs. sum on a column)\n") - diff_norm = norm(μ_ref - μ_aligned) + diff_norm <- norm(μ_ref - μ_aligned) cat(diff_norm,"\n") #NOTE: 0.5 is loose threshold, but values around 0.3 are expected...