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") > summary(os) Parameters : estimate Std. Error rate 0.9338489 NA Loglikelihood: -1068.441 AIC: 2138.881 BIC: 2143.789 > print(os) Parameters: estimate Std. Error rate 0.9338489 NA > class(os) [1] "onestep" "fitdist" > plot(os) > > x <- rlnorm(n, 0, 1) > os <- onestep(x, "lnorm", method="closed") > summary(os) Parameters : estimate Std. Error meanlog -0.02662145 NA sdlog 0.98825865 NA Loglikelihood: -1380.506 AIC: 2765.013 BIC: 2774.828 Correlation matrix: [1] NA > plot(os) > > #### G2 <- c("unif", "logis") # Special distributions #### > > x <- runif(n) > os <- onestep(x, "unif") > summary(os) Parameters : estimate Std. Error 1 0.007959695 NA 2 0.992928765 NA Loglikelihood: -Inf AIC: Inf BIC: Inf Correlation matrix: [1] NA > le <- fitdist(x, "unif") > summary(le) Fitting of the distribution ' unif ' by maximum likelihood Parameters : estimate min 0.003824146 max 0.998800386 Loglikelihood: 5.036422 AIC: -6.072844 BIC: 3.742667 > > > x <- rlogis(n) > os <- onestep(x, "logis") > summary(os) Parameters : estimate Std. Error location -0.03396374 NA scale 1.00912035 NA Loglikelihood: -2011.014 AIC: 4026.028 BIC: 4035.843 Correlation matrix: [1] NA > le <- fitdist(x, "logis") > summary(le) Fitting of the distribution ' logis ' by maximum likelihood Parameters : estimate Std. Error location -0.03065253 0.05513559 scale 1.00884501 0.02677551 Loglikelihood: -2011.012 AIC: 4026.024 BIC: 4035.839 Correlation matrix: location scale location 1.000000000 0.003863566 scale 0.003863566 1.000000000 > > > #### G3 <- c("gamma", "beta", "nbinom") # Distributions with a default MME initial guess estimator #### > > x <- rbeta(n, 3, 2) > os <- onestep(x, "beta") > summary(os) Parameters : estimate Std. Error shape1 2.944679 NA shape2 2.061269 NA Loglikelihood: 227.37 AIC: -450.74 BIC: -440.9245 Correlation matrix: [1] NA > os <- onestep(x, "beta", init=list(shape1=1, shape2=1)) > > x <- rgamma(n, 3, 2) > os <- onestep(x, "gamma", init=list(shape=1, scale=1)) > summary(os) Parameters : estimate Std. Error shape 1.4421144 NA rate 0.8930363 NA Loglikelihood: -1311.604 AIC: 2627.207 BIC: 2637.023 Correlation matrix: [1] NA > os <- onestep(x, "gamma", init=list(shape=10, rate=1)) Warning message: In dgamma(c(0.813404973459965, 1.94469708583008, 1.28208853707268, : NaNs produced > summary(os) Parameters : estimate Std. Error shape -212.52975 NA rate -20.40788 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") > summary(os) Parameters : estimate Std. Error size 3.162553 NA mu 6.108000 NA Loglikelihood: -2735.244 AIC: 5474.487 BIC: 5484.303 Correlation matrix: [1] NA > os <- onestep(x, "nbinom", init=list(size=10, mu=2)) > summary(os) Parameters : estimate Std. Error size 13.026701 NA mu 3.270555 NA Loglikelihood: -3612.092 AIC: 7228.183 BIC: 7237.999 Correlation matrix: [1] NA > os <- onestep(x, "nbinom", init=list(size=10, prob=1/2)) > summary(os) Parameters : estimate Std. Error size 2.996378 NA mu 3.923366 NA Loglikelihood: -2941.269 AIC: 5886.539 BIC: 5896.354 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") > summary(os) Parameters : estimate Std. Error shape 2.941732 NA scale 1.988123 NA Loglikelihood: -984.9011 AIC: 1973.802 BIC: 1983.618 Correlation matrix: [1] NA > os <- onestep(x, "weibull", init=list(shape=1, scale=1)) > summary(os) Parameters : estimate Std. Error shape 1.412462 NA scale 19.610546 NA Loglikelihood: -3689.761 AIC: 7383.522 BIC: 7393.338 Correlation matrix: [1] NA > > > x <- rcauchy(n, 1, 2) > os <- onestep(x, "cauchy", control=list(param_t=1/4)) > summary(os) Parameters : estimate Std. Error location 1.066975 NA scale 1.876835 NA Loglikelihood: -3187.712 AIC: 6379.423 BIC: 6389.239 Correlation matrix: [1] NA > os <- onestep(x, "cauchy", init=list(location=0, scale=1)) > summary(os) Parameters : estimate Std. Error location 0.4466025 NA scale 1.7985857 NA Loglikelihood: -3216.533 AIC: 6437.066 BIC: 6446.881 Correlation matrix: [1] NA > > > x <- rpareto(n, 1, 2) > os <- onestep(x, "pareto") > summary(os) Parameters : estimate Std. Error shape 0.9062141 NA scale 1.8331014 NA Loglikelihood: -2807.725 AIC: 5619.45 BIC: 5629.265 Correlation matrix: [1] NA > os <- onestep(x, "pareto", init=list(shape=1, scale=1)) > summary(os) Parameters : estimate Std. Error shape 0.6376192 NA scale 1.1760334 NA Loglikelihood: -2826.053 AIC: 5656.106 BIC: 5665.922 Correlation matrix: [1] NA > > proc.time() user system elapsed 1.81 0.29 2.12