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 > require(actuar) Loading required package: actuar Attaching package: 'actuar' The following objects are masked from 'package:extraDistr': dgumbel, dinvgamma, dpareto, pgumbel, pinvgamma, ppareto, qgumbel, qinvgamma, qpareto, rgumbel, rinvgamma, rpareto The following objects are masked from 'package:stats': sd, var The following object is masked from 'package:grDevices': cm > > n <- 1e3 > > #### G1 <- c("norm", "exp", "lnorm", "invgauss", "pois", "geom") # Distributions for which the explicit MLE is returned #### > > x <- rexp(n) > os <- onestep(x, "exp", method="numeric") Warning message: In onestep(x, "exp", method = "numeric") : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate rate 1.008652 Loglikelihood: -991.1173 AIC: 1984.235 BIC: 1989.142 > print(os) Parameters: estimate rate 1.008652 > class(os) [1] "onestep" "fitdist" > plot(os) > > x <- rlnorm(n, 0, 1) > os <- onestep(x, "lnorm", method="numeric") Warning message: In onestep(x, "lnorm", method = "numeric") : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate meanlog 0.03020786 sdlog 1.03457305 Loglikelihood: -1483.186 AIC: 2970.373 BIC: 2980.188 > plot(os) > > #### G2 <- c("unif", "logis") # Special distributions #### > > > x <- rlogis(n) > os <- onestep(x, "logis", method="numeric") Warning message: In onestep(x, "logis", method = "numeric") : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate location 0.03077168 scale 0.99673718 Loglikelihood: -1993.833 AIC: 3991.665 BIC: 4001.481 > le <- fitdist(x, "logis") > summary(le) Fitting of the distribution ' logis ' by maximum likelihood Parameters : estimate Std. Error location 0.03080639 0.05493861 scale 0.99902627 0.02630799 Loglikelihood: -1993.829 AIC: 3991.658 BIC: 4001.474 Correlation matrix: location scale location 1.000000000 -0.008267198 scale -0.008267198 1.000000000 > > > #### G3 <- c("gamma", "beta", "nbinom") # Distributions with a default MME initial guess estimator #### > > x <- rbeta(n, 3, 2) > os <- onestep(x, "beta", method="numeric") Warning message: In onestep(x, "beta", method = "numeric") : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate shape1 3.124408 shape2 2.126766 Loglikelihood: 248.4503 AIC: -492.9007 BIC: -483.0852 > os <- onestep(x, "beta", method="numeric", init=list(shape1=1, shape2=1)) Warning message: In onestep(x, "beta", method = "numeric", init = list(shape1 = 1, : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate shape1 1.638080 shape2 1.352755 Loglikelihood: 157.8493 AIC: -311.6986 BIC: -301.8831 > > x <- rgamma(n, 3, 2) > os <- onestep(x, "gamma", method="numeric") Warning message: In onestep(x, "gamma", method = "numeric") : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate shape 3.016845 rate 1.986529 Loglikelihood: -1164.432 AIC: 2332.864 BIC: 2342.679 > os <- onestep(x, "gamma", method="numeric", init=list(shape=1, scale=1.5)) Warning message: In onestep(x, "gamma", method = "numeric", init = list(shape = 1, : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate shape 1.6018459 scale 0.6374925 Loglikelihood: -1402.421 AIC: 2808.841 BIC: 2818.657 > os <- onestep(x, "gamma", method="numeric", init=list(shape=1, rate=1.5)) Warning messages: 1: In onestep(x, "gamma", method = "numeric", init = list(shape = 1, : argument 'method' could be set to 'closed formula' 2: In dgamma(c(1.12107910204795, 0.591788419457487, 0.676854298042977, : NaNs produced > summary(os) Parameters : estimate shape 0.9191125 rate -0.5384652 Loglikelihood: NaN AIC: NaN BIC: NaN > > x <- rnbinom(n, 3, 1/3) #mu=size*(1-prob)/prob=6 > os <- onestep(x, "nbinom", method="numeric") Warning message: In onestep(x, "nbinom", method = "numeric") : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate size 3.032708 mu 6.482028 Loglikelihood: -2795.881 AIC: 5595.761 BIC: 5605.577 > os <- onestep(x, "nbinom", method="numeric", init=list(size=10, mu=2)) Warning message: In onestep(x, "nbinom", method = "numeric", init = list(size = 10, : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate size 13.21117 mu 3.30637 Loglikelihood: -3855.557 AIC: 7715.114 BIC: 7724.93 > os <- onestep(x, "nbinom", method="numeric", init=list(size=10, prob=5/6)) Warning message: In onestep(x, "nbinom", method = "numeric", init = list(size = 10, : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate size 15.3092456 prob 0.7505049 Loglikelihood: -3107.224 AIC: 6218.449 BIC: 6228.264 > > > > > #### G4 <- c("cauchy", "weibull", "pareto") # Distributions with a special initial guess estimator #### > > x <- rweibull(n, 3, 2) > os <- onestep(x, "weibull", method="numeric") Warning message: In onestep(x, "weibull", method = "numeric") : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate shape 2.878725 scale 2.016120 Loglikelihood: -1021.336 AIC: 2046.672 BIC: 2056.488 > os <- onestep(x, "weibull", method="numeric", init=list(shape=1, scale=1)) Warning message: In onestep(x, "weibull", method = "numeric", init = list(shape = 1, : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate shape 2.845507 scale 2.719258 Loglikelihood: -1302.378 AIC: 2608.755 BIC: 2618.571 > > > x <- rcauchy(n, 1, 2) > os <- onestep(x, "cauchy", method="numeric", control=list(param_t=1/4)) Warning message: In onestep(x, "cauchy", method = "numeric", control = list(param_t = 1/4)) : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate location 0.9637844 scale 1.9530067 Loglikelihood: -3191.604 AIC: 6387.208 BIC: 6397.023 > os <- onestep(x, "cauchy", method="numeric", init=list(location=0, scale=1)) Warning message: In onestep(x, "cauchy", method = "numeric", init = list(location = 0, : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate location 1.008205 scale 1.319497 Loglikelihood: -3232.287 AIC: 6468.573 BIC: 6478.389 > > > x <- rpareto(n, 1, 2) > os <- onestep(x, "pareto", method="numeric") Warning message: In onestep(x, "pareto", method = "numeric") : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate shape 0.9839815 scale 1.8122824 Loglikelihood: -2628.15 AIC: 5260.3 BIC: 5270.116 > os <- onestep(x, "pareto", method="numeric", init=list(shape=1, scale=1)) Warning message: In onestep(x, "pareto", method = "numeric", init = list(shape = 1, : argument 'method' could be set to 'closed formula' > summary(os) Parameters : estimate shape 0.6487400 scale 0.9939109 Loglikelihood: -2654.515 AIC: 5313.031 BIC: 5322.846 > > proc.time() user system elapsed 1.50 0.18 1.68