R Under development (unstable) (2024-10-16 r87241 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. > > require(OneStep) Loading required package: OneStep Loading required package: fitdistrplus Loading required package: MASS Loading required package: survival Loading required package: numDeriv Loading required package: parallel Loading required package: extraDistr > > #### onestep numerical #### > n <- 1e3 > x <- c(rexp(n), rgamma(n, 1/2)) > dexpgamma <- function(x, shape1, rate1, rate2) + 1/2*dgamma(x, shape1, rate1) + 1/2*dexp(x, rate2) > > onestep(x, "expgamma", control=list(trace=1), start=list(shape1=2, rate1=2, rate2=2)) * one step numeric * one step result before processing output $estimate shape1 rate1 rate2 1.887854 1.502706 5.172670 $convergence [1] 0 $value NULL $hessian NULL $optim.function NULL $opt.meth NULL $fix.arg NULL $fix.arg.fun NULL $weights NULL $counts NULL $optim.message NULL $method [1] "numeric" $order NULL $memp NULL $nbstep [1] 1 Parameters: estimate Std. Error shape1 1.887854 NA rate1 1.502706 NA rate2 5.172670 NA > onestep(x, "expgamma", control=list(trace=2), start=list(shape1=2, rate1=2, rate2=2)) * one step numeric Nelder-Mead direct search function minimizer function value for initial parameters = 695.730664 Scaled convergence tolerance is 1.03672e-05 Stepsize computed as 0.200000 BUILD 4 712.700216 683.274612 EXTENSION 6 695.730664 664.168511 EXTENSION 8 693.178934 655.058605 REFLECTION 10 683.274612 643.274482 HI-REDUCTION 12 664.168511 643.274482 EXTENSION 14 660.160491 627.692152 LO-REDUCTION 16 655.058605 627.692152 EXTENSION 18 643.274482 612.234718 LO-REDUCTION 20 641.065857 612.234718 EXTENSION 22 627.692152 589.953255 LO-REDUCTION 24 612.491535 589.953255 REFLECTION 26 612.234718 583.929873 REFLECTION 28 590.645887 581.268656 HI-REDUCTION 30 589.953255 581.268656 REFLECTION 32 584.166984 579.343506 HI-REDUCTION 34 583.929873 579.343506 REFLECTION 36 581.268656 578.267256 LO-REDUCTION 38 581.077828 578.267256 LO-REDUCTION 40 579.343506 578.267256 EXTENSION 42 578.921564 577.369915 HI-REDUCTION 44 578.840090 577.369915 REFLECTION 46 578.267256 577.214919 EXTENSION 48 577.791223 576.122617 LO-REDUCTION 50 577.369915 576.122617 LO-REDUCTION 52 577.214919 576.122617 LO-REDUCTION 54 576.826655 576.122617 LO-REDUCTION 56 576.265287 576.114333 HI-REDUCTION 58 576.212762 576.112655 LO-REDUCTION 60 576.122617 576.064189 HI-REDUCTION 62 576.114333 576.064189 HI-REDUCTION 64 576.112655 576.064189 HI-REDUCTION 66 576.070964 576.064189 HI-REDUCTION 68 576.067388 576.060489 HI-REDUCTION 70 576.066450 576.058158 HI-REDUCTION 72 576.064189 576.058158 HI-REDUCTION 74 576.060489 576.058149 LO-REDUCTION 76 576.059219 576.057280 REFLECTION 78 576.058158 576.057045 HI-REDUCTION 80 576.058149 576.056689 LO-REDUCTION 82 576.057280 576.056689 HI-REDUCTION 84 576.057045 576.056494 HI-REDUCTION 86 576.056806 576.056494 LO-REDUCTION 88 576.056689 576.056492 REFLECTION 90 576.056549 576.056440 HI-REDUCTION 92 576.056494 576.056412 HI-REDUCTION 94 576.056492 576.056409 LO-REDUCTION 96 576.056440 576.056399 HI-REDUCTION 98 576.056412 576.056396 HI-REDUCTION 100 576.056409 576.056386 Exiting from Nelder Mead minimizer 102 function evaluations used ** sub-sample init shape1 rate1 rate2 1.939111 1.551976 6.062622 * one step result before processing output $estimate shape1 rate1 rate2 1.943143 1.538979 4.857036 $convergence [1] 0 $value NULL $hessian NULL $optim.function NULL $opt.meth NULL $fix.arg NULL $fix.arg.fun NULL $weights NULL $counts NULL $optim.message NULL $method [1] "numeric" $order NULL $memp NULL $nbstep [1] 1 ** one step output List of 19 $ estimate : Named num [1:3] 1.94 1.54 4.86 ..- attr(*, "names")= chr [1:3] "shape1" "rate1" "rate2" $ method : chr "numeric" $ sd : logi NA $ cor : logi NA $ vcov : logi NA $ loglik : num -1292 $ aic : num 2590 $ bic : num 2607 $ n : int 2000 $ data : num [1:2000] 1.1799 2.681 0.7511 0.0982 1.2049 ... $ distname : chr "expgamma" $ fix.arg : NULL $ fix.arg.fun: NULL $ dots :List of 1 ..$ start:List of 3 .. ..$ shape1: num 2 .. ..$ rate1 : num 2 .. ..$ rate2 : num 2 $ convergence: num 0 $ discrete : logi FALSE $ weights : NULL $ nbstep : num 1 $ delta : num 0.9 NULL Parameters: estimate Std. Error shape1 1.943143 NA rate1 1.538979 NA rate2 4.857036 NA > onestep(x, "expgamma", control=list(trace=3), start=list(shape1=2, rate1=2, rate2=2)) * one step numeric Nelder-Mead direct search function minimizer function value for initial parameters = 707.110803 Scaled convergence tolerance is 1.05368e-05 Stepsize computed as 0.200000 BUILD 4 723.531066 696.788281 EXTENSION 6 707.110803 680.333107 EXTENSION 8 705.433153 674.609297 REFLECTION 10 696.788281 663.573250 HI-REDUCTION 12 680.333107 663.573250 EXTENSION 14 676.007887 650.748879 LO-REDUCTION 16 674.609297 650.748879 EXTENSION 18 664.686064 639.821522 EXTENSION 20 663.573250 634.218411 EXTENSION 22 650.748879 622.109739 REFLECTION 24 639.821522 620.676344 HI-REDUCTION 26 634.218411 620.676344 REFLECTION 28 625.606436 617.366799 HI-REDUCTION 30 622.109739 617.366799 LO-REDUCTION 32 620.676344 617.366799 LO-REDUCTION 34 619.937537 617.366799 LO-REDUCTION 36 617.918691 617.366799 HI-REDUCTION 38 617.733754 617.366799 HI-REDUCTION 40 617.705556 617.366799 HI-REDUCTION 42 617.463693 617.366799 HI-REDUCTION 44 617.450202 617.365959 REFLECTION 46 617.421657 617.323553 LO-REDUCTION 48 617.366799 617.321808 HI-REDUCTION 50 617.365959 617.315654 HI-REDUCTION 52 617.323553 617.313798 HI-REDUCTION 54 617.321808 617.302237 HI-REDUCTION 56 617.315654 617.302237 LO-REDUCTION 58 617.313798 617.302237 LO-REDUCTION 60 617.308028 617.302237 HI-REDUCTION 62 617.304706 617.302237 HI-REDUCTION 64 617.302604 617.301599 HI-REDUCTION 66 617.302375 617.301452 HI-REDUCTION 68 617.302237 617.301291 HI-REDUCTION 70 617.301599 617.301291 HI-REDUCTION 72 617.301452 617.301181 LO-REDUCTION 74 617.301337 617.301181 HI-REDUCTION 76 617.301291 617.301162 HI-REDUCTION 78 617.301206 617.301149 LO-REDUCTION 80 617.301181 617.301135 LO-REDUCTION 82 617.301162 617.301135 HI-REDUCTION 84 617.301149 617.301135 Exiting from Nelder Mead minimizer 86 function evaluations used ** sub-sample init shape1 rate1 rate2 1.819542 1.442749 4.770384 *** step, Ichap, Scorechap [1] -0.10440675 -0.09158416 -0.36663997 [,1] [,2] [,3] [1,] 415.426944 -496.99023 8.963063 [2,] -496.990226 727.17878 -24.399246 [3,] 8.963063 -24.39925 16.021829 [1] -1.143163 -5.763183 -4.575463 * one step result before processing output $estimate shape1 rate1 rate2 1.923949 1.534333 5.137024 $convergence [1] 0 $value NULL $hessian NULL $optim.function NULL $opt.meth NULL $fix.arg NULL $fix.arg.fun NULL $weights NULL $counts NULL $optim.message NULL $method [1] "numeric" $order NULL $memp NULL $nbstep [1] 1 ** one step output List of 19 $ estimate : Named num [1:3] 1.92 1.53 5.14 ..- attr(*, "names")= chr [1:3] "shape1" "rate1" "rate2" $ method : chr "numeric" $ sd : logi NA $ cor : logi NA $ vcov : logi NA $ loglik : num -1291 $ aic : num 2589 $ bic : num 2606 $ n : int 2000 $ data : num [1:2000] 1.1799 2.681 0.7511 0.0982 1.2049 ... $ distname : chr "expgamma" $ fix.arg : NULL $ fix.arg.fun: NULL $ dots :List of 1 ..$ start:List of 3 .. ..$ shape1: num 2 .. ..$ rate1 : num 2 .. ..$ rate2 : num 2 $ convergence: num 0 $ discrete : logi FALSE $ weights : NULL $ nbstep : num 1 $ delta : num 0.9 NULL Parameters: estimate Std. Error shape1 1.923949 NA rate1 1.534333 NA rate2 5.137024 NA > > onestep(x, "expgamma", control=list(trace=3, REPORT=2), start=list(shape1=2, rate1=2, rate2=2), optim.method="BFGS") * one step numeric initial value 714.326049 iter 2 value 679.692007 iter 4 value 645.373579 iter 6 value 624.380996 iter 8 value 622.899590 iter 10 value 622.860115 iter 12 value 622.827434 final value 622.827347 converged ** sub-sample init shape1 rate1 rate2 2.106826 1.650236 5.209677 *** step, Ichap, Scorechap [1] 0.21309207 0.13153592 0.02283104 [,1] [,2] [,3] [1,] 358.3001 -437.01184 18.04110 [2,] -437.0118 642.42674 -26.94027 [3,] 18.0411 -26.94027 13.77725 [1] 19.2800584 -9.2366388 0.6153498 * one step result before processing output $estimate shape1 rate1 rate2 1.893734 1.518700 5.186846 $convergence [1] 0 $value NULL $hessian NULL $optim.function NULL $opt.meth NULL $fix.arg NULL $fix.arg.fun NULL $weights NULL $counts NULL $optim.message NULL $method [1] "numeric" $order NULL $memp NULL $nbstep [1] 1 ** one step output List of 19 $ estimate : Named num [1:3] 1.89 1.52 5.19 ..- attr(*, "names")= chr [1:3] "shape1" "rate1" "rate2" $ method : chr "numeric" $ sd : logi NA $ cor : logi NA $ vcov : logi NA $ loglik : num -1291 $ aic : num 2589 $ bic : num 2606 $ n : int 2000 $ data : num [1:2000] 1.1799 2.681 0.7511 0.0982 1.2049 ... $ distname : chr "expgamma" $ fix.arg : NULL $ fix.arg.fun: NULL $ dots :List of 2 ..$ start :List of 3 .. ..$ shape1: num 2 .. ..$ rate1 : num 2 .. ..$ rate2 : num 2 ..$ optim.method: chr "BFGS" $ convergence: num 0 $ discrete : logi FALSE $ weights : NULL $ nbstep : num 1 $ delta : num 0.9 NULL Parameters: estimate Std. Error shape1 1.893734 NA rate1 1.518700 NA rate2 5.186846 NA > > > #### onestep closed form with subsample #### > > n <- 1e3 > > x <- 1+2*rt(n, 15) > > require(extraDistr) > > onestep(x, "lst", control=list(trace=1, delta=1/3)) * one step closed formula * one step result before processing output $estimate mu sigma df 0.9398053 2.0230411 10.5840320 $convergence [1] 0 $value NULL $hessian NULL $optim.function NULL $opt.meth NULL $fix.arg NULL $fix.arg.fun NULL $weights NULL $counts NULL $optim.message NULL $loglik NULL $method [1] "closed formula" $order [1] 0 $memp NULL $nbstep [1] 2 Parameters: estimate Std. Error mu 0.9398053 NA sigma 2.0230411 NA df 10.5840320 NA > onestep(x, "lst", control=list(trace=2, delta=1/3)) * one step closed formula ** default init [1] 5.9570538 1.8940209 0.8844329 * one step result before processing output $estimate mu sigma df 0.9398053 2.0230411 10.5840320 $convergence [1] 0 $value NULL $hessian NULL $optim.function NULL $opt.meth NULL $fix.arg NULL $fix.arg.fun NULL $weights NULL $counts NULL $optim.message NULL $loglik NULL $method [1] "closed formula" $order [1] 0 $memp NULL $nbstep [1] 2 ** one step output List of 19 $ estimate : Named num [1:3] 0.94 2.02 10.58 ..- attr(*, "names")= chr [1:3] "mu" "sigma" "df" $ method : chr "closed formula" $ sd : logi NA $ cor : logi NA $ vcov : logi NA $ loglik : num -2213 $ aic : num 4432 $ bic : num 4447 $ n : int 1000 $ data : num [1:1000] 1.627 -1.191 0.741 -1.03 2.711 ... $ distname : chr "lst" $ fix.arg : NULL $ fix.arg.fun: NULL $ dots : NULL $ convergence: num 0 $ discrete : logi FALSE $ weights : NULL $ nbstep : num 2 $ delta : num 0.333 NULL Parameters: estimate Std. Error mu 0.9398053 NA sigma 2.0230411 NA df 10.5840320 NA > > onestep(x, "lst", control=list(trace=1, delta=2/3)) * one step closed formula * one step result before processing output $estimate mu sigma df 0.9320679 2.2484065 -1936.2053978 $convergence [1] 0 $value NULL $hessian NULL $optim.function NULL $opt.meth NULL $fix.arg NULL $fix.arg.fun NULL $weights NULL $counts NULL $optim.message NULL $loglik NULL $method [1] "closed formula" $order [1] 0 $memp NULL $nbstep [1] 2 Parameters: estimate Std. Error mu 0.9320679 NA sigma 2.2484065 NA df -1936.2053978 NA Warning message: In cpp_dlst(x, df, mu, sigma, log[1L]) : NaNs produced > onestep(x, "lst", control=list(trace=2, delta=2/3)) * one step closed formula Nelder-Mead direct search function minimizer function value for initial parameters = 217.675451 Scaled convergence tolerance is 3.24362e-06 Stepsize computed as 1.000000 BUILD 4 239.831754 217.675451 LO-REDUCTION 6 219.757371 214.147061 HI-REDUCTION 8 217.800360 214.147061 LO-REDUCTION 10 217.675451 213.995469 HI-REDUCTION 12 214.481137 213.512556 LO-REDUCTION 14 214.147061 213.512556 LO-REDUCTION 16 213.995469 213.350345 HI-REDUCTION 18 213.555620 213.350345 HI-REDUCTION 20 213.512556 213.281527 HI-REDUCTION 22 213.409098 213.281527 HI-REDUCTION 24 213.350345 213.281527 REFLECTION 26 213.293925 213.277367 HI-REDUCTION 28 213.290064 213.242264 HI-REDUCTION 30 213.281527 213.242264 REFLECTION 32 213.277367 213.231641 HI-REDUCTION 34 213.260842 213.231641 EXTENSION 36 213.245918 213.199274 LO-REDUCTION 38 213.242264 213.199274 EXTENSION 40 213.231641 213.164164 LO-REDUCTION 42 213.226109 213.164164 EXTENSION 44 213.199274 213.086140 LO-REDUCTION 46 213.183913 213.086140 EXTENSION 48 213.164164 213.031619 EXTENSION 50 213.087949 212.870276 LO-REDUCTION 52 213.086140 212.870276 REFLECTION 54 213.031619 212.856305 EXTENSION 56 212.914717 212.639650 EXTENSION 58 212.870276 212.533506 LO-REDUCTION 60 212.856305 212.533506 EXTENSION 62 212.639650 212.299491 EXTENSION 64 212.557680 212.168455 REFLECTION 66 212.533506 212.160437 EXTENSION 68 212.299491 212.056728 EXTENSION 70 212.168455 211.848489 LO-REDUCTION 72 212.160437 211.848489 LO-REDUCTION 74 212.056728 211.848489 REFLECTION 76 211.925594 211.781772 HI-REDUCTION 78 211.911994 211.781772 LO-REDUCTION 80 211.851957 211.781772 HI-REDUCTION 82 211.848489 211.781772 EXTENSION 84 211.817653 211.715467 LO-REDUCTION 86 211.801218 211.715467 EXTENSION 88 211.781772 211.656266 EXTENSION 90 211.730676 211.614593 EXTENSION 92 211.715467 211.585346 EXTENSION 94 211.656266 211.553846 LO-REDUCTION 96 211.614593 211.553846 LO-REDUCTION 98 211.586655 211.553846 EXTENSION 100 211.585346 211.525482 Exiting from Nelder Mead minimizer 102 function evaluations used ** default init df sigma mu 122.010593 2.026222 1.011428 * one step result before processing output $estimate mu sigma df 0.9320679 2.2484065 -1936.2053978 $convergence [1] 0 $value NULL $hessian NULL $optim.function NULL $opt.meth NULL $fix.arg NULL $fix.arg.fun NULL $weights NULL $counts NULL $optim.message NULL $loglik NULL $method [1] "closed formula" $order [1] 0 $memp NULL $nbstep [1] 2 ** one step output List of 19 $ estimate : Named num [1:3] 0.932 2.248 -1936.205 ..- attr(*, "names")= chr [1:3] "mu" "sigma" "df" $ method : chr "closed formula" $ sd : logi NA $ cor : logi NA $ vcov : logi NA $ loglik : num NaN $ aic : num NaN $ bic : num NaN $ n : int 1000 $ data : num [1:1000] 1.627 -1.191 0.741 -1.03 2.711 ... $ distname : chr "lst" $ fix.arg : NULL $ fix.arg.fun: NULL $ dots : NULL $ convergence: num 0 $ discrete : logi FALSE $ weights : NULL $ nbstep : num 2 $ delta : num 0.667 NULL Parameters: estimate Std. Error mu 0.9320679 NA sigma 2.2484065 NA df -1936.2053978 NA Warning message: In cpp_dlst(x, df, mu, sigma, log[1L]) : NaNs produced > onestep(x, "lst", control=list(trace=3, delta=2/3)) * one step closed formula Nelder-Mead direct search function minimizer function value for initial parameters = 217.675451 Scaled convergence tolerance is 3.24362e-06 Stepsize computed as 1.000000 BUILD 4 239.831754 217.675451 LO-REDUCTION 6 219.757371 214.147061 HI-REDUCTION 8 217.800360 214.147061 LO-REDUCTION 10 217.675451 213.995469 HI-REDUCTION 12 214.481137 213.512556 LO-REDUCTION 14 214.147061 213.512556 LO-REDUCTION 16 213.995469 213.350345 HI-REDUCTION 18 213.555620 213.350345 HI-REDUCTION 20 213.512556 213.281527 HI-REDUCTION 22 213.409098 213.281527 HI-REDUCTION 24 213.350345 213.281527 REFLECTION 26 213.293925 213.277367 HI-REDUCTION 28 213.290064 213.242264 HI-REDUCTION 30 213.281527 213.242264 REFLECTION 32 213.277367 213.231641 HI-REDUCTION 34 213.260842 213.231641 EXTENSION 36 213.245918 213.199274 LO-REDUCTION 38 213.242264 213.199274 EXTENSION 40 213.231641 213.164164 LO-REDUCTION 42 213.226109 213.164164 EXTENSION 44 213.199274 213.086140 LO-REDUCTION 46 213.183913 213.086140 EXTENSION 48 213.164164 213.031619 EXTENSION 50 213.087949 212.870276 LO-REDUCTION 52 213.086140 212.870276 REFLECTION 54 213.031619 212.856305 EXTENSION 56 212.914717 212.639650 EXTENSION 58 212.870276 212.533506 LO-REDUCTION 60 212.856305 212.533506 EXTENSION 62 212.639650 212.299491 EXTENSION 64 212.557680 212.168455 REFLECTION 66 212.533506 212.160437 EXTENSION 68 212.299491 212.056728 EXTENSION 70 212.168455 211.848489 LO-REDUCTION 72 212.160437 211.848489 LO-REDUCTION 74 212.056728 211.848489 REFLECTION 76 211.925594 211.781772 HI-REDUCTION 78 211.911994 211.781772 LO-REDUCTION 80 211.851957 211.781772 HI-REDUCTION 82 211.848489 211.781772 EXTENSION 84 211.817653 211.715467 LO-REDUCTION 86 211.801218 211.715467 EXTENSION 88 211.781772 211.656266 EXTENSION 90 211.730676 211.614593 EXTENSION 92 211.715467 211.585346 EXTENSION 94 211.656266 211.553846 LO-REDUCTION 96 211.614593 211.553846 LO-REDUCTION 98 211.586655 211.553846 EXTENSION 100 211.585346 211.525482 Exiting from Nelder Mead minimizer 102 function evaluations used ** default init df sigma mu 122.010593 2.026222 1.011428 ** after one-step [1] -1935.3825135 1.9304915 0.9340339 * one step result before processing output $estimate mu sigma df 0.9320679 2.2484065 -1936.2053978 $convergence [1] 0 $value NULL $hessian NULL $optim.function NULL $opt.meth NULL $fix.arg NULL $fix.arg.fun NULL $weights NULL $counts NULL $optim.message NULL $loglik NULL $method [1] "closed formula" $order [1] 0 $memp NULL $nbstep [1] 2 ** one step output List of 19 $ estimate : Named num [1:3] 0.932 2.248 -1936.205 ..- attr(*, "names")= chr [1:3] "mu" "sigma" "df" $ method : chr "closed formula" $ sd : logi NA $ cor : logi NA $ vcov : logi NA $ loglik : num NaN $ aic : num NaN $ bic : num NaN $ n : int 1000 $ data : num [1:1000] 1.627 -1.191 0.741 -1.03 2.711 ... $ distname : chr "lst" $ fix.arg : NULL $ fix.arg.fun: NULL $ dots : NULL $ convergence: num 0 $ discrete : logi FALSE $ weights : NULL $ nbstep : num 2 $ delta : num 0.667 NULL Parameters: estimate Std. Error mu 0.9320679 NA sigma 2.2484065 NA df -1936.2053978 NA Warning message: In cpp_dlst(x, df, mu, sigma, log[1L]) : NaNs produced > > > proc.time() user system elapsed 2.67 0.31 2.93