/**
* jQuery Plugin: Sticky Tabs
*
* @author Aidan Lister
// Set the correct tab when the page loads showStuffFromHash(context);
// Set the correct tab when a user uses their back/forward button $(window).on('hashchange', function() { showStuffFromHash(context); });
// Change the URL when tabs are clicked $('a', context).on('click', function(e) { history.pushState(null, null, this.href); showStuffFromHash(context); });
return this; }; }(jQuery));
window.buildTabsets = function(tocID) {
// build a tabset from a section div with the .tabset class function buildTabset(tabset) {
// check for fade and pills options var fade = tabset.hasClass("tabset-fade"); var pills = tabset.hasClass("tabset-pills"); var navClass = pills ? "nav-pills" : "nav-tabs";
// determine the heading level of the tabset and tabs var match = tabset.attr('class').match(/level(\d) /); if (match === null) return; var tabsetLevel = Number(match[1]); var tabLevel = tabsetLevel + 1;
// find all subheadings immediately below var tabs = tabset.find("div.section.level" + tabLevel); if (!tabs.length) return;
// create tablist and tab-content elements var tabList = $('
'); $(tabs[0]).before(tabList); var tabContent = $('
'); $(tabs[0]).before(tabContent);
// build the tabset var activeTab = 0; tabs.each(function(i) {
// get the tab div var tab = $(tabs[i]);
// get the id then sanitize it for use with bootstrap tabs var id = tab.attr('id');
// see if this is marked as the active tab if (tab.hasClass('active')) activeTab = i;
// remove any table of contents entries associated with // this ID (since we'll be removing the heading element) $("div#" + tocID + " li a[href='#" + id + "']").parent().remove();
// sanitize the id for use with bootstrap tabs id = id.replace(/[.\/?&!#<>]/g, '').replace(/\s/g, '_'); tab.attr('id', id);
// get the heading element within it, grab it's text, then remove it var heading = tab.find('h' + tabLevel + ':first'); var headingText = heading.html(); heading.remove();
// build and append the tab list item var a = $('' + headingText + ''); a.attr('href', '#' + id); a.attr('aria-controls', id); var li = $('
'); li.append(a); tabList.append(li);
// set it's attributes tab.attr('role', 'tabpanel'); tab.addClass('tab-pane'); tab.addClass('tabbed-pane'); if (fade) tab.addClass('fade');
// move it into the tab content div tab.detach().appendTo(tabContent); });
// set active tab $(tabList.children('li')[activeTab]).addClass('active'); var active = $(tabContent.children('div.section')[activeTab]); active.addClass('active'); if (fade) active.addClass('in');
if (tabset.hasClass("tabset-sticky")) tabset.rmarkdownStickyTabs(); }
// convert section divs with the .tabset class to tabsets var tabsets = $("div.section.tabset"); tabsets.each(function(i) { buildTabset($(tabsets[i])); }); };
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
// add bootstrap table styles to pandoc tables function bootstrapStylePandocTables() { $('tr.odd').parent('tbody').parent('table').addClass('table table-condensed'); } $(document).ready(function () { bootstrapStylePandocTables(); });