Running ‘andersondarling_behaviour.r’ [0s/0s]
  Running ‘andersondarling_correctness.r’ [1s/1s]
  Running ‘andersondarling_errors.r’ [0s/0s]
  Running ‘andersondarling_warnings.r’ [0s/0s]
  Running ‘bartlett_behaviour.r’ [0s/0s]
  Running ‘bartlett_correctness.r’ [2s/3s]
  Running ‘bartlett_errors.r’ [0s/0s]
  Running ‘bartlett_warnings.r’ [0s/0s]
  Running ‘brownforsythe_behaviour.r’ [0s/0s]
  Running ‘brownforsythe_correctness.r’ [7s/8s]
  Running ‘brownforsythe_errors.r’ [0s/0s]
  Running ‘brownforsythe_warnings.r’ [0s/0s]
  Running ‘cor_pearson_behaviour.r’ [0s/0s]
  Running ‘cor_pearson_correctness.r’ [1s/1s]
  Running ‘cor_pearson_errors.r’ [0s/0s]
  Running ‘cor_pearson_warnings.r’ [0s/0s]
  Running ‘cosinor_behaviour.r’ [0s/0s]
  Running ‘cosinor_correctness.r’ [15s/18s]
  Running ‘cosinor_errors.r’ [0s/1s]
  Running ‘cosinor_warnings.r’ [0s/0s]
  Running ‘f_var_behaviour.r’ [0s/0s]
  Running ‘f_var_correctness.r’ [1s/1s]
  Running ‘f_var_errors.r’ [0s/0s]
  Running ‘f_var_warnings.r’ [0s/1s]
  Running ‘flignerkilleen_behaviour.r’ [0s/0s]
  Running ‘flignerkilleen_correctness.r’ [2s/3s]
  Running ‘flignerkilleen_errors.r’ [0s/0s]
  Running ‘flignerkilleen_warnings.r’ [0s/0s]
  Running ‘jarquebera_behaviour.r’ [0s/0s]
  Running ‘jarquebera_correctness.r’ [1s/1s]
  Running ‘jarquebera_errors.r’ [0s/1s]
  Running ‘jarquebera_warnings.r’ [0s/0s]
  Running ‘kolmogorovsmirnov_twosample_behavioiur.r’ [0s/1s]
  Running ‘kolmogorovsmirnov_twosample_correctness.r’ [5s/6s]
  Running ‘kolmogorovsmirnov_twosample_errors.r’ [0s/0s]
  Running ‘kolmogorovsmirnov_twosample_warnings.r’ [0s/0s]
  Running ‘kruskalwallis_behaviour.r’ [0s/0s]
  Running ‘kruskalwallis_correctness.r’ [2s/3s]
  Running ‘kruskalwallis_errors.r’ [0s/0s]
  Running ‘kruskalwallis_warnings.r’ [0s/0s]
  Running ‘levene_behaviour.r’ [0s/0s]
  Running ‘levene_correctness.r’ [7s/10s]
  Running ‘levene_errors.r’ [0s/0s]
  Running ‘levene_warnings.r’ [0s/0s]
  Running ‘oneway_equalvar_behaviour.r’ [0s/0s]
  Running ‘oneway_equalvar_correctness.r’ [4s/5s]
  Running ‘oneway_equalvar_errors.r’ [0s/0s]
  Running ‘oneway_equalvar_warnings.r’ [0s/0s]
  Running ‘oneway_welch_behaviour.r’ [0s/0s]
  Running ‘oneway_welch_correctness.r’ [3s/5s]
  Running ‘oneway_welch_errors.r’ [0s/0s]
  Running ‘oneway_welch_warnings.r’ [0s/0s]
  Running ‘t_equalvar_behaviour.r’ [0s/1s]
  Running ‘t_equalvar_correctness.r’ [1s/1s]
  Running ‘t_equalvar_errors.r’ [0s/0s]
  Running ‘t_equalvar_warnings.r’ [0s/0s]
  Running ‘t_onesample_behaviour.r’ [0s/0s]
  Running ‘t_onesample_correctness.r’ [1s/1s]
  Running ‘t_onesample_errors.r’ [0s/0s]
  Running ‘t_onesample_warnings.r’ [0s/1s]
  Running ‘t_paired_behaviour.r’ [0s/1s]
  Running ‘t_paired_correctness.r’ [1s/1s]
  Running ‘t_paired_errors.r’ [0s/0s]
  Running ‘t_paired_warnings.r’ [0s/0s]
  Running ‘t_welch_behaviour.r’ [0s/0s]
  Running ‘t_welch_correctness.r’ [1s/1s]
  Running ‘t_welch_errors.r’ [0s/0s]
  Running ‘t_welch_warnings.r’ [0s/0s]
  Running ‘waerden_behaviour.r’ [0s/1s]
  Running ‘waerden_correctness.r’ [2s/3s]
  Running ‘waerden_errors.r’ [0s/0s]
  Running ‘waerden_warnings.r’ [0s/0s]
  Running ‘wilcoxon_onesample_behaviour.r’ [0s/0s]
  Running ‘wilcoxon_onesample_correctness.r’ [2s/2s]
  Running ‘wilcoxon_onesample_errors.r’ [0s/0s]
  Running ‘wilcoxon_onesample_warnings.r’ [0s/0s]
  Running ‘wilcoxon_paired_behaviour.r’ [0s/1s]
  Running ‘wilcoxon_paired_correctness.r’ [2s/2s]
  Running ‘wilcoxon_paired_errors.r’ [0s/0s]
  Running ‘wilcoxon_paired_warnings.r’ [0s/0s]
  Running ‘wilcoxon_twosample_behaviour.r’ [0s/0s]
  Running ‘wilcoxon_twosample_correctness.r’ [5s/7s]
  Running ‘wilcoxon_twosample_errors.r’ [0s/0s]
  Running ‘wilcoxon_twosample_warnings.r’ [0s/0s]
Running the tests in ‘tests/cosinor_correctness.r’ failed.
Complete output:
  > library(matrixTests)
  > 
  > #--- functions -----------------------------------------------------------------
  > 
  > cosinor_cosinor <- function(mat, time, per) {
  +   stopifnot(ncol(mat) == length(time))
  +   if(is.vector(mat)) mat <- matrix(mat, nrow=1)
  +   n <- m <- amp <- acr <- dfm <- dfr <- rsq <- f <- p <- numeric(nrow(mat))
  + 
  +   for(i in 1:nrow(mat)) {
  +     dat <- data.frame(x=mat[i,], t=time)
  +     dat <- dat[!is.na(dat$x) & !is.na(dat$t),]
  +     res <- cosinor::cosinor.lm(x ~ time(t), data=dat, period=per)
  + 
  +     n[i]   <- nrow(dat)
  +     m[i]   <- res$coefficients[1]
  +     amp[i] <- res$coefficients[2]
  +     acr[i] <- abs(cosinor2::correct.acrophase(res) / pi * (per/2))
  +     dfm[i] <- cosinor2::cosinor.detect(res)[2]
  +     dfr[i] <- cosinor2::cosinor.detect(res)[3]
  +     rsq[i] <- cosinor2::cosinor.PR(res)[[2]]
  +     f[i]   <- cosinor2::cosinor.detect(res)[1]
  +     p[i]   <- cosinor2::cosinor.detect(res)[4]
  +   }
  + 
  +   data.frame(obs=n, mesor=m, amplitude=amp, acrophase=acr, rsquared=rsq,
  +              df.model=dfm, df.residual=dfr, statistic=f,
  +              pvalue=p, period=per
  +              )
  + }
  > 
  > 
  > #--- montecarlo ----------------------------------------------------------------
  > 
  > # equally spaced 10 time points, period = 10
  > X <- matrix(rnorm(10000), ncol=10)
  > t <- -5:4
  > res1 <- cosinor_cosinor(X, t, 10)
  > res2 <- row_cosinor(X, t, 10)
  > stopifnot(all.equal(res1, res2))
  > 
  > # equally spaced 5 time points, period = 2.2
  > X <- matrix(rnorm(5000), ncol=5)
  > t <- 1:5
  > res1 <- cosinor_cosinor(X, t, 2.2)
  > res2 <- row_cosinor(X, t, 2.2)
  > stopifnot(all.equal(res1, res2))
  > 
  > # random 10 time points, random period
  > X <- matrix(rnorm(10000), ncol=10)
  > t   <- runif(10, 1, 10)
  > per <- runif(1, 1, 10)
  > res1 <- cosinor_cosinor(X, t, per)
  > res2 <- row_cosinor(X, t, per)
  > stopifnot(all.equal(res1, res2))
  > 
  > # random 50 time points, random period
  > X <- matrix(rnorm(50000), ncol=50)
  > t   <- runif(50, 1, 5)
  > per <- runif(1, 1, 10)
  > res1 <- cosinor_cosinor(X, t, per)
  > res2 <- row_cosinor(X, t, per)
  > stopifnot(all.equal(res1, res2))
  > 
  > # small period
  > X <- matrix(rnorm(10000), ncol=10)
  > t <- c(1:9, 9.3)
  > res1 <- cosinor_cosinor(X, t, 0.301)
  > res2 <- row_cosinor(X, t, 0.301)
  > stopifnot(all.equal(res1, res2))
  > 
  > # large period
  > X <- matrix(rnorm(10000), ncol=10)
  > t <- 1:10
  > res1 <- cosinor_cosinor(X, t, 300)
  > res2 <- row_cosinor(X, t, 300)
  > stopifnot(all.equal(res1, res2))
  > 
  > 
  > #--- extreme numbers -----------------------------------------------------------
  > 
  > # NOTE: extreme number test is skipped because cosinor_cosinor implementation is not robust against them
  > 
  > # NOTE: turned-off because of precission errors on architectures without long doubles
  > # large sample
  > # x <- rnorm(10^6)
  > # t <- runif(10^6, 0, 24)
  > # res1 <- cosinor_cosinor(x, t, 24)
  > # res2 <- row_cosinor(x, t, 24)
  > # stopifnot(all.equal(res1, res2))
  > 
  > # TODO: add tests for Inf and -Inf values once decided how to handle them.
  > 
  > 
  > #--- minimal sample size -------------------------------------------------------
  > 
  > # NOTE: matrixTests can work with 4 observations but cosinor_cosinor requires 5
  > 
  > # five observations
  > x <- rnorm(5)
  > t <- runif(5, 1, 24)
  > res1 <- cosinor_cosinor(x, t, 24)
  > res2 <- row_cosinor(x, t, 24)
  > stopifnot(all.equal(res1, res2))
  > 
  > # three unique time points each repeated 3 times
  > x <- rnorm(9)
  > t <- rep(runif(3, 1, 24), each=3)
  > res1 <- cosinor_cosinor(x, t, 24)
  > res2 <- row_cosinor(x, t, 24)
  > stopifnot(all.equal(res1, res2))
  > 
  > # three unique time points, one repeated 2 times and others 1 time
  > x <- rnorm(5)
  > t <- rep(runif(3, 1, 24), c(3,1,1))
  > res1 <- cosinor_cosinor(x, t, 24)
  > res2 <- row_cosinor(x, t, 24)
  > stopifnot(all.equal(res1, res2))
  > 
  > # 3 unique time points, all having the same values repeated two times
  > # NOTE: this produces a perfect fit, so cosinor_cosinor values are adjusted to match
  > x <- rep(rnorm(3), each=2)
  > t <- rep(runif(3, 1, 24), each=2)
  > res1 <- cosinor_cosinor(x, t, 24)
  > res1$statistic <- Inf; res1$pvalue <- 0
  > res2 <- suppressWarnings(row_cosinor(x, t, 24))
  > stopifnot(all.equal(res1, res2))
  > 
  > 
  > #--- constant values -----------------------------------------------------------
  > 
  > # all values are constant except one
  > x <- c(1,1,1,1,rnorm(1))
  > t <- runif(5, 1, 24)
  > res1 <- cosinor_cosinor(x, t, 24)
  > res2 <- row_cosinor(x, t, 24)
  > stopifnot(all.equal(res1, res2))
  Error: res1 and res2 are not equal:
    Component "rsquared": Mean relative difference: 3.599399e-08
  Execution halted