Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Case Study

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Problems 3.1, 3.2, 3.3 & 3.

Question 3.1). Shipments of Household Appliances: Line Graphs.


The file ApplianceShipments.csv contains the series of quarterly shipments (in millions of dollars) of US
household appliances between 1985 and 1989.
a. Create a well-formatted time plot of the data using R.
b. Does there appear to be a quarterly pattern? For a closer view of the patterns, zoom in to the range
of 3500–5000 on the y-axis.
c. Using R, create one chart with four separate lines, one line for each of Q1, Q2, Q3, and Q4. In R,
this can be achieved by generating a data.frame for each quarter Q1, Q2, Q3, Q4, and then
plotting them as separate series on the line graph. Zoom in to the range of 3500–5000 on the y-
axis. Does there appear to be a difference between quarters?
d. Using R, create a line graph of the series at a yearly aggregated level (i.e., the total shipments in
each year).
Solution 3.1a:
1. Import ApplianceShipment.csv file
2. View(ApplianceShipments)
3. summary(ApplianceShipments)
4. shipment.ts=ts(ApplianceShipments$Shipments,start = c(1985,1),end = c(1989,4), frequency = 4)
5. plot(shipment.ts, xlab = "Year", ylab = "Shipment (in million $)")

Business analytics
Problems 3.1, 3.2, 3.3 & 3.4

Solution 3.1b:

1. Import ApplianceShipment.csv file


2. View(ApplianceShipments)
3. summary(ApplianceShipments)
4. shipment.ts=ts(ApplianceShipments$Shipments,start = c(1985,1),end = c(1989,4),frequency = 4)
5. plot(shipment.ts, xlab = "Year", ylab = "Shipment (in million $)", ylim = c(3500, 5000))

Observation (Quarterly pattern):

From the time plot, it is evident that shipment increases in the 1st and 4th quarter of the year, and in the
2d and 3rd quarter shipment reduces. Probable reasons for increase in sale in the 4th quarter could be the
pressure to meet year-end targets and reason for increased sale in the 1st quarter could be a new-year
enthusiasm and push from the managers. Reasons for sluggishness in 2nd and 3rd quarter are could be over
achievement of 1st quarter target and due to which relaxed manager’s position.

Solution 3.1c:

1. Import ApplianceShipment.csv file


2. View(ApplianceShipments)
3. summary(ApplianceShipments)

Business analytics
Problems 3.1, 3.2, 3.3 & 3.4

4. shipment.ts=ts(ApplianceShipments$Shipments,start = c(1985,1),end = c(1989,4),frequency = 4)


5. plot(shipment.ts, xlab = "Year", ylab = "Shipment (in million $)", ylim = c(3500, 5000))
6. library(ggplot2)
7. par(oma = c(0,0,0,2))
8. xrange <- c(1,5)
9. yrange <- range(shipment.ts)
10. plot(xrange, yrange, main = "Shipments by Quarter", type = "n", xlab = "Year", ylab =
"Shipments", bty = "l")
11. colors <- rainbow(4)
12. linetype <- c(1:4)
13. plotchar <- c(1:4)
14. for (i in 1:4) {
current_quarter <- subset(shipment.ts, cycle(shipment.ts)==i)
lines(current_quarter, type="b", lwd=1.5, lty=linetype[i], col=colors[i], pch=plotchar[i])
}
15. legend(5.25 ,4800, 1:4, cex=0.8, col=colors, pch=plotchar, lty=linetype, title="Quarter",
xpd=NA)

Solution 3.1d:

1. Import ApplianceShipment.csv file


2. View(ApplianceShipments)
3. summary(ApplianceShipments)
4. shipment.ts=ts(ApplianceShipments$Shipments,start = c(1985,1),end = c(1989,4),frequency = 4)

Business analytics
Problems 3.1, 3.2, 3.3 & 3.4

5. plot(shipment.ts, xlab = "Year", ylab = "Shipment (in million $)", ylim = c(3500, 5000))
6. library(ggplot2)
7. par(oma = c(0,0,0,2))
8. xrange <- c(1,5)
9. yrange <- range(shipment.ts)
10. plot(xrange, yrange, main = "Shipments by Quarter", type = "n", xlab = "Year", ylab =
"Shipments", bty = "l")
11. colors <- rainbow(4)
12. linetype <- c(1:4)
13. plotchar <- c(1:4)
14. for (i in 1:4) {
current_quarter <- subset(shipment.ts, cycle(shipment.ts)==i)
lines(current_quarter, type="b", lwd=1.5, lty=linetype[i], col=colors[i], pch=plotchar[i])
}
15. legend(5.25 ,4800, 1:4, cex=0.8, col=colors, pch=plotchar, lty=linetype, title="Quarter",
xpd=NA)
16. yearly <- aggregate(shipment.ts, nfrequency=1, FUN=sum)
17. plot(yearly, bty="l")

Business analytics
Problems 3.1, 3.2, 3.3 & 3.4

Question 3.2). Sales of Riding Mowers: Scatter Plots.


A company that manufactures riding mowers wants to identify the best sales prospects for an intensive
sales campaign. In particular, the manufacturer is interested in classifying households as prospective
owners or nonowners on the basis of Income (in $1000s) and Lot Size (in 1000 ft2). The marketing
expert looked at a random sample of 24 households, given in the file Riding- Mowers.csv.

a. Using R, create a scatter plot of Lot Size vs. Income, color-coded by the outcome variable
owner/nonowner. Make sure to obtain a well-formatted plot (create legible labels and a legend, etc.).

Solution 3.2:
1. Import RidingMowers.csv file
2. View(RidingMowers)
3. summary(RidingMowers)
4. par(xpd=TRUE)
5. plot(RidingMowers$Income,RidingMowers$Lot_Size, xlab = "Income in $1000s", ylab = "Lot
Size in 1000ft2",col = ifelse(RidingMowers$Ownership=="Owner","black","red"), pch=19,
bty="l")
6. legend ("topleft", inset = c(0,-0.3), legend = c("Ownership=Owner", "Ownership=
Nonowner"),col=c("black","red"), pch=1)

Business analytics
Problems 3.1, 3.2, 3.3 & 3.4

Question 3.3). Laptop Sales at a London Computer Chain: Bar Charts and Boxplots.
The file LaptopSalesJanuary2008.csv contains data for all sales of laptops at a computer chain in London
in January 2008. This is a subset of the full dataset that includes data for the entire year.
a. Create a bar chart, showing the average retail price by store. Which store has the highest average?
Which has the lowest?
b. To better compare retail prices across stores, create side-by-side boxplots of retail price by store. Now
compare the prices in the two stores from (a). Does there seem to be a difference between their price
distributions?

Solution 3.3a

1. Import Laptop SalesJanuary2008.csv file


2. View(LaptopSalesJanuary2008)
3. summary(LaptopSalesJanuary2008)
4. data.for.plot <- aggregate(LaptopSalesJanuary2008$Retail.Price,
by=list(LaptopSalesJanuary2008$Store.Postcode), FUN = mean)
5. names(data.for.plot)<- c("Store", "MeanRetail")
6. barplot (data.for.plot $MeanRetail, names.arg=data.for.plot$Store, ylab="Avg Retail Price",
bty="l")

Business analytics
Problems 3.1, 3.2, 3.3 & 3.4

Solution 3.3b

1. Import Laptop SalesJanuary2008.csv file


2. View(LaptopSalesJanuary2008)
3. summary(LaptopSalesJanuary2008)
4. par(las=2)
5. boxplot(LaptopSalesJanuary2008$Retail.Price~LaptopSalesJanuary2008$Store.Postcode,
xlab="Store", ylab="Retail Price")

Question 3.4). Laptop Sales at a London Computer Chain: Interactive Visualization.


The next exercises are designed for using an interactive visualization tool. The file LaptopSales.txt is a
comma-separated file with nearly 300,000 rows. ENBIS (the European Network for Business and
industrial Statistics) provided these data as part of a contest organized in the fall of 2009. Scenario:
Imagine that you are a new analyst for a company called Acell (a company selling laptops). You have
been provided with data about products and sales. You need to help the company with their business goal
of planning a product strategy and pricing policies that will maximize Acell’s projected revenues in 2009.
Using an interactive visualization tool, answer the following questions.
a. Price Questions:
i. At what price are the laptops actually selling?

Business analytics
Problems 3.1, 3.2, 3.3 & 3.4

ii. Does price change with time? (Hint: Make sure that the date column is recognized as such. The
software should then enable different temporal aggregation choices, e.g., plotting the data by
weekly or monthly aggregates, or even by day of week.)
iii. Are prices consistent across retail outlets?
iv. How does price change with configuration?

b. Location Questions:
i. Where are the stores and customers located?
ii. Which stores are selling the most?
iii. How far would customers travel to buy a laptop?

◦ Hint 1: You should be able to aggregate the data, for example, plot the sum or average of the prices.
◦ Hint 2: Use the coordinated highlighting between multiple visualizations in the same page, for example,
select a store in one view to see the matching customers in another visualization.
◦ Hint 3: Explore the use of filters to see differences. Make sure to filter in the zoomed out view. For
example, try to use a “store location” slider as an alternative way to dynamically compare store locations.
This might be more useful to spot outlier patterns if there were 50 store locations to compare.

iv. Try an alternative way of looking at how far customers traveled. Do this by
creating a new data column that computes the distance between customer and
store.

c. Revenue Questions:
i. How do the sales volume in each store relate to Acell’s revenues?
ii. How does this relationship depend on the configuration?

d. Configuration Questions:
i. What are the details of each configuration? How does this relate to price?
ii. Do all stores sell all configurations?

Business analytics

You might also like