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 > > n <- 1e3 > > theta <- c(shape=0.8, scale=3) > o.sample <- rweibull(n, shape=theta["shape"], scale=theta["scale"]) > > #### numerical one-step with sub-sample init #### > #i <- 0 > > dweibull2 <- function(x, shape, scale, log=FALSE) + { + #cat("\t\tx", i, "\ttheta", shape, "/-/", scale, "\n") + if(is.function(x)) + { + stop("x is a function") + } + #i <<- i+1 + dweibull(x = x, shape = shape, scale = scale, log = log) + } > args(dweibull) function (x, shape, scale = 1, log = FALSE) NULL > > onestep(o.sample, "weibull2", method="numeric", start=list(shape=1, scale=1), control=list(trace=1)) * one step numeric * one step result before processing output $estimate shape scale 0.7934857 3.1588227 $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 shape 0.7934857 NA scale 3.1588227 NA > > mledist(o.sample, "weibull2", start=list(shape=1, scale=1)) $estimate shape scale 0.793334 3.166981 $convergence [1] 0 $value [1] 2235.323 $hessian shape scale shape 2942.6128 -135.37444 scale -135.3744 62.72158 $optim.function [1] "optim" $optim.method [1] "Nelder-Mead" $fix.arg NULL $fix.arg.fun NULL $weights NULL $counts function gradient 125 NA $optim.message NULL $loglik [1] -2235.323 $vcov NULL > > #### numerical one-step with user-supplied #### > > onestep(o.sample, "weibull", method="numeric", start=list(shape=1, scale=1), control=list(trace=1)) * one step numeric * one step result before processing output $estimate shape scale 0.7928546 3.1525591 $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 shape 0.7928546 NA scale 3.1525591 NA Warning message: In onestep(o.sample, "weibull", method = "numeric", start = list(shape = 1, : argument 'method' could be set to 'closed formula' > > proc.time() user system elapsed 1.79 0.31 2.04