R Under development (unstable) (2024-02-22 r85974 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 2.058120 1.689614 5.279895 $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 shape1 2.058120 rate1 1.689614 rate2 5.279895 > 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 = 671.083152 Scaled convergence tolerance is 9.99992e-06 Stepsize computed as 0.200000 BUILD 4 684.066185 660.319941 EXTENSION 6 671.083152 652.752898 EXTENSION 8 670.800000 647.888984 REFLECTION 10 660.319941 638.049389 HI-REDUCTION 12 652.752898 638.049389 EXTENSION 14 647.888984 622.260745 EXTENSION 16 644.582951 617.992518 REFLECTION 18 638.049389 613.664596 REFLECTION 20 622.260745 601.846111 LO-REDUCTION 22 617.992518 601.846111 REFLECTION 24 613.664596 601.765423 REFLECTION 26 602.700204 601.167017 EXTENSION 28 601.846111 590.893671 LO-REDUCTION 30 601.765423 590.663186 LO-REDUCTION 32 601.167017 590.663186 LO-REDUCTION 34 591.570437 590.663186 HI-REDUCTION 36 590.893671 589.629165 REFLECTION 38 590.720640 588.881928 HI-REDUCTION 40 590.663186 588.801088 LO-REDUCTION 42 589.629165 588.371593 HI-REDUCTION 44 588.881928 588.351537 LO-REDUCTION 46 588.801088 588.342889 REFLECTION 48 588.371593 587.925788 HI-REDUCTION 50 588.351537 587.925788 LO-REDUCTION 52 588.342889 587.925788 EXTENSION 54 588.125990 587.334993 LO-REDUCTION 56 588.032653 587.334993 EXTENSION 58 587.925788 587.081808 EXTENSION 60 587.396899 586.101918 EXTENSION 62 587.334993 585.558909 LO-REDUCTION 64 587.081808 585.558909 REFLECTION 66 586.101918 585.221123 REFLECTION 68 585.894483 585.162827 REFLECTION 70 585.558909 584.874761 LO-REDUCTION 72 585.221123 584.874761 REFLECTION 74 585.162827 584.822997 LO-REDUCTION 76 584.880134 584.774639 REFLECTION 78 584.874761 584.716852 LO-REDUCTION 80 584.822997 584.716852 LO-REDUCTION 82 584.774639 584.714596 HI-REDUCTION 84 584.718449 584.714596 HI-REDUCTION 86 584.716852 584.695768 HI-REDUCTION 88 584.715031 584.695768 REFLECTION 90 584.714596 584.694175 HI-REDUCTION 92 584.702433 584.694175 EXTENSION 94 584.697224 584.680338 HI-REDUCTION 96 584.695768 584.680338 LO-REDUCTION 98 584.694175 584.680338 REFLECTION 100 584.689636 584.678663 Exiting from Nelder Mead minimizer 102 function evaluations used ** sub-sample init shape1 rate1 rate2 2.088875 1.703956 5.181640 * one step result before processing output $estimate shape1 rate1 rate2 2.053248 1.688893 5.349502 $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] 2.05 1.69 5.35 ..- attr(*, "names")= chr [1:3] "shape1" "rate1" "rate2" $ method : chr "numeric" $ sd : logi NA $ cor : logi NA $ vcov : logi NA $ loglik : num -1233 $ aic : num 2472 $ bic : num 2489 $ n : int 2000 $ data : num [1:2000] 1.439 1.29 1.297 0.738 0.885 ... $ 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 shape1 2.053248 rate1 1.688893 rate2 5.349502 > 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 = 674.747405 Scaled convergence tolerance is 1.00545e-05 Stepsize computed as 0.200000 BUILD 4 688.224195 663.859255 EXTENSION 6 674.747405 654.816880 EXTENSION 8 674.196775 649.424418 REFLECTION 10 663.859255 639.300383 HI-REDUCTION 12 654.816880 639.300383 EXTENSION 14 649.424418 623.641789 EXTENSION 16 647.220917 620.249909 REFLECTION 18 639.300383 614.196688 REFLECTION 20 623.641789 603.488416 LO-REDUCTION 22 620.249909 603.488416 REFLECTION 24 614.196688 602.013890 LO-REDUCTION 26 604.258566 599.013675 REFLECTION 28 603.488416 595.712247 LO-REDUCTION 30 602.013890 595.712247 LO-REDUCTION 32 599.013675 594.433420 HI-REDUCTION 34 596.361217 594.433420 HI-REDUCTION 36 595.712247 594.433420 HI-REDUCTION 38 595.314460 594.433420 REFLECTION 40 594.701123 594.186932 EXTENSION 42 594.683645 592.513235 LO-REDUCTION 44 594.433420 592.513235 LO-REDUCTION 46 594.186932 592.513235 REFLECTION 48 592.874346 592.245935 REFLECTION 50 592.582597 591.900336 LO-REDUCTION 52 592.513235 591.900336 EXTENSION 54 592.245935 591.211607 REFLECTION 56 591.908309 590.859504 EXTENSION 58 591.900336 589.618223 REFLECTION 60 591.211607 589.342343 LO-REDUCTION 62 590.859504 589.342343 EXTENSION 64 589.637243 587.033292 LO-REDUCTION 66 589.618223 587.033292 LO-REDUCTION 68 589.342343 587.033292 EXTENSION 70 588.173382 586.139129 REFLECTION 72 587.930611 586.085728 LO-REDUCTION 74 587.033292 585.941206 LO-REDUCTION 76 586.139129 585.889737 HI-REDUCTION 78 586.085728 585.889737 HI-REDUCTION 80 585.941206 585.889737 LO-REDUCTION 82 585.925440 585.878072 REFLECTION 84 585.923236 585.857392 HI-REDUCTION 86 585.889737 585.857392 LO-REDUCTION 88 585.878072 585.855201 HI-REDUCTION 90 585.862652 585.853157 EXTENSION 92 585.857392 585.834902 HI-REDUCTION 94 585.855201 585.834902 HI-REDUCTION 96 585.853157 585.834902 LO-REDUCTION 98 585.843828 585.834902 EXTENSION 100 585.842882 585.821104 Exiting from Nelder Mead minimizer 102 function evaluations used ** sub-sample init shape1 rate1 rate2 1.958795 1.593352 5.128437 *** step, Ichap, Scorechap [1] -0.09599043 -0.09522780 -0.22719522 [,1] [,2] [,3] [1,] 392.18905 -456.62612 13.21988 [2,] -456.62612 647.40170 -23.76736 [3,] 13.21988 -23.76736 14.05645 [1] 2.833614 -12.419072 -2.199227 * one step result before processing output $estimate shape1 rate1 rate2 2.054786 1.688579 5.355632 $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] 2.05 1.69 5.36 ..- attr(*, "names")= chr [1:3] "shape1" "rate1" "rate2" $ method : chr "numeric" $ sd : logi NA $ cor : logi NA $ vcov : logi NA $ loglik : num -1233 $ aic : num 2472 $ bic : num 2489 $ n : int 2000 $ data : num [1:2000] 1.439 1.29 1.297 0.738 0.885 ... $ 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 shape1 2.054786 rate1 1.688579 rate2 5.355632 > > 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 685.003855 iter 2 value 644.117377 iter 4 value 605.332439 iter 6 value 597.144115 iter 8 value 596.317311 iter 10 value 596.316264 iter 12 value 596.315346 iter 12 value 596.315346 iter 12 value 596.315346 final value 596.315346 converged ** sub-sample init shape1 rate1 rate2 1.910489 1.556385 5.082625 *** step, Ichap, Scorechap [1] -0.1432144 -0.1308604 -0.2786134 [,1] [,2] [,3] [1,] 403.5171 -468.0212 11.94250 [2,] -468.0212 663.1873 -23.43500 [3,] 11.9425 -23.4350 14.13053 [1] 0.128645 -13.228265 -2.580581 * one step result before processing output $estimate shape1 rate1 rate2 2.053703 1.687245 5.361238 $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] 2.05 1.69 5.36 ..- attr(*, "names")= chr [1:3] "shape1" "rate1" "rate2" $ method : chr "numeric" $ sd : logi NA $ cor : logi NA $ vcov : logi NA $ loglik : num -1233 $ aic : num 2472 $ bic : num 2489 $ n : int 2000 $ data : num [1:2000] 1.439 1.29 1.297 0.738 0.885 ... $ 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 shape1 2.053703 rate1 1.687245 rate2 5.361238 > > > #### 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 1.033286 1.962097 8.986978 $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 mu 1.033286 sigma 1.962097 df 8.986978 > onestep(x, "lst", control=list(trace=2, delta=1/3)) * one step closed formula ** default init [1] 4.914716 1.814169 1.113965 * one step result before processing output $estimate mu sigma df 1.033286 1.962097 8.986978 $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] 1.03 1.96 8.99 ..- attr(*, "names")= chr [1:3] "mu" "sigma" "df" $ method : chr "closed formula" $ sd : logi NA $ cor : logi NA $ vcov : logi NA $ loglik : num -2198 $ aic : num 4402 $ bic : num 4416 $ n : int 1000 $ data : num [1:1000] 2.32 -2.58 -1.63 1.65 6.26 ... $ 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 mu 1.033286 sigma 1.962097 df 8.986978 > > onestep(x, "lst", control=list(trace=1, delta=2/3)) * one step closed formula * one step result before processing output $estimate mu sigma df 1.032441 1.967914 9.782311 $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 mu 1.032441 sigma 1.967914 df 9.782311 > 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 = 246.093439 Scaled convergence tolerance is 3.66708e-06 Stepsize computed as 1.000000 BUILD 4 266.957017 230.073179 LO-REDUCTION 6 247.264388 230.073179 LO-REDUCTION 8 246.093439 229.239727 LO-REDUCTION 10 231.869537 229.239727 HI-REDUCTION 12 231.008210 229.239727 LO-REDUCTION 14 230.073179 229.239727 HI-REDUCTION 16 229.522759 229.239727 LO-REDUCTION 18 229.336108 229.239727 HI-REDUCTION 20 229.297682 229.197195 HI-REDUCTION 22 229.256517 229.197195 HI-REDUCTION 24 229.239727 229.188682 HI-REDUCTION 26 229.198338 229.176322 HI-REDUCTION 28 229.197195 229.176322 LO-REDUCTION 30 229.188682 229.176322 LO-REDUCTION 32 229.177655 229.175415 REFLECTION 34 229.177260 229.174389 HI-REDUCTION 36 229.176322 229.170290 LO-REDUCTION 38 229.175415 229.170290 LO-REDUCTION 40 229.174389 229.169863 HI-REDUCTION 42 229.170838 229.169863 HI-REDUCTION 44 229.170679 229.169863 LO-REDUCTION 46 229.170290 229.169863 HI-REDUCTION 48 229.169999 229.169741 HI-REDUCTION 50 229.169866 229.169741 REFLECTION 52 229.169863 229.169685 HI-REDUCTION 54 229.169782 229.169685 REFLECTION 56 229.169741 229.169602 LO-REDUCTION 58 229.169696 229.169602 LO-REDUCTION 60 229.169685 229.169602 EXTENSION 62 229.169622 229.169515 LO-REDUCTION 64 229.169614 229.169515 HI-REDUCTION 66 229.169602 229.169515 REFLECTION 68 229.169548 229.169484 LO-REDUCTION 70 229.169534 229.169484 EXTENSION 72 229.169515 229.169451 LO-REDUCTION 74 229.169503 229.169451 EXTENSION 76 229.169484 229.169389 LO-REDUCTION 78 229.169462 229.169389 EXTENSION 80 229.169451 229.169350 REFLECTION 82 229.169418 229.169341 EXTENSION 84 229.169389 229.169258 LO-REDUCTION 86 229.169350 229.169258 LO-REDUCTION 88 229.169341 229.169258 EXTENSION 90 229.169292 229.169202 EXTENSION 92 229.169286 229.169159 EXTENSION 94 229.169258 229.169123 LO-REDUCTION 96 229.169202 229.169123 EXTENSION 98 229.169159 229.168996 LO-REDUCTION 100 229.169129 229.168996 Exiting from Nelder Mead minimizer 102 function evaluations used ** default init df sigma mu 10.041986 2.209282 1.083746 * one step result before processing output $estimate mu sigma df 1.032441 1.967914 9.782311 $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] 1.03 1.97 9.78 ..- attr(*, "names")= chr [1:3] "mu" "sigma" "df" $ method : chr "closed formula" $ sd : logi NA $ cor : logi NA $ vcov : logi NA $ loglik : num -2198 $ aic : num 4401 $ bic : num 4416 $ n : int 1000 $ data : num [1:1000] 2.32 -2.58 -1.63 1.65 6.26 ... $ 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 mu 1.032441 sigma 1.967914 df 9.782311 > 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 = 246.093439 Scaled convergence tolerance is 3.66708e-06 Stepsize computed as 1.000000 BUILD 4 266.957017 230.073179 LO-REDUCTION 6 247.264388 230.073179 LO-REDUCTION 8 246.093439 229.239727 LO-REDUCTION 10 231.869537 229.239727 HI-REDUCTION 12 231.008210 229.239727 LO-REDUCTION 14 230.073179 229.239727 HI-REDUCTION 16 229.522759 229.239727 LO-REDUCTION 18 229.336108 229.239727 HI-REDUCTION 20 229.297682 229.197195 HI-REDUCTION 22 229.256517 229.197195 HI-REDUCTION 24 229.239727 229.188682 HI-REDUCTION 26 229.198338 229.176322 HI-REDUCTION 28 229.197195 229.176322 LO-REDUCTION 30 229.188682 229.176322 LO-REDUCTION 32 229.177655 229.175415 REFLECTION 34 229.177260 229.174389 HI-REDUCTION 36 229.176322 229.170290 LO-REDUCTION 38 229.175415 229.170290 LO-REDUCTION 40 229.174389 229.169863 HI-REDUCTION 42 229.170838 229.169863 HI-REDUCTION 44 229.170679 229.169863 LO-REDUCTION 46 229.170290 229.169863 HI-REDUCTION 48 229.169999 229.169741 HI-REDUCTION 50 229.169866 229.169741 REFLECTION 52 229.169863 229.169685 HI-REDUCTION 54 229.169782 229.169685 REFLECTION 56 229.169741 229.169602 LO-REDUCTION 58 229.169696 229.169602 LO-REDUCTION 60 229.169685 229.169602 EXTENSION 62 229.169622 229.169515 LO-REDUCTION 64 229.169614 229.169515 HI-REDUCTION 66 229.169602 229.169515 REFLECTION 68 229.169548 229.169484 LO-REDUCTION 70 229.169534 229.169484 EXTENSION 72 229.169515 229.169451 LO-REDUCTION 74 229.169503 229.169451 EXTENSION 76 229.169484 229.169389 LO-REDUCTION 78 229.169462 229.169389 EXTENSION 80 229.169451 229.169350 REFLECTION 82 229.169418 229.169341 EXTENSION 84 229.169389 229.169258 LO-REDUCTION 86 229.169350 229.169258 LO-REDUCTION 88 229.169341 229.169258 EXTENSION 90 229.169292 229.169202 EXTENSION 92 229.169286 229.169159 EXTENSION 94 229.169258 229.169123 LO-REDUCTION 96 229.169202 229.169123 EXTENSION 98 229.169159 229.168996 LO-REDUCTION 100 229.169129 229.168996 Exiting from Nelder Mead minimizer 102 function evaluations used ** default init df sigma mu 10.041986 2.209282 1.083746 ** after one-step [1] 8.446724 1.939365 1.027951 * one step result before processing output $estimate mu sigma df 1.032441 1.967914 9.782311 $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] 1.03 1.97 9.78 ..- attr(*, "names")= chr [1:3] "mu" "sigma" "df" $ method : chr "closed formula" $ sd : logi NA $ cor : logi NA $ vcov : logi NA $ loglik : num -2198 $ aic : num 4401 $ bic : num 4416 $ n : int 1000 $ data : num [1:1000] 2.32 -2.58 -1.63 1.65 6.26 ... $ 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 mu 1.032441 sigma 1.967914 df 9.782311 > > > proc.time() user system elapsed 1.76 0.20 1.95