-
Notifications
You must be signed in to change notification settings - Fork 1
/
IS606_Collab1_Markdown.Rmd
144 lines (91 loc) · 4.75 KB
/
IS606_Collab1_Markdown.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
---
title: "IS606_Collaborate_Markdown_1"
output:
html_document:
highlight: tango
keep_md: yes
number_sections: yes
theme: cerulean
toc: yes
pdf_document:
highlight: tango
keep_tex: yes
word_document:
highlight: tango
---
##Initial Thoughts
An initial question to be answered is whether the answer to this question should be a probabilistic one or a simulation. While a statistician might initially choose the first, the second is better to actually see results.
James Response: I think the simulation is just a way of running a probabilistic model. In the code, we are using a Poisson distribution to approximate customer demand. In the last two graphs in the updated code, we have supply trying to match the demand, so we have another poisson distribution. So the simulation just works out the distribution of profit analytically versus mathematically. I think either way is fine but we can be formal about the model if we need to:
Proft = Revenue - Cost
Revenue = price.ham * min(stock.ham, cust.ham) + price.turkey * min(stock.ham, cust.turkey) + price.veggie * min(stock.ham, cust.veggie)
with
cust.ham ~ Poisson(lambda.ham)
cust.turkey ~ Poisson(lambda.turkey)
cust.veggie ~ Poisson(lambda.veggie)
and
Cost = stock.ham * cost.ham + stock.turkey * cost.turkey + stock.veggie * cost.veggie
in the constant supply model with the cost variables constant, and the stock variables constant (unless we have storage in the model, etc...). I guess at this point we would have to write the math out to find an explicit formula the Profit distribution?
I feel like this is a IS609-way of looking at things :)
## Assumptions
Our assumptions include:
* Customers and the orders they make are independent of each other
+ While this may not be true in the real world, as someone's order may influence the order of the next person, it is easier to pretend that they are not
* In the no storage models, we assume that everything goes to waste. In the storage models, we assume that we can keep leftovers indefintely.
* Customer demand in the future will be close to customer demand we have seen in the past
* Increasing the supply doesn't increase cost outside of buying more goods (i.e. no need to increase labor)
* TODO: any others?
## Investigating Customer Demand
## Proft Graphs
## Suggestions?
# TODO: elaborate
After analyzing the situation, these suggestions come to mind:
* Increasing your supply to match customer demand increases profit
* Buying a refrigerator can help lower long-term costs by not wasting food
## Model
Lets test these recoomendations by creating a model and simulating events to find and compare the various profit distributions for the different suggestions.
# TODO: describe model
## Simulation to Test Suggestions
## Conclusions
Using this model, it seems that both suggestions would increase James' overall profit
=======
##First Look
```{r}
library(ggplot2)
library(reshape2)
details <- read.csv("details.csv", header=T)
sales <- read.csv("sales.csv", header=T)
attach(sales)
demand <- melt(sales[1:4], id.vars="date", variable.name="type", value.name="demand")
supply <- melt(sales[c(1,5,6,7)], id.vars="date", variable.name="type", value.name="supply")
ham <- melt(sales[c(1,2,5)], id.vars="date", variable.name="metric", value.name="amount")
turkey <- melt(sales[c(1,3,6)], id.vars="date", variable.name="metric", value.name="amount")
veggie <- melt(sales[c(1,4,7)], id.vars="date", variable.name="metric", value.name="amount")
plotHam <- ggplot(data=ham, aes(x=date, y=amount, group=metric, color=metric)) + geom_point() + geom_line() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_x_discrete(breaks=c("2014-03-03", "2014-04-01", "2014-05-01", "2014-06-02", "2014-07-01", "2014-08-01", "2014-08-29")) +
ggtitle("Ham")
plotTurkey <- ggplot(data=turkey, aes(x=date, y=amount, group=metric, color=metric)) + geom_point() + geom_line() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_x_discrete(breaks=c("2014-03-03", "2014-04-01", "2014-05-01", "2014-06-02", "2014-07-01", "2014-08-01", "2014-08-29")) +
ggtitle("Turkey")
plotVeggie <- ggplot(data=veggie, aes(x=date, y=amount, group=metric, color=metric)) + geom_point() + geom_line() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_x_discrete(breaks=c("2014-03-03", "2014-04-01", "2014-05-01", "2014-06-02", "2014-07-01", "2014-08-01", "2014-08-29")) +
ggtitle("Veggie")
```
<!-- Some comments about each of the graphs? -->
```{r}
plotHam
```
```{r}
plotTurkey
```
```{r}
plotVeggie
```
##Analysis of Historical Data
##Why Poisson distribution
##Simulation
###Assuming there is no storage of sandwiches after each day
###Assuming there is storage of unsold sandwiches after each day
##Interpretations and Recommendations