Van Westendorp analysis, common in market research, aims to find the optimal price point at which to sell a good or service. You find this point, according to Van Westendorp's principles, at the intersection of the cumulative percentages between too inexpensive and too expensive (see Van Westendorp's Price Sensitivity Meter).  You conduct such an analysis in Q by means of a short R script and by creating a final output that shows you, visually, where the intersecting points occur.

## Setting up the Questions and the Data in Q

Van Westendorp analysis relies on the presentation of four questions to your survey respondents:

1. At what price point a good or service is considered so cheap that they would doubt its quality.
2. At what price point a good or service is to be considered cheap, but not cast doubt on its quality.
3. At what point the respondent would consider it expensive.
4. At what price point the respondent would consider it too expensive to buy.

The data should be stored in actual dollar values, so if you've used a single-select question, it is important to first re-code it to the dollar values that each respondent has selected.  Otherwise you may have to use a bit too much imagination to interpret the resultant chart!  Thus, you're better off letting the respondent enter their own dollar value in a numeric entry style question.  In Q, the variables should be grouped together into a Number - Multi question type (for more on grouping questions, see Set Question).  For the rest of the analysis, it's important that they're arranged in the correct order as well, from "too cheap" to "too expensive".

When done, the question (on the Variables and Questions tab) may look something like the below. The name of the question is named in this example as "Van Westendorp data" (the column truncated to just be "Van W..." in the image below).

## Setting up a Table for Analysis

For the analysis proper, we need to have the raw data available to the script.  The easiest way to set this up, without having to reference the individual variables is to take these steps:

1. On the Outputs tab, in the blue drop-down, select the "Van Westendorp data" question we set up earlier.
2. In the brown drop-down, type in "RAW DATA"

This will give us a table showing all the values that the respondents have entered.

## Creating the Chart Data

We'll use a little bit of R script to create our analysis, and you can use the code that follows in your own projects, with only minor modifications. Before we paste in the code, we need to get the reference name of the table with the raw data.  To get this, right-click the table name in the Report tree and select Reference name...  In the dialogue that appears, make a note of the name so that we can use it in the script.  Next, insert the actual script (for which all credit goes to Tim Bock): select Create > R Output, and paste in the following code into the R CODE field.

```
input_data = reference_name
lowest.value = floor(min(input_data)) #Can be manually changed; rounded down
highest.value = ceiling(max(input_data))
x.ticks = .01 #The gap between prices to be plotted

## Do not change what follows unless you understand the script
dollar.values = seq(lowest.value, highest.value, by = x.ticks)
n.values = length(dollar.values)
VWTable = matrix(NA, nrow = n.values, ncol = 4, dimnames = list(dollar.values, c("Too Inexpensive", "Inexpensive", "Expensive", "Too Expensive")))
n = nrow(input_data)
for (i in 1:n.values)
{
value = dollar.values[i]
VWTable[i, 1] = sum(input_data[, 1] >= value) / n
VWTable[i, 2] = sum(input_data[, 2] >= value) / n
VWTable[i, 3] = sum(input_data[, 3] <= value) / n
VWTable[i, 4] = sum(input_data[, 4] <= value) / n
}
VWTable
```

Edit the first four lines of the code according to your requirements, where, on the first line, you should replace reference_name with the reference name you noted down earlier.  The second line of the script finds the minimum value in your data, and rounds it down.  If you do not wish to round it, instead use  min(input_data) without the floor() function. Similarly, the third line finds the highest value and rounds it up (remove ceiling() to not round). Replacing these two bits of programming with the lower and upper value that you wish to use allows you to fine-tune your chart.  The last of these first four lines of script indicates the gap-width between dollar amounts. Here's what it looked like in the attached QPack example:

## Creating the Chart (Visualization)

Now that we have the cumulative data all set up, we set up the chart (which is actually a visualization based in R).  In Q, go to Create > Chart > Visualization > Line chart. Over in the Object Inspector (on the right) in the chart Inputs, select the R Output in the Output drop-down.  The Table to use is the R Output we created earlier.  Change any other settings that you like, and then click  Calculate .

A line chart will now be generated, plotting out the Van Westendorp cumulative data. Should it happen that your data has some outliers in it, then you may end up getting something that looks like what I have here:

Not very useful! To fix this up, go back to the R Output we created before and replace the max value with something that makes a bit more sense.  In this case, I'll use highest.value = 25 (on line 3 of the code), and I'll change the x.ticks to = 0.5 (on the fourth line). In order for it to update, you will need to push   Calculate  again for the visualization (or set the box next it to Automatic). My final output, jagged though it be, comes out like this: