R Under development (unstable) (2024-07-10 r86888 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(fitdistrplus) Loading required package: MASS Loading required package: survival > > visualize <- FALSE # TRUE for manual tests with visualization of results > set.seed(123) > n <- 20 > if (visualize) + { + # (1) test ppcomp/ppcompcens on a good example + # + + + x <- rlnorm(n, 0, 1) + dx <- data.frame(left=x, right=x) + dx$right[1:(n/2)*2] <- NA + dx$left[2:(n/4)*4-1] <- NA + + f1 <- fitdist(x, "lnorm") + f1c <- fitdistcens(dx, "lnorm") + + f3 <- fitdist(x, "lnorm", fix.arg=list(sdlog=1)) + f3c <- fitdistcens(dx, "lnorm", fix.arg=list(sdlog=1)) + + + + par(mfrow=1:2, mar=c(4,4,2,1)) + ppcomp(f1) + ppcompcens(f1c) + par(mfrow = c(1,1)) + if (requireNamespace ("ggplot2", quietly = TRUE)) { + ppcomp(f1, plotstyle = "ggplot") + ppcompcens(f1c, plotstyle = "ggplot") + } + + #test log-scale + par(mfrow=1:2, mar=c(4,4,2,1)) + ppcomp(f1, xlogscale = TRUE, ylogscale = TRUE) + ppcompcens(f1c, xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1)) + par(mfrow = c(1,1)) + if (requireNamespace ("ggplot2", quietly = TRUE)) { + ppcomp(f1, xlogscale = TRUE, ylogscale = TRUE, plotstyle = "ggplot") + ppcompcens(f1c, xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1), plotstyle = "ggplot") + } + + + # (2) test ppcomp/ppcompcens on a weird example + # + + f2 <- fitdist(x, "unif") + f2c <- fitdistcens(dx, "unif") + + par(mfrow=1:2, mar=c(4,4,2,1)) + ppcomp(list(f1, f2, f3)) + ppcompcens(list(f1c, f2c, f3c)) + par(mfrow = c(1,1)) + if (requireNamespace ("ggplot2", quietly = TRUE)) { + ppcomp(list(f1, f2, f3), plotstyle = "ggplot") + ppcompcens(list(f1c, f2c, f3c), plotstyle = "ggplot") + } + + #test log-scale + par(mfrow=1:2, mar=c(4,4,2,1)) + ppcomp(list(f1, f2, f3), xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1)) + ppcompcens(list(f1c, f2c, f3c), xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1)) + par(mfrow = c(1,1)) + if (requireNamespace ("ggplot2", quietly = TRUE)) { + ppcomp(list(f1, f2, f3), xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1), plotstyle = "ggplot") + ppcompcens(list(f1c, f2c, f3c), xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1), plotstyle = "ggplot") + } + + #test y noise + par(mfrow=1:2, mar=c(4,4,2,1)) + ppcomp(list(f1, f2, f3)) + ppcomp(list(f1, f2, f3), ynoise=FALSE) + par(mfrow = c(1,1)) + if (requireNamespace ("ggplot2", quietly = TRUE)) { + ppcomp(list(f1, f2, f3), plotstyle = "ggplot") + ppcomp(list(f1, f2, f3), ynoise=FALSE, plotstyle = "ggplot") + } + + par(mfrow=1:2, mar=c(4,4,2,1)) + ppcompcens(list(f1c, f2c, f3c)) + ppcompcens(list(f1c, f2c, f3c), ynoise=FALSE) + par(mfrow = c(1,1)) + if (requireNamespace ("ggplot2", quietly = TRUE)) { + ppcompcens(list(f1c, f2c, f3c), ynoise=FALSE, plotstyle = "ggplot") + } + + #test log-scale y-noise + par(mfrow=1:2, mar=c(4,4,2,1)) + ppcomp(list(f1, f2, f3), xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1)) + ppcomp(list(f1, f2, f3), xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1), ynoise=FALSE) + par(mfrow = c(1,1)) + if (requireNamespace ("ggplot2", quietly = TRUE)) { + ppcomp(list(f1, f2, f3), xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1), plotstyle = "ggplot") + ppcomp(list(f1, f2, f3), xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1), plotstyle = "ggplot") + } + + par(mfrow=1:2, mar=c(4,4,2,1)) + ppcompcens(list(f1c, f2c), xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1)) + ppcompcens(list(f1c, f2c), xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1), ynoise=FALSE) + par(mfrow = c(1,1)) + if (requireNamespace ("ggplot2", quietly = TRUE)) { + ppcompcens(list(f1c, f2c), xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1), plotstyle = "ggplot") + ppcompcens(list(f1c, f2c), xlogscale = TRUE, ylogscale = TRUE, xlim=c(.1, 1), ylim=c(.1, 1), plotstyle = "ggplot") + } + + } > > proc.time() user system elapsed 1.45 0.29 1.65