-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathCampaignEffects.Rmd
126 lines (112 loc) · 3.62 KB
/
CampaignEffects.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
---
title: "CampaignEffects"
author: "John Mount"
date: "March 24, 2015"
output: html_document
---
```{r}
library('ggplot2')
library('xtable')
source('functions.R')
```
```{r}
# use case 1: user enters two success probability estimates, two success valuations
# and optionally overrides errorProbability, and relativeError
# we compute an experiment plan and show a typical expected outcome
tabExperiment <- data.frame(
Label=c('campaign1','campaign2'),
Probability=c(0.05,0.025),
ValueSuccess=c(2,3))
errorProbability=0.05
relativeError=0.2
# end of user input
tabExperiment$expectedValue <- tabExperiment$Probability*tabExperiment$ValueSuccess
print(tabExperiment)
sizes <- heuristicPowerPlan(tabExperiment)
print(sizes)
tabTypical <- typicalTable(tabExperiment,sizes)
print(tabTypical)
tabGraphs <- sampleGraph(tabExperiment,sizes)
plotSample(tabGraphs)
computeProbsGES(tabExperiment,tabGraphs)
g2 = build2dProbGraph(tabGraphs,'campaign1','campaign2')
ggplot() +
geom_contour(data=g2,aes(x=v1,y=v2,z=d)) +
xlab('campaign1') + ylab('campaign2') +
geom_abline(slope=1) + coord_fixed() + expand_limits(x = 0, y = 0)
```
```{r}
# use case 2: user enters an experiment result
tabValue <- data.frame(Label=c('Campaign$2','Campaign$4'),
Actions=c(10000,10000),
Successes=c(412,255),
ValueSuccess=c(2,4))
# end of user input
tabValue$Probability <- tabValue$Successes/tabValue$Actions
tabValue$expectedValue <- tabValue$Probability*tabValue$ValueSuccess
print(tabValue)
valueGraphs <- posteriorGraph(tabValue)
plotPosterior(valueGraphs)
computeProbsGEP(tabValue,valueGraphs$graph)
g = build2dProbGraph(valueGraphs$graph,'Campaign$2','Campaign$4')
ggplot() +
geom_contour(data=g,aes(x=v1,y=v2,z=d)) +
xlab('Campaign$2') + ylab('Campaign$4') +
geom_abline(slope=1) + coord_fixed() + expand_limits(x = 0, y = 0)
```
```{r}
# stacked example
tabValue <- data.frame(Label=c('Campaign1','Campaign2'),
Actions=c(10,10),
Successes=c(1,1),
ValueSuccess=c(1,1))
# end of user input
tabValue$Probability <- tabValue$Successes/tabValue$Actions
tabValue$expectedValue <- tabValue$Probability*tabValue$ValueSuccess
print(tabValue)
valueGraphs <- posteriorGraph(tabValue)
plotPosterior(valueGraphs)
computeProbsGEP(tabValue,valueGraphs$graph)
g = build2dProbGraph(valueGraphs$graph,'Campaign1','Campaign2')
ggplot() +
geom_contour(data=g,aes(x=v1,y=v2,z=d)) +
xlab('Campaign1') + ylab('Campaign2') +
geom_abline(slope=1) + coord_fixed() + expand_limits(x = 0, y = 0)
```
```{r}
# edge case 100% conversion
tabValue <- data.frame(Label=c('Campaign1','Campaign2'),
Actions=c(1,1),
Successes=c(0,1),
ValueSuccess=c(1,1))
print(tabValue)
valueGraphs <- posteriorGraph(tabValue)
plotPosterior(valueGraphs)
```
```{r}
# nice example plot
tabValue <- data.frame(Label=c('Campaign1','Campaign2'),
Actions=c(100,100),
Successes=c(1,2),
ValueSuccess=c(2,1))
print(tabValue)
print(xtable(tabValue),type='html')
valueGraphs <- posteriorGraph(tabValue)
plotPosterior(valueGraphs,0.05)
```
```{r}
# corner case plot to check
```{r}
# use case 1: user enters two success probability estimates, two success valuations
# and optionally overrides errorProbability, and relativeError
# we compute an experiment plan and show a typical expected outcome
planTab <- data.frame(
Label=c('campaign1','campaign2'),
Probability=c(0.01,0.01),
ValueSuccess=c(1,1))
errorProbability=0.05
relativeError=0.2
# end of user input
p <- sampleGraph(planTab,c(100,100))
computeProbsGES(planTab,p)
```