CRAN Package Check Results for Package detect

Last updated on 2026-06-24 11:55:52 CEST.

Flavor Version Tinstall Tcheck Ttotal Status Flags
r-devel-linux-x86_64-debian-clang 0.5-1 11.44 95.61 107.05 ERROR
r-devel-linux-x86_64-debian-gcc 0.5-1 8.17 199.50 207.67 OK
r-devel-linux-x86_64-fedora-clang 0.5-1 19.00 485.77 504.77 OK
r-devel-linux-x86_64-fedora-gcc 0.5-1 18.00 520.25 538.25 OK
r-devel-windows-x86_64 0.5-1 13.00 502.00 515.00 OK
r-patched-linux-x86_64 0.5-1 10.22 301.67 311.89 OK
r-release-linux-x86_64 0.5-1 11.36 301.38 312.74 OK
r-release-macos-arm64 0.5-1 3.00 73.00 76.00 OK
r-release-macos-x86_64 0.5-1 8.00 367.00 375.00 OK
r-release-windows-x86_64 0.5-1 12.00 532.00 544.00 OK
r-oldrel-macos-arm64 0.5-1 OK
r-oldrel-macos-x86_64 0.5-1 8.00 343.00 351.00 OK
r-oldrel-windows-x86_64 0.5-1 18.00 589.00 607.00 OK

Check Details

Version: 0.5-1
Check: tests
Result: ERROR Running ‘tests.R’ [5s/6s] Running the tests in ‘tests/tests.R’ failed. Complete output: > #devtools::install_github("psolymos/detect") > library(detect) Loading required package: Formula Loading required package: stats4 Loading required package: pbapply detect 0.5-1 2026-01-04 > > ## --- run examples with \dontrun sections --- > > help_pages <- c(#"bootstrap", + "cmulti", "convertEDR", "databu", "datocc", + "hbootindex", "oven", "svabu", "svocc") > > for (i in help_pages) { + cat("\n\n---------- detect example:", i, "----------\n\n") + eval(parse(text=paste0("example(", i, + ", package = 'detect', run.dontrun = TRUE)"))) + } ---------- detect example: cmulti ---------- cmulti> simfun1 <- function(n = 10, phi = 0.1, c=1, tau=0.8, type="rem") { cmulti+ if (type=="dis") { cmulti+ Dparts <- matrix(c(0.5, 1, NA, cmulti+ 0.5, 1, Inf, cmulti+ 1, Inf, NA), 3, 3, byrow=TRUE) cmulti+ D <- Dparts[sample.int(3, n, replace=TRUE),] cmulti+ CP <- 1-exp(-(D/tau)^2) cmulti+ } else { cmulti+ Dparts <- matrix(c(5, 10, NA, cmulti+ 3, 5, 10, cmulti+ 3, 5, NA), 3, 3, byrow=TRUE) cmulti+ D <- Dparts[sample.int(3, n, replace=TRUE),] cmulti+ CP <- 1-c*exp(-D*phi) cmulti+ } cmulti+ k <- ncol(D) cmulti+ P <- CP - cbind(0, CP[, -k, drop=FALSE]) cmulti+ Psum <- rowSums(P, na.rm=TRUE) cmulti+ PPsum <- P / Psum cmulti+ Pok <- !is.na(PPsum) cmulti+ N <- rpois(n, 10) cmulti+ Y <- matrix(NA, ncol(PPsum), nrow(PPsum)) cmulti+ Ypre <- sapply(1:n, function(i) rmultinom(1, N, PPsum[i,Pok[i,]])) cmulti+ Y[t(Pok)] <- unlist(Ypre) cmulti+ Y <- t(Y) cmulti+ list(Y=Y, D=D) cmulti+ } cmulti> n <- 200 cmulti> x <- rnorm(n) cmulti> X <- cbind(1, x) cmulti> ## removal, constant cmulti> vv <- simfun1(n=n, phi=exp(-1.5)) cmulti> m1 <- cmulti(vv$Y | vv$D ~ 1, type="rem") cmulti> coef(m1) log.phi_(Intercept) -1.452594 cmulti> ## mixture, constant (mix and fmix are identical) cmulti> vv <- simfun1(n=n, phi=exp(-1.5), c=plogis(0.8)) cmulti> m2 <- cmulti(vv$Y | vv$D ~ 1, type="mix") cmulti> coef(m2) log.phi logit.c_(Intercept) -1.5243161 0.7439766 cmulti> m2f <- cmulti(vv$Y | vv$D ~ 1, type="fmix") cmulti> coef(m2f) log.phi_(Intercept) logit.c -1.5243161 0.7439766 cmulti> ## dist, constant cmulti> vv <- simfun1(n=n, tau=exp(-0.2), type="dis") cmulti> m3 <- cmulti(vv$Y | vv$D ~ 1, type="dis") cmulti> coef(m3) log.tau_(Intercept) -0.2107198 cmulti> ## removal, not constant cmulti> log.phi <- crossprod(t(X), c(-2,-1)) cmulti> vv <- simfun1(n=n, phi=exp(cbind(log.phi, log.phi, log.phi))) cmulti> m1 <- cmulti(vv$Y | vv$D ~ x, type="rem") cmulti> coef(m1) log.phi_(Intercept) log.phi_x -1.9884759 -0.9319305 cmulti> ## mixture, fixed phi, varying c cmulti> logit.c <- crossprod(t(X), c(-2,1)) cmulti> vv <- simfun1(n=n, phi=exp(-1.5), c=plogis(cbind(logit.c, logit.c, logit.c))) cmulti> m2 <- cmulti(vv$Y | vv$D ~ x, type="mix") cmulti> coef(m2) log.phi logit.c_(Intercept) logit.c_x -1.447096 -1.863916 1.027770 cmulti> ## mixture, varying phi, fixed c cmulti> log.phi <- crossprod(t(X), c(-2,-1)) cmulti> vv <- simfun1(n=n, phi=exp(cbind(log.phi, log.phi, log.phi)), c=plogis(0.8)) cmulti> m2f <- cmulti(vv$Y | vv$D ~ x, type="fmix") cmulti> coef(m2f) log.phi_(Intercept) log.phi_x logit.c -1.9837536 -0.9477935 0.8041107 cmulti> ## dist, not constant cmulti> log.tau <- crossprod(t(X), c(-0.5,-0.2)) cmulti> vv <- simfun1(n=n, tau=exp(cbind(log.tau, log.tau, log.tau)), type="dis") cmulti> m3 <- cmulti(vv$Y | vv$D ~ x, type="dis") cmulti> coef(m3) log.tau_(Intercept) log.tau_x -0.5200918 -0.2181637 cmulti> summary(m3) Call: cmulti(formula = vv$Y | vv$D ~ x, type = "dis") Distance Sampling (half-normal, circular area) Conditional Maximum Likelihood estimates Coefficients: Estimate Std. Error z value Pr(>|z|) log.tau_(Intercept) -0.52009 0.01600 -32.50 <2e-16 *** log.tau_x -0.21816 0.01662 -13.12 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Log-likelihood: -343.4 BIC = 697.5 cmulti> coef(m3) log.tau_(Intercept) log.tau_x -0.5200918 -0.2181637 cmulti> vcov(m3) log.tau_(Intercept) log.tau_x log.tau_(Intercept) 2.561463e-04 3.423522e-05 log.tau_x 3.423522e-05 2.763424e-04 cmulti> AIC(m3) [1] 690.8791 cmulti> confint(m3) 2.5 % 97.5 % log.tau_(Intercept) -0.5514602 -0.4887234 log.tau_x -0.2507452 -0.1855821 cmulti> logLik(m3) 'log Lik.' -343.4395 (df=2) cmulti> ## fitted values cmulti> plot(exp(log.tau), fitted(m3)) cmulti> ## prediction for new locations (type = 'rem') cmulti> ndf <- data.frame(x=seq(-1, 1, by=0.1)) cmulti> summary(predict(m1, newdata=ndf, type="link")) Min. 1st Qu. Median Mean 3rd Qu. Max. -2.920 -2.454 -1.988 -1.988 -1.523 -1.057 cmulti> summary(pr1 <- predict(m1, newdata=ndf, type="response")) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.05391 0.08591 0.13690 0.15976 0.21816 0.34765 cmulti> ## turing singing rates into probabilities requires total duration cmulti> ## 5 minutes used here cmulti> psing <- 1-exp(-5*pr1) cmulti> plot(ndf$x, psing, type="l", ylim=c(0,1)) cmulti> ## prediction for new locations (type = 'dis') cmulti> summary(predict(m3, newdata=ndf, type="link")) Min. 1st Qu. Median Mean 3rd Qu. Max. -0.7383 -0.6292 -0.5201 -0.5201 -0.4110 -0.3019 cmulti> summary(pr3 <- predict(m3, newdata=ndf, type="response")) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.4779 0.5330 0.5945 0.5997 0.6630 0.7394 cmulti> ## turing EDR into probabilities requires finite truncation distances cmulti> ## r=0.5 used here (50 m) cmulti> r <- 0.5 cmulti> pdet <- pr3^2*(1-exp(-r^2/pr3^2))/r^2 cmulti> plot(ndf$x, pdet, type="l", ylim=c(0,1)) cmulti> ## joint removal-distance estimation cmulti> ## is not different from 2 orthogonal estimations cmulti> cmulti> simfun12 <- function(n = 10, phi = 0.1, c=1, tau=0.8, type="rem") { cmulti+ Flat <- function(x, DIM, dur=TRUE) { cmulti+ x <- array(x, DIM) cmulti+ if (!dur) { cmulti+ x <- aperm(x,c(1,3,2)) cmulti+ } cmulti+ dim(x) <- c(DIM[1], DIM[2]*DIM[3]) cmulti+ x cmulti+ } cmulti+ Dparts1 <- matrix(c(5, 10, NA, cmulti+ 3, 5, 10, cmulti+ 3, 5, NA), 3, 3, byrow=TRUE) cmulti+ D1 <- Dparts1[sample.int(3, n, replace=TRUE),] cmulti+ CP1 <- 1-c*exp(-D1*phi) cmulti+ Dparts2 <- matrix(c(0.5, 1, NA, cmulti+ 0.5, 1, Inf, cmulti+ 1, Inf, NA), 3, 3, byrow=TRUE) cmulti+ D2 <- Dparts2[sample.int(3, n, replace=TRUE),] cmulti+ CP2 <- 1-exp(-(D2/tau)^2) cmulti+ k1 <- ncol(D1) cmulti+ k2 <- ncol(D2) cmulti+ DIM <- c(n, k1, k2) cmulti+ P1 <- CP1 - cbind(0, CP1[, -k1, drop=FALSE]) cmulti+ P2 <- CP2 - cbind(0, CP2[, -k2, drop=FALSE]) cmulti+ Psum1 <- rowSums(P1, na.rm=TRUE) cmulti+ Psum2 <- rowSums(P2, na.rm=TRUE) cmulti+ Pflat <- Flat(P1, DIM, dur=TRUE) * Flat(P2, DIM, dur=FALSE) cmulti+ PsumFlat <- Psum1 * Psum2 cmulti+ PPsumFlat <- Pflat / PsumFlat cmulti+ PokFlat <- !is.na(PPsumFlat) cmulti+ N <- rpois(n, 10) cmulti+ Yflat <- matrix(NA, ncol(PPsumFlat), nrow(PPsumFlat)) cmulti+ YpreFlat <- sapply(1:n, function(i) rmultinom(1, N, PPsumFlat[i,PokFlat[i,]])) cmulti+ Yflat[t(PokFlat)] <- unlist(YpreFlat) cmulti+ Yflat <- t(Yflat) cmulti+ Y <- array(Yflat, DIM) cmulti+ k1 <- dim(Y)[2] cmulti+ k2 <- dim(Y)[3] cmulti+ Y1 <- t(sapply(1:n, function(i) { cmulti+ count <- rowSums(Y[i,,], na.rm=TRUE) cmulti+ nas <- rowSums(is.na(Y[i,,])) cmulti+ count[nas == k2] <- NA cmulti+ count cmulti+ })) cmulti+ Y2 <- t(sapply(1:n, function(i) { cmulti+ count <- colSums(Y[i,,], na.rm=TRUE) cmulti+ nas <- colSums(is.na(Y[i,,])) cmulti+ count[nas == k2] <- NA cmulti+ count cmulti+ })) cmulti+ list(Y=Y, D1=D1, D2=D2, Y1=Y1, Y2=Y2) cmulti+ } cmulti> ## removal and distance, constant cmulti> vv <- simfun12(n=n, phi=exp(-1.5), tau=exp(-0.2)) cmulti> res <- cmulti2.fit(vv$Y, vv$D1, vv$D2) cmulti> res1 <- cmulti.fit(vv$Y1, vv$D1, NULL, "rem") cmulti> res2 <- cmulti.fit(vv$Y2, vv$D2, NULL, "dis") cmulti> ## points estimates are identical cmulti> cbind(res$coef, c(res1$coef, res2$coef)) [,1] [,2] [1,] -1.4717740 -1.4717740 [2,] -0.2042504 -0.2042504 cmulti> ## standard errors are identical cmulti> cbind(sqrt(diag(res$vcov)), cmulti+ c(sqrt(diag(res1$vcov)),sqrt(diag(res2$vcov)))) [,1] [,2] [1,] 0.04364967 0.04364967 [2,] 0.01341445 0.01341445 cmulti> ## removal and distance, not constant cmulti> vv <- simfun12(n=n, cmulti+ phi=exp(cbind(log.phi, log.phi, log.phi)), cmulti+ tau=exp(cbind(log.tau, log.tau, log.tau))) cmulti> res <- cmulti2.fit(vv$Y, vv$D1, vv$D2, X1=X, X2=X) Error in aggregate.data.frame(as.data.frame(x), ...) : no rows to aggregate Calls: eval ... aggregate -> aggregate.default -> aggregate.data.frame In addition: Warning messages: 1: In max(D, na.rm = TRUE) : no non-missing arguments to max; returning -Inf 2: In log(max(D, na.rm = TRUE)) : NaNs produced Execution halted Flavor: r-devel-linux-x86_64-debian-clang