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 > > # (1) Plot of an empirical censored distribution (censored data) as a CDF > # using the default Turnbull method > # > data(smokedfish) > plotdistcens(smokedfish) > plotdistcens(data.frame(right=smokedfish$right, left=smokedfish$left)) > d1 <- as.data.frame(log10(smokedfish)) > plotdistcens(d1) > > #test on first arg > try(plotdistcens(list(left=smokedfish$left, right=smokedfish$right))) Error in plotdistcens(list(left = smokedfish$left, right = smokedfish$right)) : datacens must be a dataframe with two columns named 'left' and 'right' and more than one line > try(plotdistcens(cbind(left=smokedfish$left, right=smokedfish$right))) Error in plotdistcens(cbind(left = smokedfish$left, right = smokedfish$right)) : datacens must be a dataframe with two columns named 'left' and 'right' and more than one line > d2 <- data.frame(left=smokedfish$right, right=smokedfish$left) > try(plotdistcens(d2)) Error in plotdistcens(d2) : some rows in censdata have left values strictly greater than right values > > # (2) Add the CDF of a normal distribution and QQ and PP plots > # > plotdistcens(smokedfish,"lnorm", para=list(meanlog=-3.6,sdlog=3.5)) > plotdistcens(d1,"norm", para=list(mean=-1.6,sd=1.5)) > > # (3) Various plots of the same empirical distribution > # > # default Wang plot > plotdistcens(d1, NPMLE = TRUE, NPMLE.method = "Wang") > plotdistcens(d1, NPMLE = TRUE, NPMLE.method = "Wang", lwd = 3, main = "Wang ECDF plot") > # Turnbull plot > plotdistcens(d1, NPMLE = TRUE, NPMLE.method = "Turnbull", col = "red", + main = "Turnbull ECDF plot") Warning message: In plotdistcens(d1, NPMLE = TRUE, NPMLE.method = "Turnbull", col = "red", : Turnbull is now a deprecated option for NPMLE.method. You should use Turnbull.middlepoints of Turnbull.intervals. It was here fixed as Turnbull.middlepoints, equivalent to former Turnbull. > plotdistcens(d1,Turnbull = TRUE) # deprecated way to do it Warning message: In plotdistcens(d1, Turnbull = TRUE) : When Turnbull.confint is TRUE NPMLE.method is forced to Turnbull.middlepoints. > # Turnbull plot with confidence intervals > plotdistcens(d1,NPMLE = TRUE, NPMLE.method = "Turnbull", Turnbull.confint = TRUE) Warning message: In plotdistcens(d1, NPMLE = TRUE, NPMLE.method = "Turnbull", Turnbull.confint = TRUE) : Turnbull is now a deprecated option for NPMLE.method. You should use Turnbull.middlepoints of Turnbull.intervals. It was here fixed as Turnbull.middlepoints, equivalent to former Turnbull. > plotdistcens(d1,Turnbull = TRUE,Turnbull.confint = TRUE) # deprecated way to do it Warning messages: 1: In plotdistcens(d1, Turnbull = TRUE, Turnbull.confint = TRUE) : When Turnbull.confint is TRUE NPMLE.method is forced to Turnbull.middlepoints. 2: In plot.window(...) : "Turnbull" is not a graphical parameter 3: In plot.xy(xy, type, ...) : "Turnbull" is not a graphical parameter 4: In axis(side = side, at = at, labels = labels, ...) : "Turnbull" is not a graphical parameter 5: In axis(side = side, at = at, labels = labels, ...) : "Turnbull" is not a graphical parameter 6: In box(...) : "Turnbull" is not a graphical parameter 7: In title(...) : "Turnbull" is not a graphical parameter > # with intervals and points > plotdistcens(d1,NPMLE = FALSE) > plotdistcens(d1,NPMLE = FALSE, col = "red", lwd = 2) > plotdistcens(d1,rightNA=3, NPMLE = FALSE) > plotdistcens(d1,rightNA=3, Turnbull = FALSE) # deprecated way to do it > # with intervals and points > # defining a minimum value for left censored values > plotdistcens(d1,leftNA=-3, NPMLE = FALSE) > > # (4) Goodness-of-fit plots for the same dataset after logarithmic transformation > # with a lognormal distribution, successively using the three proposed methods > # > d3 <- smokedfish > plotdistcens(d3,"lnorm",para=list(meanlog=-3.6,sdlog=3.5), main = "Wang plot") > plotdistcens(d3,"lnorm",para=list(meanlog=-3.6,sdlog=3.5), + NPMLE.method = "Turnbull", main = "Turnbull plot") Warning messages: 1: In plotdistcens(d3, "lnorm", para = list(meanlog = -3.6, sdlog = 3.5), : Turnbull is now a deprecated option for NPMLE.method. You should use Turnbull.middlepoints of Turnbull.intervals. It was here fixed as Turnbull.middlepoints, equivalent to former Turnbull. 2: In plotdistcens(d3, "lnorm", para = list(meanlog = -3.6, sdlog = 3.5), : Q-Q plot and P-P plot are available only with the arguments NPMLE.method at Wang (default value) or Turnbull.intervals. > plotdistcens(d3,"lnorm",para=list(meanlog=-3.6,sdlog=3.5), + NPMLE = FALSE, leftNA=0, main = "Plot of ordered intervals") Warning message: In plotdistcens(d3, "lnorm", para = list(meanlog = -3.6, sdlog = 3.5), : When NPMLE is FALSE the nonparametric maximum likelihood estimation of the cumulative distribution function is not computed. Q-Q plot and P-P plot are available only with the arguments NPMLE.method at Wang (default value) or Turnbull.intervals. > > # Test with the salinity data set > # > data(salinity) > log10LC50 <-log10(salinity) > plotdistcens(log10LC50) > plotdistcens(log10LC50, NPMLE.method = "Turnbull") Warning message: In plotdistcens(log10LC50, NPMLE.method = "Turnbull") : Turnbull is now a deprecated option for NPMLE.method. You should use Turnbull.middlepoints of Turnbull.intervals. It was here fixed as Turnbull.middlepoints, equivalent to former Turnbull. > plotdistcens(log10LC50, NPMLE = FALSE) > fn <- fitdistcens(log10LC50,"norm") > fl <- fitdistcens(log10LC50,"logis") > plot(fn) > plot(fl) > > proc.time() user system elapsed 2.31 0.28 2.57