Skip to content

Commit

Permalink
Naming: changing from trial to reach
Browse files Browse the repository at this point in the history
  • Loading branch information
max-alletsee committed Feb 24, 2024
1 parent c293fea commit 677bd8e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions tests/testthat/test_data_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ test_that("Data Output: Rest of Output Object Structure", {
expect_true(is.numeric(psm_result2$pi_scale$pi_calibrated))
expect_false(unique(is.nan(psm_result2$pi_scale$pi_calibrated)))

expect_true(is.numeric(psm_result2$price_optimal_trial))
expect_false(is.nan(psm_result2$price_optimal_trial))
expect_length(psm_result2$price_optimal_trial, 1)
expect_true(is.numeric(psm_result2$price_optimal_revenue))
expect_false(is.nan(psm_result2$price_optimal_revenue))
expect_length(psm_result2$price_optimal_revenue, 1)

expect_true(is.numeric(psm_result2$price_optimal_revenue))
expect_false(is.nan(psm_result2$price_optimal_revenue))
Expand Down Expand Up @@ -253,8 +253,8 @@ test_that("Data Output - Plausibility: Price estimations must be within range of
expect_gte(psm_result1$opp, min(psm_result1$data_vanwestendorp$price))
expect_lte(psm_result1$opp, max(psm_result1$data_vanwestendorp$price))

expect_gte(psm_result2$price_optimal_trial, min(psm_result2$data_vanwestendorp$price))
expect_lte(psm_result2$price_optimal_trial, max(psm_result2$data_vanwestendorp$price))
expect_gte(psm_result2$price_optimal_revenue, min(psm_result2$data_vanwestendorp$price))
expect_lte(psm_result2$price_optimal_revenue, max(psm_result2$data_vanwestendorp$price))

expect_gte(psm_result2$price_optimal_revenue, min(psm_result2$data_vanwestendorp$price))
expect_lte(psm_result2$price_optimal_revenue, max(psm_result2$data_vanwestendorp$price))
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test_data_output_weighted.R
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ expect_length(psm_results_w3$nms, 1)
expect_true(is.numeric(psm_results_w3$pi_scale$pi_calibrated))
expect_false(unique(is.nan(psm_results_w3$pi_scale$pi_calibrated)))

expect_true(is.numeric(psm_results_w3$price_optimal_trial))
expect_false(is.nan(psm_results_w3$price_optimal_trial))
expect_length(psm_results_w3$price_optimal_trial, 1)
expect_true(is.numeric(psm_results_w3$price_optimal_reach))
expect_false(is.nan(psm_results_w3$price_optimal_reach))
expect_length(psm_results_w3$price_optimal_reach, 1)

expect_true(is.numeric(psm_results_w3$price_optimal_revenue))
expect_false(is.nan(psm_results_w3$price_optimal_revenue))
Expand Down Expand Up @@ -252,8 +252,8 @@ test_that("Data Output - Plausibility: Price estimations must be within range of
expect_gte(psm_results_w1$opp, min(psm_results_w1$data_vanwestendorp$price))
expect_lte(psm_results_w1$opp, max(psm_results_w1$data_vanwestendorp$price))

expect_gte(psm_results_w3$price_optimal_trial, min(psm_results_w3$data_vanwestendorp$price))
expect_lte(psm_results_w3$price_optimal_trial, max(psm_results_w3$data_vanwestendorp$price))
expect_gte(psm_results_w3$price_optimal_reach, min(psm_results_w3$data_vanwestendorp$price))
expect_lte(psm_results_w3$price_optimal_reach, max(psm_results_w3$data_vanwestendorp$price))

expect_gte(psm_results_w3$price_optimal_revenue, min(psm_results_w3$data_vanwestendorp$price))
expect_lte(psm_results_w3$price_optimal_revenue, max(psm_results_w3$data_vanwestendorp$price))
Expand Down
22 changes: 11 additions & 11 deletions vignettes/visualizing-psm-results.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,19 @@ legend("bottomleft",

### ggplot: Optimal Trial and Revenue (based on Newton Miller Smith Extension)

When we have information of the purchase intent at the "cheap" and at the "expensive" price point, we can also model the optimal price to maximize trial or revenue based on the Newton Miller Smith Extension
When we have information of the purchase intent at the "cheap" and at the "expensive" price point, we can also model the optimal price to maximize reach or revenue based on the Newton Miller Smith Extension

```{r, fig.width=7}
library(ggplot2)
# Plot for Optimal Trial
ggplot(data = output_psm$data_nms, aes(x = price)) +
geom_line(aes(y = trial)) + # trial curve
geom_vline(xintercept = output_psm$price_optimal_trial,
geom_line(aes(y = reach)) + # reach curve
geom_vline(xintercept = output_psm$price_optimal_reach,
linetype = "dotted") + # highlighting the optimal price
geom_text(data = subset(output_psm$data_nms, trial == max(trial)),
aes(x = price + 0.5, y = trial),
label = paste("Optimal Price:", output_psm$price_optimal_trial),
geom_text(data = subset(output_psm$data_nms, reach == max(reach)),
aes(x = price + 0.5, y = reach),
label = paste("Optimal Price:", output_psm$price_optimal_reach),
hjust = 0) + # labelling the optimal price
labs(x = "Price", y = "Likelihood to Buy (Trial)",
title = "Price Sensitivity Meter: Price for Optimal Trial",
Expand Down Expand Up @@ -314,7 +314,7 @@ par(cex.sub = 0.66) # reducing the font size of the subtitle
# a) Plot for Optimal Trial
# Main plot: Line, axis descriptions
plot(x = output_psm$data_nms$price,
y = output_psm$data_nms$trial,
y = output_psm$data_nms$reach,
type = "l",
main = "Price Sensitivity Meter: Price for Optimal Trial",
xlab = "Price",
Expand All @@ -330,13 +330,13 @@ par(adj = adj.old) # restore standard (so that next main title is again centered
# drawing additional line to highlight optimal price
abline(v = output_psm$data_nms$price[which.max(output_psm$data_nms$trial)],
abline(v = output_psm$data_nms$price[which.max(output_psm$data_nms$reach)],
lty = "dotted")
# annotating the optimal price
text(x = output_psm$data_nms$price[which.max(output_psm$data_nms$trial)],
y = max(output_psm$data_nms$trial),
labels = paste("Optimal Price:", output_psm$price_optimal_trial),
text(x = output_psm$data_nms$price[which.max(output_psm$data_nms$reach)],
y = max(output_psm$data_nms$reach),
labels = paste("Optimal Price:", output_psm$price_optimal_reach),
pos = 4)
# b) Plot for Optimal Revenue
Expand Down

0 comments on commit 677bd8e

Please sign in to comment.