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 > 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 Std. Error rate 0.9787222 NA Loglikelihood: -1021.166 AIC: 2044.332 BIC: 2049.239 > print(os) Parameters: estimate Std. Error rate 0.9787222 NA > 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 Std. Error meanlog -0.02429523 NA sdlog 0.98832531 NA Loglikelihood: -1385.55 AIC: 2775.1 BIC: 2784.915 Correlation matrix: [1] NA > 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 Std. Error location 0.03741474 NA scale 1.01017937 NA Loglikelihood: -2008.887 AIC: 4021.773 BIC: 4031.589 Correlation matrix: [1] NA > le <- fitdist(x, "logis") > summary(le) Fitting of the distribution ' logis ' by maximum likelihood Parameters : estimate Std. Error location 0.03730365 0.05539416 scale 1.01065891 0.02674219 Loglikelihood: -2008.886 AIC: 4021.773 BIC: 4031.588 Correlation matrix: location scale location 1.000000000 0.001022883 scale 0.001022883 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 Std. Error shape1 2.840728 NA shape2 1.936016 NA Loglikelihood: 216.338 AIC: -428.676 BIC: -418.8605 Correlation matrix: [1] NA > 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 Std. Error shape1 1.606830 NA shape2 1.316324 NA Loglikelihood: 143.4634 AIC: -282.9267 BIC: -273.1112 Correlation matrix: [1] NA > > 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 Std. Error shape 2.931058 NA rate 1.962880 NA Loglikelihood: -1151.992 AIC: 2307.984 BIC: 2317.799 Correlation matrix: [1] NA > 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 Std. Error shape 1.6343028 NA scale 0.5204777 NA Loglikelihood: -1544.93 AIC: 3093.86 BIC: 3103.675 Correlation matrix: [1] NA > 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.30008975830071, 1.62857334972408, 1.08806433419838, : NaNs produced > summary(os) Parameters : estimate Std. Error shape 0.9527999 NA rate -0.4184140 NA Loglikelihood: NaN AIC: NaN BIC: NaN Correlation matrix: [1] NA > > 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 Std. Error size 2.829552 NA mu 6.059134 NA Loglikelihood: -2753.542 AIC: 5511.083 BIC: 5520.899 Correlation matrix: [1] NA > 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 Std. Error size 13.217293 NA mu 3.271458 NA Loglikelihood: -3658.91 AIC: 7321.819 BIC: 7331.635 Correlation matrix: [1] NA > 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 Std. Error size 14.9675230 NA prob 0.7540021 NA Loglikelihood: -3047.947 AIC: 6099.893 BIC: 6109.709 Correlation matrix: [1] NA > > > > > #### 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 Std. Error shape 3.006200 NA scale 2.001794 NA Loglikelihood: -985.8161 AIC: 1975.632 BIC: 1985.448 Correlation matrix: [1] NA > 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 Std. Error shape 2.865929 NA scale 2.720400 NA Loglikelihood: -1292.767 AIC: 2589.535 BIC: 2599.35 Correlation matrix: [1] NA > > > 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 Std. Error location 1.046622 NA scale 2.074356 NA Loglikelihood: -3229.91 AIC: 6463.819 BIC: 6473.635 Correlation matrix: [1] NA > 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 Std. Error location 0.985121 NA scale 1.357792 NA Loglikelihood: -3276.263 AIC: 6556.527 BIC: 6566.342 Correlation matrix: [1] NA > > > 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 Std. Error shape 1.066241 NA scale 2.268624 NA Loglikelihood: -2689.571 AIC: 5383.143 BIC: 5392.958 Correlation matrix: [1] NA > 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 Std. Error shape 0.6108631 NA scale 1.0001182 NA Loglikelihood: -2730.71 AIC: 5465.42 BIC: 5475.235 Correlation matrix: [1] NA > > proc.time() user system elapsed 2.43 0.21 2.61