ALY 6000
Northeastern University
Oladimeji Adegoke
Project 6 Report
Instructor: Prof Dee Chiliuza


INTRODUCTION

The objective of this project is to carry out analysis of data distribution of our process across different market segment; identify problems in terms of total sales, efficiency of our shipping mode versus cost per region, part of our aim is to study product price per region or market and total and average sales by regional market. we will be presenting basic descriptive statistics to visualize product segment by market by region visa-a-vis sales volume, product ID and shipment classification, we will visualize the loss per return column to show what we need to do from the point of order fulfillment to final delivery to prevent return which is costly to the business.

Our data set consist of categorical data such as region, market,and product ID, we also have numerical data such as product price, shipping cost each,returns and loss per return.

We will be analyzing these data using graphical and tabular tools in R with a view at coming up with recommendation to improve the business.

Descriptive Statistics in Business Projects:

Descriptive statistics involves the summary and presentation of data in a meaningful way, providing insights into the central tendency, variability, and distribution of the data set. In real-life business projects, descriptive statistics play a crucial role in understanding historical trends, identifying patterns, and making informed decisions. Here’s what I’ve learned about the application of descriptive statistics in business projects:

  1. Data Summarization: Descriptive statistics help in summarizing large data sets into manageable and interpretable metrics. For example, measures such as mean, median, and mode can provide insights into the average performance of a product, employee, or process.

  2. Visualization: Techniques like histograms, box plots, and pie charts allow for the visual representation of data distributions and patterns. Visualizations make it easier to communicate findings and trends to stakeholders, aiding in decision-making processes.

  3. Performance Evaluation: Descriptive statistics are used to evaluate the performance of various business metrics such as sales, revenue, customer satisfaction scores, etc. By analyzing trends over time and comparing different segments, businesses can identify areas of improvement and opportunities for growth.

  4. Benchmarking: Descriptive statistics enable businesses to benchmark their performance against industry standards or competitors. Metrics like quartiles, percentiles, and standard deviations help in understanding how the business measures up relative to its peers.

References: - Hair, J. F., Black, W. C., Babin, B. J., & Anderson, R. E. (2019). Multivariate data analysis. Pearson Education Limited. - Montgomery, D. C., Peck, E. A., & Vining, G. G. (2015). Introduction to linear regression analysis. John Wiley & Sons.

Inferential Statistics in Business Projects:

Inferential statistics involves making inferences and predictions about a population based on sample data. It allows businesses to draw conclusions, test hypotheses, and make decisions with a certain level of confidence. Here’s what I’ve learned about the application of inferential statistics in business projects:

  1. Hypothesis Testing: Inferential statistics are used to test hypotheses and make decisions about population parameters. For example, businesses may use hypothesis tests to determine whether a new marketing campaign has led to a significant increase in sales.

  2. Predictive Analytics: Techniques like regression analysis and time series forecasting help businesses predict future outcomes based on historical data. This is invaluable for strategic planning, resource allocation, and risk management.

  3. Market Research: Inferential statistics are widely used in market research to estimate population parameters such as market size, customer preferences, and demand forecasting. Surveys, experiments, and A/B testing are common methods used to gather data for inferential analysis.

  4. Quality Control: In manufacturing and process industries, inferential statistics are used to monitor and control product quality. Control charts, hypothesis tests, and analysis of variance (ANOVA) help identify deviations from quality standards and take corrective actions.

References: - Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2013). Bayesian data analysis. Chapman and Hall/CRC. - Montgomery, D. C., Jennings, C. L., & Kulahci, M. (2015). Introduction to time series analysis and forecasting. John Wiley & Sons.

Similarities and Differences Between R Script vs. R Markdown:

R Script:

Pros: - R script files (.R) are plain text files containing R code that can be executed directly in RStudio or any other R environment. - They are suitable for writing and running code snippets, functions, and entire R programs. - R scripts are useful for exploratory data analysis, data cleaning, statistical modeling, and automation of repetitive tasks.

Cons: - R scripts lack the ability to integrate formatted text, code, and visualizations in a single document. - They do not support the generation of dynamic reports or presentations.

R Markdown:

Pros: - R Markdown files (.Rmd) combine formatted text (using Markdown syntax), R code chunks, and output (such as tables and plots) in a single document. - R Markdown supports the creation of dynamic documents, including reports, presentations, dashboards, and websites. - It allows for seamless integration of narrative text, code, and results, making it ideal for reproducible research and communication of findings.

Cons: - R Markdown files may require additional setup and familiarity with Markdown syntax compared to plain R scripts. - While highly versatile, R Markdown documents may become complex to manage and maintain for large-scale projects.

References: - Xie, Y., Allaire, J. J., & Grolemund, G. (2018). R markdown: The definitive guide. Chapman and Hall/CRC. - Allaire, J. J., Xie, Y., McPherson, J., Luraschi, J., Ushey, K., Atkins, A., … & Cheng, J. (2021). Rmarkdown: Dynamic Documents for R. R package version 2.11. Visit to https://rmarkdown.rstudio.com.

#library used in this projects
library(dplyr)
library(ggplot2)
library(knitr)
library(kableExtra)
library(readxl)

#Data used in this report

M6_project_dataset_2023_ <- read_excel("M6_project_dataset(2023).xlsx")


Task 1

Calculate summary statistics of whole data

summary_stats<-summary(M6_project_dataset_2023_)
mean_product<-mean(M6_project_dataset_2023_$Product_Price)
mean_qty<-mean(M6_project_dataset_2023_$Quantity)
mean_shipping<-mean(M6_project_dataset_2023_$Shipping_Cost_Each)
mean_return<-mean(M6_project_dataset_2023_$Returns)
mean_loss<-mean(M6_project_dataset_2023_$Loss_Per_Return)

median_product<-median(M6_project_dataset_2023_$Product_Price)
median_qty<-median(M6_project_dataset_2023_$Quantity)
median_shipping<-median(M6_project_dataset_2023_$Shipping_Cost_Each)
median_return<-median(M6_project_dataset_2023_$Returns)
median_loss<-median(M6_project_dataset_2023_$Loss_Per_Return)

sd_product<-sd(M6_project_dataset_2023_$Product_Price)
sd_qty<-sd(M6_project_dataset_2023_$Quantity)
sd_shipping<-sd(M6_project_dataset_2023_$Shipping_Cost_Each)
sd_return<-sd(M6_project_dataset_2023_$Returns)
sd_loss<-sd(M6_project_dataset_2023_$Loss_Per_Return)

#Create a table to display the descriptive statistics

summary_df <- data.frame("Statistic" = c("Mean product", "Median product", "Standard Deviation product","Mean Qty", "Median Qty", "Standard Deviation Qty","Mean shipping", "Median shipping", "Standard Deviation shipping","Mean return", "Median return", "Standard Deviation return","Mean loss", "Median loss", "Standard Deviation loss"),
  "Value" = c(mean_product,mean_qty,mean_shipping,mean_return,mean_loss,median_product,median_qty,median_shipping,median_return,median_loss, sd_product,sd_qty,sd_shipping,sd_return,sd_loss))

# Create table using kable
table <- kable(summary_df, caption = "Descriptive Statistics of whole data")


# Create a box plot of quantity distribution per Region
boxplot(Quantity ~ Region, data = M6_project_dataset_2023_, 
        main = "Quantity Distribution per Region",
        xlab = "Region", ylab = "qty")

# Create a bar plot of returns distribution per Region
barplot(M6_project_dataset_2023_$Returns,xlab= "Region",ylab = "Returns",300)

# Display the table and the graph
table
Descriptive Statistics of whole data
Statistic Value
Mean product 548.90281
Median product 158.52000
Standard Deviation product 14.32477
Mean Qty 47.59200
Median Qty 168.91985
Standard Deviation Qty 501.35000
Mean shipping 133.00000
Median shipping 8.58500
Standard Deviation shipping 40.00000
Mean return 145.65500
Median return 293.96055
Standard Deviation return 116.08541
Mean loss 13.97852
Median loss 34.82623
Standard Deviation loss 122.83409
boxplot
## function (x, ...) 
## UseMethod("boxplot")
## <bytecode: 0x00000249e1045190>
## <environment: namespace:graphics>
barplot
## function (height, ...) 
## UseMethod("barplot")
## <bytecode: 0x00000249e105ecb8>
## <environment: namespace:graphics>

In the table above we found out that the mean of product price is 548.9, median is 501.35, standard deviation of product is 293.96, the basic statistic of mean quantity is 158.52, median 133 and standard deviation 116.09, the basic statistics for mean shipping cost each is 14.32, median is 8.59 and standard deviation is 13.98, the basic statistics for mean return is 47.59, median is 40 and standard deviation is 34.83, while the basic statistics for mean loss per return is 168.92, median is 145.66 and standard deviation is 122.83

The standard deviation of product price, quantity, shipping cost each and loss per return is falls within 1 SD below the mean.

Our bar plot shows that we did not record ‘0’ return in any region which is a high cost to the business.

The box plot for central Asia , eastern US and southern Africa shows top outliers, there is need for further analysis of quantity data in the affected region.


Task 2

Display the distribution of data for shipping cost each showing mean and median

# Set up the layout for two plots
par(mfcol=c(1,1))

box_shipping<- boxplot.stats(M6_project_dataset_2023_$Shipping_Cost_Each)

# Create a box plot
boxplot(M6_project_dataset_2023_$Shipping_Cost_Each, main="Shipping Cost Each", ylim = c(0,60), horizontal = TRUE,
        col = "#09F2B4", 
        las =1,xlab = "shipping cost", ylab = "frequency")

text(x = boxplot.stats(M6_project_dataset_2023_$Shipping_Cost_Each)$stats, 
     labels = boxplot.stats(M6_project_dataset_2023_$Shipping_Cost_Each)$stats, 
     y = 1.25)

text(x = mean_shipping,
     labels = mean_shipping,
     y = 1.15,
     col = "red")

points(mean_shipping, 
       pch = 15, 
       col = "#F20909", 
       lwd = 7,)
points(median_shipping, 
       pch = 15, 
       col = "#800000", 
       lwd = 7)

# Create a histogram
histogram <- ggplot(M6_project_dataset_2023_, aes(x = Shipping_Cost_Each)) +
  geom_histogram(fill = "lightgreen", color = "darkgreen", bins = 30) +
  geom_vline(xintercept = mean_shipping, color = "red", linetype = "dashed", y=14.32) +
  geom_vline(xintercept = median_shipping, color = "blue", linetype = "dashed", y=8.59) +
  labs(title = "Histogram of Shipping Cost Each",
       x = "Shipping Cost Each",
       y = "Frequency", ylim = c(0,80)) +
  theme_minimal()
## Warning in geom_vline(xintercept = mean_shipping, color = "red", linetype =
## "dashed", : Ignoring unknown parameters: `y`
## Warning in geom_vline(xintercept = median_shipping, color = "blue", linetype =
## "dashed", : Ignoring unknown parameters: `y`
print(boxplot)
## function (x, ...) 
## UseMethod("boxplot")
## <bytecode: 0x00000249e1045190>
## <environment: namespace:graphics>
print(histogram)

What we are trying to visualize here is the data distribution of shipping cost each of our product in different market.

The red line on the histogram indicates 14.32 which is the mean value for shipping cost , while the blue line is 8.59 the median value shipping cost,the histogram reports n=0 value data.

The box plot displays important values in the data distribution, there top outliers after the maximum value which is indicating further analysis of data leading us to additional information regarding our shipping cost, the min value is zero and the value in red in the box plot represents mean value of shipping, the box plot is divided into 25% each regardless of the size, we have Q1 value=3.89, Q2/median=8.585,Q3=21.415 and Q4/maximum value= 47.7


Task 3

Display which market has the highest or lowest shipping cost using a box plot

boxplot(Shipping_Cost_Each ~ Market, data = M6_project_dataset_2023_, 
        main = "Shipping cost Vs Market Data Distribution",
        xlab = "market", ylab = "shipping cost", ylim = c(0,80))

The graph above shows our shipping cost data in different market, as we can see USCA has the lowest shipping cost with on top outlier, we are incurring less cost to deliver product in this market, this is an advantage we need to leverage on to sell volume profitably, this is due to proximity. Asia pacific,Europe and LATAM follows next and they show multiple top outliers, this could be as a result of our data and require further analysis.

Africa has the highest shipping cost, can we locate a factory to bring our shipping cost down and increase sales volume and our product availability


Task 4

What is the average shipping cost and product price by market? Use tapply(),

 mean_shipping_cost_per_market <- tapply(M6_project_dataset_2023_$Shipping_Cost_Each, M6_project_dataset_2023_$Market, mean)

median_Product_price_per_market <- tapply(M6_project_dataset_2023_$Product_Price, M6_project_dataset_2023_$Market, median)

barplot(mean_shipping_cost_per_market,5, xlab = "market", ylab = "shipping cost", ylim = c(0,80))

barplot(median_Product_price_per_market,5,xlab = "market", ylab = "product price", ylim = c(0,1000))

# Create a box plot
boxplot(M6_project_dataset_2023_$Shipping_Cost_Each, main="Shipping Cost Each", ylim = c(0,60), horizontal = TRUE,
        col = "#09F2B4", 
        las =1)

text(x = boxplot.stats(M6_project_dataset_2023_$Shipping_Cost_Each)$stats, 
     labels = boxplot.stats(M6_project_dataset_2023_$Shipping_Cost_Each)$stats, 
     y = 1.25,)

text(x = mean_shipping,
     labels = mean_shipping,
     y = 1.15,
     col = "red",)

points(mean_shipping, 
       pch = 15, 
       col = "#F20909", 
       lwd = 7,)
points(median_shipping, 
       pch = 15, 
       col = "#800000", 
       lwd = 7)

print(barplot)
## function (height, ...) 
## UseMethod("barplot")
## <bytecode: 0x00000249e105ecb8>
## <environment: namespace:graphics>

The graph above visualize the mean value of shipping cost and product price by market.

USCA has the lowest mean price,the highest shipping cost is to Africa, we need to ask a fundamental question:

How can we reduce our shipping cost to Africa and increase sales? Build a plant or franchise our brand?


Task 5

Show a graph using a box plot of shipping cost each versus shipping mode distribution

boxplot(Shipping_Cost_Each ~ ShipMode, data = M6_project_dataset_2023_, 
        main = "Shipping cost Vs ShipMode Distribution",
        xlab = "Ship Mode", ylab = "shipping cost", ylim = c(0,80))

In the graph above , we are trying to determine the relationship between shipping cost and different mode of shipping used to deliver product to our customers,as displayed in the box plot

  1. Standard class mode- has the lowest shipping cost, there are top outliers data shown, which is an indication of some values are above the maximum value, this mode of shipping do not require any urgency, customer agrees to deliver within the normal delivery time frame, the minimum value falls is around ‘0’, the thick line in between is the median value.

  2. Same day shipping mode as visualized has the highest cost of delivery, this is because the order require urgency, the customer is paying more to get the product delivered same day.

As shown in the graph it is observed that shipping cost for same day delivery is higher than first class, this means we have been under-charging customers requesting first class shipping mode or over-charging customers requesting same-day delivery, there is need for a close review of both shipping mode


Task 6

Create a row for total sale using mutate code

m6_project_dataset_2 <- mutate(M6_project_dataset_2023_,total_sales=Product_Price*Quantity)

glimpse(m6_project_dataset_2[18])
## Rows: 1,000
## Columns: 1
## $ total_sales <dbl> 55446.16, 41578.26, 71936.86, 27969.95, 113337.87, 60897.0…

In the data above, a column was omitted in the original data set, we have created a new column called total sale, by using the mutate code, and glimpse code to display values.

The new data set have been renamed as m6_project_dataset_2, the total sales value now in column 18, the values displayed above.


Task 7

Group the data by market, region and find total sales for each

sales_summary <- m6_project_dataset_2 %>%
  group_by(Market) %>%
  summarise(Total_Sales = sum(total_sales))

# Find the region with the highest total sales
highest_sales_market <- sales_summary$Market[which.max(sales_summary$Total_Sales)]

# Print the table of total sales by market
sales_summary_table <- sales_summary %>%
  kable("html") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))

# Print the result
cat("The market with the highest total sales is:", highest_sales_market, "\n")
## The market with the highest total sales is: Asia Pacific
sales_summary_table
Market Total_Sales
Africa 5127296
Asia Pacific 24704625
Europe 24627127
LATAM 14005415
USCA 9533931

In the table above Asia Pacific has the highest total sales during the period under review, Africa has the lowest total sales.

We need to come up with a plan to improve sales in Africa, we need to carry out a study why our demand is low in this region by taking sample from the population in this region using stratified sampling technique, From our previous graphical reports could the low total sales be as a result of high shipping cost? which is making our product less competitive or preferred, we need to engage our R&D to improve our market offering to suite this region, and use our research result to further segment this market.


Task 8

Poser

On a average which product ID by region has the highest sales volume?

Can we visualize Product ID contribution to the average total sales by region?

# using the dataset m6_project_dataset_2 with the three variables Market, product_ID, and total_sales

# Group the data by Market and product ID, calculate total sales for each group, and then calculate average total sales per product ID in each market
average_sales_per_category <- m6_project_dataset_2 %>%
  group_by(Market, ProductID) %>%
  mutate(total_sales = sum(total_sales)) %>%
  group_by(Market, ProductID) %>%
  summarise(avg_total_sales = mean(total_sales))
## `summarise()` has grouped output by 'Market'. You can override using the
## `.groups` argument.
# Find the product ID with the highest average total sales in each market
highest_avg_sales_per_market <- average_sales_per_category %>%
  group_by(Market) %>%
  filter(avg_total_sales == max(avg_total_sales))

# Print the table of average total sales per product ID in each region
average_sales_table <- average_sales_per_category %>%
  kable("html") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))

# Print the result
cat("Product ID with the highest average total sales in each market:\n")
## Product ID with the highest average total sales in each market:
print(highest_avg_sales_per_market)
## # A tibble: 5 × 3
## # Groups:   Market [5]
##   Market       ProductID avg_total_sales
##   <chr>        <chr>               <dbl>
## 1 Africa       OFF66667          398560.
## 2 Asia Pacific OFF76494          375887.
## 3 Europe       OFF69296          550305.
## 4 LATAM        TEC64511          423451.
## 5 USCA         OFF42256          302268.
# Plot the average total sales in each market
sales_plot <- ggplot(average_sales_per_category, aes(x =avg_total_sales, y = Market, fill = Market,labels=TRUE, breaks=30)) +
  geom_bar(stat = "identity", position = "dodge") +
  labs(title = "Average Total Sales per Product ID in Each Market", x ="Average Total Sales", y ="Market", xlim = c(0,50000), labels=TRUE) +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 65, hjust = 1))

# Show the plot
sales_plot

The graph presented here shows which product ID contributes highest to total sales in each market, Our analysis above as displayed in table format shows that Product ID OFF69296 has the highest contribution to total sales in Europe, the table above have also revealed to us that Product ID OFF42256 contributes to total sales in USCA region, we need to identify why there is a decline in sales for product ID OFF42256

The bar plot is the graphical visualization of the table above showing product ID contribution to average total sales by market. The graph above show that Europe contributes highest to total sales on average with product ID OFF6929, this shows that one product ID is responsible for this volume of sales, we need to look into performance of other product ID in same market to improve our sales turnover.


Conclusion

In summary the analysis of m6_project_dataset have identified some areas of improvement as listed below:

  1. We need to have a close review shipping cost for same day and first class delivery mode, so as to ensure we are not under charging or over charging customers, this will also impact our product price per product ID.

  2. We need to look closely into high shipping cost to Africa and low sales turnover coming from that region, we need to explore other ways of getting our product to African market competitively and improve our sales and profit margin in that region.

  3. This analysis have also identified that the product price, shipping cost and total sales in USCA is on a low, we need to take advantage of this local market and improve our numbers.

Strategy for Organisation:

The data was loaded and explored step by step.

Every analysis task was divided into doable portions, I completed the codes first study the result before writing my observations and conclusion.

Using the dplyr and kableExtra libraries consistently ensured effective presentation and manipulation of data.


Bibliograhpy


  1. Hair, J. F., Black, W. C., Babin, B. J., & Anderson, R. E. (2019). Multivariate data analysis. Pearson Education Limited.

  2. Montgomery, D. C., Peck, E. A., & Vining, G. G. (2015). Introduction to linear regression analysis. John Wiley & Sons.

  3. Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2013). Bayesian data analysis. Chapman and Hall/CRC.

  4. Montgomery, D. C., Jennings, C. L., & Kulahci, M. (2015). Introduction to time series analysis and forecasting. John Wiley & Sons.

  5. Xie, Y., Allaire, J. J., & Grolemund, G. (2018). R markdown: The definitive guide. Chapman and Hall/CRC.

  6. Allaire, J. J., Xie, Y., McPherson, J., Luraschi, J., Ushey, K., Atkins, A., … & Cheng, J. (2021). Rmarkdown: Dynamic Documents for R. R package version 2.11. Visit to https://rmarkdown.rstudio.com.

  7. Dee Chiluiza,(2021) Introduction to data analysis using R, R Studio and R Markdown https://rpubs.com/Dee_Chiluiza/816756

  8. Wickham, H. (2019). Advanced R. CRC Press https://adv-r.hadley.nz.


Acknowledgement


My special appreciation goes to Professor Dee Chiluiza, for taking me from zero knowledge or skill in using R to analyse data to this level.

You are an amazing instructor!

Finally, I appreciate my classmate for sharing ideas and creating a tempo for learning.