Statistical Estimation

Distributions Fitting



Orders Distribution Analysis





1.Loading the required packages and data

library(fitdistrplus)
library(readxl)
library(actuar)
library(tidyverse)
library(MASS)
data <- read_xlsx("Shipments and Orders  copy.xlsx",sheet = "Orders")

2.Exploratory Data Analysis

hist(data$Interarrival, breaks = 30, probability = TRUE, main = "Histogram of Shipments",
     col = "lightblue", border = "black",,xlab= "Interarrival Time (Hours)")
lines(density(data$Interarrival), col = "red", lwd = 2)

descdist(data$Interarrival, discrete = FALSE,boot = 1000)  

## summary statistics
## ------
## min:  0.04395604   max:  12 
## median:  0.3333333 
## mean:  1.346451 
## estimated sd:  2.63505 
## estimated skewness:  3.066366 
## estimated kurtosis:  12.1656

3.Fitting the candidates distributions

lognorm_<- fitdist(data$Interarrival,"lnorm")
exp_<- fitdist(data$Interarrival,"exp")
gamma_<- fitdist(data$Interarrival,"gamma")
weibull_<- fitdist(data$Interarrival,"weibull")
pareto_<- fitdist(data$Interarrival,"pareto")
llogis_<- fitdist(data$Interarrival,"llogis")

4.Visualize Fitted Distribution

4.1 Lognormal Distribution

plot(lognorm_)

4.2 Exponential Distribution

plot(exp_)

4.3 Gamma Distribution

plot(gamma_)

4.4 Weibull Distribution

plot(weibull_)

4.5 Pareto Distribution

plot(pareto_)

4.6 Log-logistic Distribution

plot(llogis_)

5. Goodness of Fit

fit_list<-list(lognorm_,exp_,gamma_,weibull_,pareto_,llogis_)
gofstat(fit_list)  
## Goodness-of-fit statistics
##                              1-mle-lnorm  2-mle-exp 3-mle-gamma 4-mle-weibull
## Kolmogorov-Smirnov statistic   0.1246572  0.3418689   0.2196067     0.1658613
## Cramer-von Mises statistic     0.8267156  8.5380233   3.1546848     1.8843501
## Anderson-Darling statistic     5.0414870 44.1835095  16.1612789    10.9073068
##                              5-mle-pareto 6-mle-llogis
## Kolmogorov-Smirnov statistic    0.1210169   0.09323707
## Cramer-von Mises statistic      0.7359316   0.40402703
## Anderson-Darling statistic      5.2762132   3.79510272
## 
## Goodness-of-fit criteria
##                                1-mle-lnorm 2-mle-exp 3-mle-gamma 4-mle-weibull
## Akaike's Information Criterion    392.7215  552.1284    497.0598      465.1349
## Bayesian Information Criterion    399.4346  555.4850    503.7730      471.8480
##                                5-mle-pareto 6-mle-llogis
## Akaike's Information Criterion     411.6951     393.5127
## Bayesian Information Criterion     418.4083     400.2259

6.Estimate Parameters

summary(lognorm_)
## Fitting of the distribution ' lnorm ' by maximum likelihood 
## Parameters : 
##           estimate Std. Error
## meanlog -0.7981928 0.09234322
## sdlog    1.3445376 0.06529636
## Loglikelihood:  -194.3607   AIC:  392.7215   BIC:  399.4346 
## Correlation matrix:
##         meanlog sdlog
## meanlog       1     0
## sdlog         0     1
summary(llogis_)
## Fitting of the distribution ' llogis ' by maximum likelihood 
## Parameters : 
##        estimate Std. Error
## shape 1.3255562 0.07660006
## scale 0.3885515 0.03503933
## Loglikelihood:  -194.7564   AIC:  393.5127   BIC:  400.2259 
## Correlation matrix:
##             shape       scale
## shape  1.00000000 -0.09590283
## scale -0.09590283  1.00000000