Running ‘t-CIcdfplot.R’ [4s/5s]
  Running ‘t-bootdist.R’ [5s/6s]
  Running ‘t-bootdistcens.R’ [3s/4s]
  Running ‘t-cdfcomp.R’ [4s/4s]
  Running ‘t-cdfcompcens.R’ [4s/4s]
  Running ‘t-cvg-algo.R’ [2s/2s]
  Running ‘t-denscomp.R’ [4s/4s]
  Running ‘t-descdist.R’ [2s/2s]
  Running ‘t-detectbound.R’ [2s/2s]
  Running ‘t-fitbench.R’ [2s/2s]
  Running ‘t-fitdist-customoptim.R’ [2s/3s]
  Running ‘t-fitdist.R’ [6s/6s]
  Running ‘t-fitdistcens.R’ [6s/6s]
  Running ‘t-getparam.R’ [2s/2s]
  Running ‘t-gofstat.R’ [2s/2s]
  Running ‘t-init-actuar.R’ [0s/0s]
  Running ‘t-llplot.R’ [3s/4s]
  Running ‘t-lnL-surf.R’ [3s/3s]
  Running ‘t-logLik-vcov-coef.R’ [2s/2s]
  Running ‘t-manageparam.R’ [2s/2s]
  Running ‘t-mgedist.R’ [3s/3s]
  Running ‘t-mledist-cens.R’ [2s/2s]
  Running ‘t-mledist-nocens.R’ [3s/3s]
  Running ‘t-mmedist.R’ [3s/3s]
  Running ‘t-parallel.R’ [0s/0s]
  Running ‘t-plotdist.R’ [2s/2s]
  Running ‘t-plotdistcens.R’ [3s/3s]
  Running ‘t-ppcomp.R’ [4s/4s]
  Running ‘t-ppcompcens.R’ [4s/4s]
  Running ‘t-prefit.R’ [2s/3s]
  Running ‘t-qme-discrete.R’ [8s/10s]
  Running ‘t-qmedist.R’ [6s/6s]
  Running ‘t-qqcomp.R’ [5s/5s]
  Running ‘t-qqcompcens.R’ [4s/4s]
  Running ‘t-quantiledist.R’ [2s/2s]
  Running ‘t-startfixarg-overall.R’ [4s/4s]
  Running ‘t-startingvalues.R’ [2s/2s]
  Running ‘t-util-testdensity.R’ [2s/2s]
  Running ‘t-weird-ppcomp-cens.R’ [2s/2s]
  Running ‘t-weird-qqcomp-cens.R’ [2s/2s]
Running the tests in ‘tests/t-fitdistcens.R’ failed.
Complete output:
  > library(fitdistrplus)
  Loading required package: MASS
  Loading required package: survival
  Loading required package: npsurv
  Loading required package: lsei
  > 
  > nsample <- 500
  > nsample <- 50
  > visualize <- FALSE # TRUE for manual tests with visualization of results
  > 
  > # (6) custom optimisation function - example with the genetic algorithm
  > #
  > data(fluazinam)
  > log10EC50 <-log10(fluazinam)
  > 
  >   #wrap genoud function rgenoud package
  >   mygenoud  <-  function(fn, par, ...) 
  +   {
  +     require(rgenoud)
  +     res  <-  genoud(fn, starting.values=par, ...)        
  +     standardres  <-  c(res, convergence=0)
  +     
  +     return(standardres)
  +   }
  >   
  >   # call fitdistcens with a 'custom' optimization function
  >   fit.with.genoud <- fitdistcens(log10EC50, "logis", custom.optim=mygenoud, nvars=2, 
  +                                  start=list(location=0, scale=1),    
  +                                  Domains=cbind(c(0,0), c(5, 5)), boundary.enforcement=1, 
  +                                  print.level=1, hessian=TRUE)
  Loading required package: rgenoud
  ##  rgenoud (Version 5.8-2.0, Build Date: 2018-04-03)
  ##  See http://sekhon.berkeley.edu/rgenoud for additional documentation.
  ##  Please cite software as:
  ##   Walter Mebane, Jr. and Jasjeet S. Sekhon. 2011.
  ##   ``Genetic Optimization Using Derivatives: The rgenoud package for R.''
  ##   Journal of Statistical Software, 42(11): 1-26. 
  ##
  
  
  
  Fri Nov  2 20:46:42 2018
  Domains:
   0.000000e+00   <=  X1   <=    5.000000e+00 
   0.000000e+00   <=  X2   <=    5.000000e+00 
  
  Data Type: Floating Point
  Operators (code number, name, population) 
  	(1) Cloning........................... 	122
  	(2) Uniform Mutation.................. 	125
  	(3) Boundary Mutation................. 	125
  	(4) Non-Uniform Mutation.............. 	125
  	(5) Polytope Crossover................ 	125
  	(6) Simple Crossover.................. 	126
  	(7) Whole Non-Uniform Mutation........ 	125
  	(8) Heuristic Crossover............... 	126
  	(9) Local-Minimum Crossover........... 	0
  
  HARD Maximum Number of Generations: 100
  Maximum Nonchanging Generations: 10
  Population size       : 1000
  Convergence Tolerance: 1.000000e-03
  
  Using the BFGS Derivative Based Optimizer on the Best Individual Each Generation.
  Checking Gradients before Stopping.
  Not Using Out of Bounds Individuals But Allowing Trespassing.
  
  Minimization Problem.
  
  
  Generation#	    Solution Value
  
        0 	2.059813e+01
        1 	2.055391e+01
  
  'wait.generations' limit reached.
  No significant improvement in 10 generations.
  
  Solution Fitness Value: 2.055391e+01
  
  Parameters at the Solution (parameter, gradient):
  
   X[ 1] :	2.151911e+00	G[ 1] :	1.873865e-06
   X[ 2] :	6.909666e-01	G[ 2] :	1.457498e-05
  
  Solution Found Generation 1
  Number of Generations Run 12
  
  Fri Nov  2 20:46:46 2018
  Total run time : 0 hours 0 minutes and 4 seconds
  >   
  >   summary(fit.with.genoud)
  Fitting of the distribution ' logis ' By maximum likelihood on censored data 
  Parameters
            estimate Std. Error
  location 2.1519106  0.3222568
  scale    0.6909666  0.1744837
  Loglikelihood:  -20.55391   AIC:  45.10781   BIC:  46.38593 
  Correlation matrix:
             [,1]       [,2]
  [1,] 1.00000000 0.05106561
  [2,] 0.05106561 1.00000000
  
  > 
  > 
  > # (9) check keepdata
  > #
  > if (visualize) # LONG TO RUN ON CRAN AND NEEDS VISALIZATION OF RESULTS
  + {
  +   set.seed(1234)
  +   x <- rexp(1e3, 5)
  +   # x <- data.frame(left=x, right=x+rexp(x, 1/2))
  +   x <- data.frame(left=x, right=x)
  +   f1 <- fitdistcens(x, "exp", keepdata=FALSE)
  +   f2 <- fitdistcens(x, "exp", keepdata=TRUE)
  +   f1$censdata
  +   f2$censdata
  +   plot(f1)
  +   plot(f2)
  +   
  + }
  > 
  > 
  > # (9) fixing parameters
  > #
  > x <- rexp(nsample, 5)
  > x <- data.frame(left=x, right=x+.1)
  > 
  > f1 <- fitdistcens(x, "gamma", fix.arg=list(shape=1.5))
  > f1
  Fitting of the distribution ' gamma ' on censored data by maximum likelihood 
  Parameters:
       estimate
  rate 5.831247
  Fixed parameters:
        value
  shape   1.5
  > f1$fix.arg
  $shape
  [1] 1.5
  
  > 
  > f1 <- fitdistcens(x, "gamma", fix.arg=function(x) list(shape=1.5))
  > f1
  Fitting of the distribution ' gamma ' on censored data by maximum likelihood 
  Parameters:
       estimate
  rate 5.831247
  Fixed parameters (computed by a user-supplied function):
        value
  shape   1.5
  > f1$fix.arg.fun
  function (x) 
  list(shape = 1.5)
  > 
  > 
  > # (10) weights
  > #
  > data(salinity)
  > salinity.unique <- unique(salinity)
  > string.unique <- paste(salinity.unique$left, salinity.unique$right)
  > string.salinity <- paste(salinity$left, salinity$right)
  > nobs <- nrow(salinity.unique)
  > salinity.weights <- numeric(nobs)
  > for (i in 1:nobs)
  + {
  +   salinity.weights[i] <- length(which(string.salinity == string.unique[i]))
  + }
  > cbind(salinity.unique, salinity.weights)
       left right salinity.weights
  1   20.00    NA                8
  6   21.50  21.5                1
  7   15.00  30.0                1
  8   20.00  25.0                1
  9   23.70  23.7                1
  10  25.00    NA                5
  13  20.00  30.0                3
  18   3.20  47.0                2
  20  26.10  26.1                1
  21  26.20  26.2                1
  22  25.00  30.0                1
  23  29.10  29.1                2
  25  30.00    NA               10
  30  30.00  30.0                1
  36  30.00  35.0                2
  38  35.00  35.0                1
  39  35.00    NA                2
  41  25.00  47.0                1
  42  30.00  47.0                1
  43  30.00  50.0                1
  44  35.00  47.0                1
  45  43.90  43.9                1
  46  35.00  55.0                1
  47  45.70  45.7                1
  48  47.00    NA                3
  50  47.00  47.0                2
  53  49.00  49.0                1
  54   0.10    NA                5
  59   0.23    NA                1
  60   3.20    NA                3
  63   6.40    NA                6
  69   3.20  12.8                1
  70   6.40  12.8                1
  71   0.10  20.0                1
  72   3.20  20.0                1
  73  12.60  12.6                1
  74  12.80  12.8                2
  75  12.80    NA               10
  86  12.80  15.0                2
  88  15.00    NA                7
  90  15.00  15.0                3
  98   6.40  25.0                1
  99  15.00  20.0                1
  100  6.40  30.0                1
  101 12.80  25.0                2
  103  3.20  35.0                1
  104 15.00  25.0                1
  105 12.80  20.0                1
  > 
  > (fa <- fitdistcens(salinity, "lnorm"))
  Fitting of the distribution ' lnorm ' on censored data by maximum likelihood 
  Parameters:
           estimate
  meanlog 3.3854230
  sdlog   0.4961333
  > (fb <- fitdistcens(salinity.unique, "lnorm", weights = salinity.weights)) # should give the same results
  Fitting of the distribution ' lnorm ' on censored data by maximum likelihood 
  Parameters:
           estimate
  meanlog 3.3854550
  sdlog   0.4961777
  Warning message:
  In mledist(censdata, distname, start = arg_startfix$start.arg, fix.arg = arg_startfix$fix.arg,  :
    weights are not taken into account in the default initial values
  > 
  > # (11) check the warning messages when using weights in the fit followed by functions
  > # that do not yet take weights into account
  > # with an example to be used later to see if weights are well taken into account
  > #
  > x <- rexp(100, 5)
  > x <- sort(x)
  > x <- data.frame(left=x, right=x+.1)
  > (f <- fitdistcens(x, "gamma", weights=c(rep(10, 50), rep(1, 50))))
  <simpleError in optim(par = vstart, fn = fnobjcens, fix.arg = fix.arg, gr = gradient,     rcens = rcens, lcens = lcens, icens = icens, ncens = ncens,     ddistnam = ddistname, pdistnam = pdistname, hessian = TRUE,     method = meth, lower = lower, upper = upper, ...): non-finite finite-difference value [1]>
  Error in fitdistcens(x, "gamma", weights = c(rep(10, 50), rep(1, 50))) : 
    the function mle failed to estimate the parameters, 
          with the error code 100
  In addition: Warning message:
  In mledist(censdata, distname, start = arg_startfix$start.arg, fix.arg = arg_startfix$fix.arg,  :
    weights are not taken into account in the default initial values
  Execution halted