R Under development (unstable) (2024-07-10 r86888 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. > library(fitdistrplus) Loading required package: MASS Loading required package: survival > library(actuar) Attaching package: 'actuar' The following objects are masked from 'package:stats': sd, var The following object is masked from 'package:grDevices': cm > > set.seed(1234) > > n <- 1e3 > x <- rtrgamma(n, 2, 2, scale=2) > > fitdistrplus:::startarg_transgamma_family(x, "trgamma") $shape1 [1] 7.953247 $shape2 [1] 1.002587 $scale [1] 0.3374842 > > fitdistrplus:::startarg_transgamma_family(x, "gamma") $shape [1] 7.953247 $rate [1] 0.3374842 > > fitdistrplus:::startarg_transgamma_family(x, "weibull") $shape [1] 3.081294 $scale [1] 3.015039 > > fitdistrplus:::startarg_transgamma_family(x, "exp") $rate [1] 0.372565 > > fitdist(x, "trgamma") Fitting of the distribution ' trgamma ' by maximum likelihood Parameters: estimate Std. Error shape1 2.143840 0.4835707 shape2 1.974504 0.2516188 scale 1.932572 0.3420543 > fitdist(x, "gamma") Fitting of the distribution ' gamma ' by maximum likelihood Parameters: estimate Std. Error shape 7.372872 0.3225398 rate 2.746763 0.1243473 > fitdist(x, "weibull") Fitting of the distribution ' weibull ' by maximum likelihood Parameters: estimate Std. Error shape 3.038278 0.07291534 scale 3.004382 0.03301925 > fitdist(x, "exp") Fitting of the distribution ' exp ' by maximum likelihood Parameters: estimate Std. Error rate 0.372565 0.01178145 > > > #weird examples > x <- rep(1, n) > > fitdistrplus:::startarg_transgamma_family(x, "gamma") $shape [1] 1 $rate [1] 1 > > #previous code > n <- length(x) > m <- mean(x) > v <- (n - 1)/n*var(x) > list(shape=m^2/v, rate=m/v) $shape [1] Inf $rate [1] Inf > > > #normal -> weibull > x <- abs(rnorm(n = 20, mean = 150, sd = 10)) > m <- mean(log(x)) > v <- var(log(x)) > shape <- 1.2/sqrt(v) > scale <- exp(m + 0.572/shape) > s1 <- list(shape=shape, scale=scale) > cdfcomp(fitdist(x, "weibull", start=s1)) > > > proc.time() user system elapsed 2.12 0.25 2.36