* using log directory ‘/data/gannet/ripley/R/packages/tests-LENGTH1/MsdeParEst.Rcheck’ * using R Under development (unstable) (2022-04-03 r82074) * using platform: x86_64-pc-linux-gnu (64-bit) * using session charset: UTF-8 * using option ‘--no-stop-on-test-error’ * checking for file ‘MsdeParEst/DESCRIPTION’ ... OK * checking extension type ... Package * this is package ‘MsdeParEst’ version ‘1.7’ * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for executable files ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking whether package ‘MsdeParEst’ can be installed ... [18s/37s] OK * checking package directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking R files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking use of S3 registration ... OK * checking dependencies in R code ... NOTE Namespaces in Imports field not imported from: ‘MASS’ ‘moments’ ‘mvtnorm’ All declared Imports should be used. * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... [30s/49s] OK * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking contents of ‘data’ directory ... OK * checking data for non-ASCII characters ... OK * checking data for ASCII and uncompressed saves ... OK * checking examples ... [8s/11s] ERROR Running examples in ‘MsdeParEst-Ex.R’ failed The error most likely occurred in: > ### Name: msde.sim > ### Title: Simulation Of A Mixed Stochastic Differential Equation > ### Aliases: msde.sim > > ### ** Examples > > > > # Example 1 : one random effect in the drift and one fixed effect in the diffusion coefficient > sim <- msde.sim(M = 30, T = 1, N = 1000, model = 'OU', drift.random = 2, + diffusion.random = 0, drift.param = c(0,1,sqrt(0.4/4)), diffusion.param = 0.5) Be careful, X0 is missing thus the initial value X0=0.01 is used > > # Example 2 : two random effects in the drift and one random effect in the diffusion coefficient > > sim <- msde.sim(M = 30, T = 1, N = 1000, model = 'OU', drift.random = c(1,2), + diffusion.random = 1, drift.param = c(1,0.5,0.5,0.5), diffusion.param = c(8,1/2)) Be careful, X0 is missing thus the initial value X0=0.01 is used ----------- FAILURE REPORT -------------- --- failure: length > 1 in coercion to logical --- --- srcref --- : --- package (from environment) --- MsdeParEst --- call from context --- msde.sim(M = 30, T = 1, N = 1000, model = "OU", drift.random = c(1, 2), diffusion.random = 1, drift.param = c(1, 0.5, 0.5, 0.5), diffusion.param = c(8, 1/2)) --- call from argument --- (drift.random == 0) && (length(drift.param) != 2) --- R stacktrace --- where 1: msde.sim(M = 30, T = 1, N = 1000, model = "OU", drift.random = c(1, 2), diffusion.random = 1, drift.param = c(1, 0.5, 0.5, 0.5), diffusion.param = c(8, 1/2)) --- value of length: 2 type: logical --- [1] FALSE FALSE --- function from context --- function (M, T, N = 100, model, drift.random, diffusion.random, drift.param, diffusion.param, nb.mixt = 1, mixt.prop = 1, t0 = 0, X0 = 0.01, delta = T/N, op.plot = 0, add.plot = FALSE) { con <- file(tempfile(), open = "w") on.exit(close(con)) sde.sim <- function(...) { sink(con) res <- sde::sde.sim(...) sink(NULL) res } if (((M - round(M)) != 0) || (M <= 0)) { stop("Invalid value for M. The number of simulated trajectories should be a positive integer") } if (((N - round(N)) != 0) || (N <= 0)) { stop("Invalid value for N. The number of simulated time points should be a positive integer") } if (t0 < 0) { stop("Invalid value for t0. The starting time point should be positive") } if (T <= 0) { stop("Invalid value for T. The maximum time point should be positive") } if (t0 > T) { stop("The starting time point t0 should be smaller than the maximum time point T") } if ((delta < 0) || (delta > (T - t0))) { stop("Invalid value for delta") } if ((model != "OU") & (model != "CIR")) { stop("A model must be precised: OU or CIR") } if (((nb.mixt - round(nb.mixt)) != 0) || (nb.mixt <= 0)) { stop("The number of mixture components (nb.mixt) should be a positive integer") } if ((diffusion.random != 0) && (diffusion.random != 1)) { stop("Invalid value for diffusion.random, should be either 0 or 1") } valid.drift = list(0, 1, 2, c(1, 2)) check <- 0 for (i in 1:4) { check <- check + prod(drift.random %in% valid.drift[[i]]) } if (check == 0) { stop("Invalid value for drift.random, should be either 0, or 1, or 2, or c(1,2)") } if ((model == "CIR") && (X0 <= 0)) { stop("For the CIR model, the initial values should be positive.") } if (missing(X0)) { message("Be careful, X0 is missing thus the initial value X0=0.01 is used") } if ((diffusion.random == 1) && (length(diffusion.param) != 2)) { stop("Invalid diffusion.param, should be a vector of length 2") } if ((diffusion.random == 0) && (length(diffusion.param) > 1)) { message("Only the first value of diffusion.param is considered") } if (prod(diffusion.param > 0) != 1) { stop("Invalid diffusion.param, should contain positive values") } if (nb.mixt == 1) { if ((drift.random == 0) && (length(drift.param) != 2)) { stop("Invalid drift.param, should be a vector of length 2") } if (((sum(drift.random) == 1) || (sum(drift.random) == 2)) && (length(drift.param) != 3)) { stop("Invalid drift.param, should be a vector of length 3") } if ((sum(drift.random) == 3) && (length(drift.param) != 4)) { stop("Invalid drift.param, should be a vector of length 4") } } else { if (dim(drift.param)[1] != nb.mixt) { stop("Invalid dimensions for drift.param, should have as many lines as mixture components") } if (((sum(drift.random) == 1) || (sum(drift.random) == 2)) && (dim(drift.param)[2] != 3)) { stop("Invalid dimensions for drift.param, should have 3 columns") } if ((sum(drift.random) == 3) && (dim(drift.param)[2] != 4)) { stop("Invalid dimensions for drift.param, should have 4 columns") } } if (((sum(drift.random)) == 0) && (diffusion.random == 0)) { stop("There should be at least one random effect either in the drift or the diffusion coefficient.") } if (((diffusion.random == 1) && (nb.mixt > 1))) { stop("If there is one random effect in the diffusion coefficient, the random effects in the drift can't follow a mixture of Normal distributions. Try nb.mixt = 1.") } if (length(mixt.prop) != nb.mixt) { stop("There should be as many mixing proportions as mixture components") } if ((prod(mixt.prop >= 0) == 0)) { stop("Invalid values for the mixing proportions, should be positive") } else { if (prod(mixt.prop <= 1) == 0) { mixt.prop <- mixt.prop/sum(mixt.prop) } } delta <- T/N times <- seq(t0, T, length = N + 1) X <- matrix(0, M, N + 1) index <- NA if (diffusion.random == 0) { sig <- diffusion.param[1] psi <- NA if ((sum(drift.random) > 2)) { phi <- matrix(0, 2, M) if (nb.mixt == 1) { phi[1, ] <- rnorm(M, drift.param[1], drift.param[2]) phi[2, ] <- rnorm(M, drift.param[3], drift.param[4]) } if (nb.mixt > 1) { phi <- mixture.sim(M, drift.param, mixt.prop)$Y } if (model == "OU") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(T = T, X0 = X0, N = N, delta = delta, method = "EA", theta = c(phi[, j], sig), model = "OU")) } } if (model == "CIR") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(T = T, X0 = X0, N = N, delta = delta, method = "milstein", theta = c(phi[, j], sig), sigma.x = expression(sig/(2 * sqrt(x))), sigma = expression(sig * sqrt(x)), model = "CIR")) } } } if (sum(drift.random) == 1) { phi <- rep(0, M) if (nb.mixt > 1) { sim <- mixture.sim(M, drift.param[, c(1, 2)], mixt.prop) phi <- sim$Y index <- sim$index if (model == "OU") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(T = T, X0 = X0, N = N, delta = delta, method = "EA", theta = c(phi[j], drift.param[index[j], 3], sig), model = "OU")) } } if (model == "CIR") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(T = T, N = N, X0 = X0, delta = delta, method = "milstein", theta = c(phi[j], drift.param[index[j], 3], sig), sigma.x = expression(sig/(2 * sqrt(x))), sigma = expression(sig * sqrt(x)), model = "CIR")) } } } if (nb.mixt == 1) { phi <- drift.param[1] + drift.param[2] * rnorm(M, mean = 0, sd = 1) if (model == "OU") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(T = T, X0 = X0, N = N, delta = delta, method = "EA", theta = c(phi[j], drift.param[3], sig), model = "OU")) } } if (model == "CIR") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(T = T, N = N, X0 = X0, delta = delta, method = "milstein", theta = c(phi[j], drift.param[3], sig), sigma.x = expression(sig/(2 * sqrt(x))), sigma = expression(sig * sqrt(x)), model = "CIR")) } } } } if (sum(drift.random) == 2) { phi <- rep(0, M) if (nb.mixt > 1) { sim <- mixture.sim(M, drift.param[, c(2, 3)], mixt.prop) phi <- sim$Y index <- sim$index if (model == "OU") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(T = T, X0 = X0, N = N, delta = delta, method = "EA", theta = c(drift.param[index[j], 1], phi[j], sig), model = "OU")) } } if (model == "CIR") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(t0, T, X0, N, delta, method = "milstein", theta = c(drift.param[index[j], 1], phi[j], sig), sigma.x = expression(sig/(2 * sqrt(x))), sigma = expression(sig * sqrt(x)), model = "CIR")) } } } if (nb.mixt == 1) { phi <- drift.param[2] + drift.param[3] * rnorm(M, mean = 0, sd = 1) if (model == "OU") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(T = T, X0 = X0, N = N, delta = delta, method = "EA", theta = c(drift.param[1], phi[j], sig), model = "OU")) } } if (model == "CIR") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(t0, T, X0, N, delta, method = "milstein", theta = c(drift.param[1], phi[j], sig), sigma.x = expression(sig/(2 * sqrt(x))), sigma = expression(sig * sqrt(x)), model = "CIR")) } } } } } if (diffusion.random == 1) { psi <- 1/sqrt(rgamma(M, shape = diffusion.param[1], rate = 1/diffusion.param[2])) if ((sum(drift.random) > 2)) { phi <- matrix(0, 2, M) if (nb.mixt == 1) { for (j in 1:M) { phi[1, j] <- rnorm(1, drift.param[1], sd = drift.param[2] * psi[j]) phi[2, j] <- rnorm(1, drift.param[3], sd = drift.param[4] * psi[j]) } } if (model == "OU") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(T = T, X0 = X0, N = N, delta = delta, method = "EA", theta = c(phi[, j], psi[j]), model = "OU")) } } if (model == "CIR") { message("to consider a random effect in the diffusion coefficient, alphaj should not be random") } } if (sum(drift.random) == 1) { phi <- rep(0, M) if (nb.mixt == 1) { for (j in 1:M) { phi[j] <- drift.param[1] + drift.param[2] * psi[j] * rnorm(1, mean = 0, sd = 1) } } if (model == "OU") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(T = T, X0 = X0, N = N, delta = delta, method = "EA", theta = c(phi[j], drift.param[3], psi[j]), model = "OU")) } } if (model == "CIR") { message("to consider a random effect in the diffusion coefficient, alphaj should not be random") } } if (sum(drift.random) == 2) { phi <- rep(0, M) if (nb.mixt == 1) { for (j in 1:M) { phi[j] <- drift.param[2] + drift.param[3] * psi[j] * rnorm(1, mean = 0, sd = 1) } } if (model == "OU") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(T = T, X0 = X0, N = N, delta = delta, method = "EA", theta = c(drift.param[1], phi[j], psi[j]), model = "OU")) } } if (model == "CIR") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(t0, T, X0, N, delta, method = "milstein", theta = c(drift.param[1], phi[j], psi[j]), sigma.x = expression(psi[j]/(2 * sqrt(x))), sigma = expression(psi[j] * sqrt(x)), model = "CIR")) } } } if (sum(drift.random) == 0) { phi <- NA if (model == "OU") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(T = T, X0 = X0, N = N, delta = delta, method = "EA", theta = c(drift.param[1], drift.param[2], psi[j]), model = "OU")) } } if (model == "CIR") { for (j in 1:M) { suppressMessages(X[j, ] <- sde.sim(t0, T, X0, N, delta, method = "milstein", theta = c(drift.param[1], drift.param[2], psi[j]), sigma.x = expression(psi[j]/(2 * sqrt(x))), sigma = expression(psi[j] * sqrt(x)), model = "CIR")) } } } } output <- X if (op.plot) { if (add.plot) { for (j in 1:M) { lines(delta * (0:N), X[j, ], col = j) } } else { plot(delta * (0:N), X[1, ], type = "l", ylim = c(min(X), max(X)), xlab = "time", ylab = "", col = 1) for (j in 2:M) { lines(delta * (0:N), X[j, ], col = j) } } } return(list(index = index, phi = phi, psi = psi, X = X, times = times)) } --- function search by body --- Function msde.sim in namespace MsdeParEst has this body. ----------- END OF FAILURE REPORT -------------- Fatal error: length > 1 in coercion to logical * checking PDF version of manual ... OK * checking for non-standard things in the check directory ... OK * checking for detritus in the temp directory ... OK * DONE Status: 1 ERROR, 1 NOTE See ‘/data/gannet/ripley/R/packages/tests-LENGTH1/MsdeParEst.Rcheck/00check.log’ for details. Command exited with non-zero status 1 Time 3:44.07, 119.80 + 11.79