10 Survey design & analysis

10.1 Your tasks

In this section you will find all information related to the group project. Generally, the group project comprises two parts:

  1. Questionnaire design & data collection: In the first part, you will work with your group on creating a questionnaire. Once you have created a draft of your questionnaire, you will present the draft to us and we will provide feedback. After implementing the feedback, you will submit the final version of the questionnaire and start the data collection using an online survey.
  2. Data analysis & presentation: In the second part, you will apply the statistical knowledge acquired during the course to analyze your data and present your findings using a video recording and submit your report (R code and video presentation).
Structure of the group project

Figure 10.1: Structure of the group project

Note that this assignment may require you to deal with and integrate knowledge that has not yet been covered in class! Students are expected to read ahead and collect additional information to the extent to which their project requires this.

10.1.1 Topics for the group project

The first step is to select a topic from the list below. We will send out a survey, asking you to rank the top 3 topics so that we can assign the topics according to your preferences. Please note that only one person per group needs to fill out the survey after you discussed which topic to chose within your groups. If two or more groups have the same preference for a topic, we will select one group randomly.

No.  Topic Description
1 Consumers’ willingness to pay for organic products Develop a questionnaire to measure consumers’ willingness to pay for organic products (e.g., milk). How much are consumers willing to pay for organic milk vs. conventional milk? What is the observed price premium? How does this vary across consumers? What are the drivers? Does it reflect a desire to achieve better health, eat better quality food, or to contribute to environmental protection?
2 The impact of social distancing on student’s learning experience The recent COVID-19 pandemic affected virtually all aspects of people’s lives. For university students, many courses that were previously delivered on campus switched to distance learning mode. Develop a questionnaire to assess how distance learning affects student’s learning experiences. What are advantages and disadvantages of online teaching? What teaching aids are most helpful to students? What tools should teachers use to overcome the disadvantages?
3 Student canteen (Mensa) and the WU campus Develop a questionnaire to measure students‘ attitudes and its drivers (e.g., quality of meals, price, etc.) toward the canteen and other restaurants on the campus
4 Privacy in social media – consumers’ willingness to switch to a secure messaging service Develop a questionnaire to measure consumers’ willingness to switch from WhatsApp to a secure messaging service (e.g., Threema). What are the main motives (e.g., security concerns, costs, usability, etc.), and are consumers willing to pay for the secure service provider? Can you find evidence for the “privacy paradox?” What factors make users give up their privacy?
5 Consumers‘ attitude and willingness to pay for store brands Develop a questionnaire to measure consumers’ willingness to pay for a store brand (e.g., “Clever,” “Billa”). Are consumers willing to pay more for the manufacturer’s brand than for the store brand? What factors affect consumers’ choice?
6 COVID-19 and consumers’ preference and attitude towards online grocery shopping More and more people use online shopping services (e.g., Amazon Fresh, BillaOnline) to buy groceries, especially since the Coronavirus outbreak. Develop a questionnaire to measure consumers’ attitude and its drivers (e.g., price, service) towards the online grocery shopping. Are there differences before, during and after the pandemic. Are consumers less price sensitive when shopping online than in the offline stores? How likely are consumers to continue using online shopping services in the future?
7 The most liveable city in the world Vienna is frequently listed as one of the most liveable cities in the world (e.g., by the Economist Intelligence Unit). Develop a questionnaire to investigate the reasons why Vienna ranks so high in different rankings. What are the factors that contribute to its image? Are there differences between different groups of people?
8 Self-driving cars Companies such as Google heavily invest in the development of self-driving cars. Develop a questionnaire to measure consumers attitude and usage intention for self-driving cars. What are the drivers and deterrents of the consumers’ willingness to adopt this innovation?
9 Front-of-package nutrition labels Frequent consumption of unhealthy foods can lead to overweight or obesity, hypertension, and cardiovascular disease. The consequences of poor diets is putting a burdon on health care systems and front-of-package labels have been proposed as a means to help consumers to gain a better understanding of the ingredients of a product. Develop a questionnaire to test how front-of-package nutrition labels affect consumer choice. Which type of label is most effective?
10 Consumer preferences for fair-trade products in the apparel industry Develop a questionnaire to measure consumers’ preferences for sustainable brands and eco fashion. Conduct an experiment to determine whether there are different perceptions regarding the “Fair Trade” effect.
11 Going and being vegan: consumers willingness to make the change More and more people are turning to a vegan diet for many reasons, including health, concerns about animal welfare or a desire to protect environment. Develop a questionnaire to measure consumers’ willingness to become a vegan and its drivers (e.g., health, environment, compassion for animals). Did the Coronavirus outbreak change consumer attitudes towards meat-based products?
12 Freemium business models in the music industry Many music streaming services (e.g., Spotify) offer a baseline version free of charge to consumers but charge for a premium version with additional features. Develop a questionnaire to measure consumers’ attitude towards legal music streaming providers. What factors influence the attitude (e.g., occupation, gender, usage behavior etc.), and how could companies motivate consumers to convert to the premium version of the service?
13 Local vs. global brands Some researchers argue that the increasing globalization leads to the homogenization of consumer needs and desires across the globe and companies address this trend with standardized global products. However, some consumers appear to prefer local brands over global brands. Develop a questionnaire that investigates the drivers of consumers’ attitudes toward global and local brands.
14 The climate debate and green consumption The climate debate is currently on the top of the agenda of many news outlets. Some public figures that strongly favor one side dominate and emotionalize the debate (e.g., Greta Thunberg, Donald Trump). Explore in how far consumers are willing to change their behavior (e.g., cut air-travel) to help protect the environment. What factors influence the willingness to change (e.g., social factors, convenience)?
15 Car-sharing vs. vehicle ownership Develop a questionnaire to explore the attractiveness of car sharing options for consumers (e.g., Car2go). Are consumers willing and planning to substitute a personal vehicle through car sharing option? Is car sharing likely to affect the amount of driving? Which factors influence these decisions?
16 Consumers’ attitude towards legal video streaming providers and piracy Video streaming providers like Netflix record a continuous increase in registered users. On the other hand, illegal video streaming portals (e.g., Popcorn Time) are heavily used by other consumers. Develop a questionnaire to measure consumers’ attitude and drivers (e.g. occupation, gender, usage behavior etc.) towards legal video streaming providers. What could be reasons for piracy?
17 Design your own questionnaire on a topic of your choice Feel free to choose topic of your choice as well.

10.1.2 Guidelines

In this section, you can find some guidelines regarding the design of your questionnaire and the final presentation.

Individual responsibility:

  • Group members should plan to share responsibilities equally
  • All members of the group must contribute to the project
  • Each student will receive an individual grade for presentation
  • To ensure an equal contribution of group members, a peer assessment will be conducted, which enters into the computation of the individual grades for the group project

Submission

There are two grading components:

  • Questionnaire design & data collection: When you submit your questionnaire draft, please submit 1) the pdf printout from Qualtrics, 2) a short slide deck explaining your research problem and how you intend to solve it (research design, measurement & scaling, intended analyses). We will go through the presentation during the first coaching session. After this, you’ll have time to revise the questionnaire based on the feedback that you received.
  • Data analysis & presentation: When you submit your final presentation, please submit a .zip folder containing 1) the video recording, 2) the data, 3) the R code file, and 4) your slides.

10.1.2.1 Questionnaire design & data collection

In the presentation of your questionnaire design, you should address the following points:

Problem statement & research hypotheses

  • What is the research problem & why is it relevant from a managerial perspective?
  • What research questions do you intend to answer with your research?
  • What are your hypotheses?

Questionnaire structure & research design

  • Please provide a justification for the structure of your questionnaire
  • Use appropriate wording in the questionnaire to obtain the desired information
  • Provide explanations regarding your choice of research design to answer the research questions

Reasons for variable selection & measurement and scaling

  • Please provide a justification of why you chose your variables and the associated choices regarding the measurement & scaling of these variables
  • What are the expected relationships between the independent variable(s) and your dependent variable(s)?

Plan your statistical analyses

  • Although we won’t have covered all methods when you submit your questionnaire design, you should plan ahead and present some ideas on how you plan to analyze your data
  • It is important to consider this before collecting your data, since the type of data you will obtain affects the type of methods you can use

10.1.2.2 Data analysis & presentation

For your data analysis & final presentation, you should consider the following points:

Problem statement

  • Be clear about the problem that you are trying to solve or the research question(s) you would like to answer
  • Why is the problem relevant from a managerial perspective?

Presentation structure

  • Think about the overall structure of your presentation before you start designing the individual slides.
  • Given your research problem/question, what slides/content do you need to have in the presentation to answer your research question or solve your problem?
  • Please don’t include an accumulation of visualizations that lead nowhere. Instead, ask yourself, is this chart contributing to the answer of your research question?
  • It is usually a good idea to start with an introduction to the topic and the research question(s). Next, you may describe and justify your research design (e.g., causal inference vs. predictive vs. descriptive) that you chose to address the research questions(s). After that, you should provide some descriptive statistics about your sample. In a next step, you should present your results regarding the central research questions. Remember to include all the necessary information that are required to understand the results (e.g., number of observations, wording of questions, etc.). It is usually a good idea to include appropriate visualizations of the variables that you are investigating. You do not need to include all assumption tests for the methods in the main body of the presentation. However, you should still test if the assumptions are met and include the results in the appendix in case there are questions. Finally, you should discuss/interpret your results with regard to the managerial research question(s) and list potential limitations of your research.

Choice of appropriate statistical tests

  • Please provide a justification for the choice of statistical test (e.g., t-test, regression, ANOVA, parametric vs. non-parametric) given your choices regarding the types of variables.
  • Remember to use the correct terminology and e.g., state the dependent and independent variables.
  • If you use a regression model, also include a formal statement of the regression equation so it is clear what is being analyzed, e.g., \(log(DV)=\beta_0+\beta_1*log(IDV1)+\beta_2*log(IDV2)+\epsilon\). From the regression equation, it should be clear what type of model it is (linear regression vs. logistic regression), what the dependent variable is, what the independent variables are, and whether the values are transformed (e.g., logarithms) or not.
  • If your analyses include multiple steps, make sure that it is clear to the audience why the individual steps were conducted and how they relate to each other (e.g., if you do a PCA first to reduce the dimensionality of the data and then include the resulting factor scores in a regression model, make sure that the purpose of each step is clear).

Implementation of analysis

  • Make sure that you store the R code you used for your analysis and submit it along with your data & the slides to the assignment on Learn. This way, it is transparent how you arrived at your results.
  • We should be able to replicate your results by running the code.

Visualizations

  • Select appropriate plots to visualize your variables (e.g., scatter plot, boxplot, mean plot, histogram)
  • Not every visualization that you could potentially come up with really makes sense to put into a presentation. Again, ask yourself, is this chart contributing to the answer of your research question(s)?
  • Do not forget legends and labels of the axes in your visualization!
  • Remember to include all information that are required to understand the visualization (e.g., the wording of the question, the number of observations, axis labels)
  • Keep it simple and make sure that a visualization can be easily understood. Adding too much information into a visualization is very often misleading for your audience and hurts more than you might think.
  • In case a visualization is not easily comprehensible, you might think about adding a note that explains the audience how-to-read the visualization using an example.

Reporting and interpretation of model results

  • Report your analysis in an appropriate way (e.g., use the ‘stargazer’ package to report the results of regression models or use the ‘ggstatsplot’ package to provide test summaries).
  • Interpret all relevant test statistics (e.g., test statistics, confidence intervals, coefficients and their significance and relative importance, R-squared, effect sizes, etc.).
  • Discuss the recommendations derived from analysis. Do not skip this part! Always assume that you have an audience of decision makers. You need to tell them what to do based on your analysis.

10.1.3 Timeline

This section summarizes important dates for the first part of your group project:

Date_A Time_A Date_B Time_B Task Chapters Link
Oct. 21 11:59PM Oct. 25 11:59PM
  • Submit questionnaire draft
10
Oct. 23* 09:00AM - 02:30PM Oct. 27* 02:00PM - 08:00PM
  • Coaching: Questionnaire design (live video coaching)
10 TBC
Nov. 1 11:59PM Nov. 4 11:59PM
  • Submit revised questionnaire
10
Note: Dates and times are indicated for groups A and B respectively.
Sessions indicated with ’*’ are group coaching sessions. Slots of 45 min. are assigned to each group within the indicated times.


In the second part of your project, after you have collected your data, the following dates are important:

Date_A Time_A Date_B Time_B Task Chapters Link
Nov. 16* 01:30PM - 04:30PM Nov. 18* 02:00PM - 05:00PM
  • Coaching: Data handling (live video coaching)
TBC
Nov. 23* 01:30PM - 06:30PM Nov. 25* 03:00PM - 08:00PM
  • Coaching: Data analysis (live video coaching)
TBC
Dec. 7 11:59PM Dec. 9 11:59PM
  • Submit video recording of presentation (pre-recorded)
Note: Dates and times are indicated for groups A and B respectively.
Sessions indicated with ’*’ are group coaching sessions. Slots of 45 min. are assigned to each group within the indicated times.

10.2 Part 1: Before collecting data

This section provides some information regarding the first part of the group project: questionnaire design & data collection.

An aim of this course is to develop your ability to translate business problems into actionable research questions and to design an adequate research plan to answer these questions. Therefore, you need to be equipped with knowledge on how to create a survey and properly conduct a research.

Generally, what you can expect from the survey design is similar to what one experiences in a relationship. If you try to take more than you commit, it doesn’t work out. Now on a serious note, if you follow guidelines mentioned here, you will certainly avoid usual traps your fellow colleagues were caught in.

In a research process, conducting a survey is a part of (primary) data collection. Before we collect data, we have to make sure that preceding steps are correctly done. However, in the following sections we will focus on the process of designing a questionnaire. Eventually, you will be able to collect relevant data and apply appropriate statistical tests.

10.2.1 Research design

As you aim to conduct a real marketing research, before you start writing down questions for a questionnaire, you need to come up with a research design. In particular, you should review the research questions, hypotheses and characteristics that influence the research design.

If you are interested in the causal effect of one particular (independent) variable on another (dependent) variable, think about an experimental design that might allow you to manipulate this variable. In this case, you particularly have to decide on the following:

  • Which variable to manipulate?
  • Whether to use a between-subjects or within-subjects design?
  • The cause-effect sequence (the cause must occur before the effect)
  • The number of experimental conditions
  • Potential interactions and relationships with other variables (does the effect depend on another variable?)

What you need to be careful about is the effect of reversed causation. The effect refers to the situation where the causal relationship could possible have an opposite direction from what we assumed at the first place. For instance, it is often assumed that an increase in individual income leads to increase in well-being (happiness). However, some researches suggest that this causation could have an opposite direction, i.e. that actually increase in well-being of an individual leads to an increase in income.

Here are some examples of causal research design applications:

  • To assess how a product’s country-of-origin impacts attractiveness across different countries.
  • To analyse the effects of rebranding on customer loyalty.

If you would like to analyze the effects of multiple categorical or continuous (independent) variables on one continuous (dependent) variable, you might use a regression model. When doing this, you particularly have to decide on:

  • How to measure the dependent variable (DV). This is particularly important, since you need a variable that is powerful in uncovering variation between subjects (e.g., open-ended questions, such as “How much are you willing to pay for this product” are good candidates). Moreover, you also need to consider the nature of your DV,i.e. whether it is an interval variable, ordinal or categorical variable. The nature of your DV will heavily influence your choice of a correct statistical test.

  • How to measure the independent variables (IV) (single-item vs. multi-item scales, categorical vs. continuous). Bear in mind that the nature of the IV, together with DV, affects your choice of a statistical test as well.

  • What other variables might cause the effect that you would like to investigate (to prevent omitted variable bias, i.e. variables that are not part of your model but still influence the dependent variable).

  • Potential interactions (e.g., is the effect of variable X stronger for group A vs. B?)

10.2.2 Survey method

In the next step you should review the type of survey method you will use.

At this point you need to think in which setting you aim to conduct your survey. For instance, should you do it in a face-to-face setting or rather online. Here you can find some advantages and disadvantages of online surveys:

Advantages Disadvantages
Speed Sampling issues
Cost Access issues
Quality of response Technical problems
No interviewer bias
Access to unique populations

Here is the list of the online tools you can use to conduct an online survey (usually for free):

For the purpose of this course, we suggest to use Qualtrics.

A questionnaire creation in Qualtrics starts with creation of a Qulatrics project. Each project consists of a survey, distribution record, and collection of responses and reports. There are three ways to create a questionnaire. First, you can create a new survey project from scratch. Second, you can create a new questionnaire from a copy of an existing questionnaire. Eventually, you can create from a template in your Survey Library, or from an exported QSF file.

In order to create a completely new questionnaire, you need to do the following:

Go to the Projects page by clicking the Qualtric XM logo or clicking Projects on the top-right.

Create new project by clicking the blue button on the right side.
In the “Create your own” section click on the survey button.

Enter a name for your survey and get started with a survey creation.

If you would like to create a new questionnaire on a basis of an already existing one, then you choose “From a Copy.” Subsequently, you need to indicate the questionnaire you would like to copy. Now you are good to go!

If there is a questionnaire in the Qualtrics Library you would like to use, then you need to choose “From Library,” and indicate one library name in the dropdown menu.

10.2.3 Questionnaire

After you set up everything, you should develop 20 - 25 questions. However, there are some important objectives to keep in mind while developing a questionnaire:

  • Information you are primarily interested in (dependent variable)
  • Information which might explain the dependent variable (independent variables)
  • Other factors related to both dependent and independent factors
  • Who’s answering the questions?

If you have sorted out all answers on the previous questions, you are ready to start writing the content. Again, here are some important things to remember:

  • The purpose of the questionnaire
  • Why it is important for you and why it could be useful for the respondent
  • How long it should take to complete & the final date for a reply
  • Ask questions in a logical order & use the right type of questions
  • Aim for brevity & use simple language

10.2.3.1 Questionnaire and research design

The questionnaire design should be aligned with the research design! Therefore, in the following sections we will explain some suggested steps on how to approach questionnaire creation.

Let’s start with what is a questionnaire. A structured questionnaire is a research instrument designed to elicit specific information from a sample of a target population. Usually it is used in a standardized way with fixed-alternative questions (same questions and response options for all respondents).

An objective of a questionnaire is threefold:

  • to translate the information need into a set of specific questions that the respondent can and will answer,
  • to motivate, and encourage respondents to become involved, to cooperate, and to complete the questionnaire,
  • to minimize response error.

10.2.3.2 Content in a questionnaire

In this step you are starting to work on the content of you questions.

At the beginning of the questionnaire you should give a brief introduction to your respondents in the context of your research and the content of the questionnaire. Try to use simple language and avoid technical terms. Additionally, in the introduction you should state how long the survey will approximately take.

When you start thinking about the questions to ask, there are several points to consider:

  • Is the question necessary?
  • Will I obtain the needed information?
  • Are several questions needed instead of one?
  • What type of data can I collect by asking that question (categorical or continuious)?

In your survey try to avoid asking double-barrelled questions.Those are a single question that attempts to cover two issues. Such questions can be confusing to respondents and result in ambiguous responses. Instead, you might ask multiple questions in order to obtain the inteded information.

Incorrect

Do you think Nike Town offers better variety and prices than other Nike stores?

Correct

Do you think Nike Town offers better variety than other Nike stores?
Do you think Nike Town offers better prices than other Nike stores?

10.2.3.3 Inability and unwillingness to answer

The quality of collected data you highly depends on your ability to address correct participants. Therefore, you need to make sure that your respondents are able to meaningfully answer your questions.

Examples:

  • Not every household member might be informed about monthly expenses for groceries purchases if someone else makes these purchases.
  • Use filter questions that measure familiarity and product use.
  • Include a “don’t know” option.
  • If you ask participants for monteray values (e.g. how much are you ready to pay for the XY product?) across several EU, make sure you indicate correct currency (e.g. HRK for Croatia or HUF for Hungary).
  • Think about how mobile friendly is the layout of your survey (if it is an online survey).
  • Good case practices suggest that there should not be more than 2 questions per page (for online surveys displayed on mobile phones).

If you are asking participants to recall certain brands for instance, make sure you use unaided recall question:

Correct

What brands of soft drinks do you remember being advertised on TV last night?

Incorrect

Which of these brands were advertised last night on TV?
a) Coca-Cola
b) Pepsi
c) Red Bull
d) Evian
e) Don’t know

If you are asking participants to list something, the good case practice is to minimize the effort required by respondents:

Correct

Please check all the departments from which you purchased merchandise on your most recent shopping trip to a department store:
a) Women’s dresses
b) Men’s apparel
c) Children’s apparel
d) Cosmetics
e) Jewelry
f) Other (please specify) ___________

Incorrect

Please list all the departments from which you purchased merchandise on your most recent shopping trip to department store X.

In a case you are asking for information that could be considered sensitive (e.g. money, family life, political beliefs, religion), they should come at the end of the questionnaire. Moreover, it is recommendable to provide response categories rather than asking for specific figures:

Correct

Which one of the following categories best describes your household’s annual gross income?
a) under 25.001 €
b) 25.001€ to 50.000 €
c) 50.001€ to 75.000 €
d) 75.001€ to 100.000 €
e) over 100.000 €

Incorrect

What is your household’s exact annual income?

10.2.3.4 Decide on measurement scales and scaling techniques

Every statistical analysis requires that variables have a specific levels of measurement. Measurement scales you choose for your questions in a survey will affect the answers you get and eventually statistical test you can apply. For instance, it would not make sense to compute an average of genders. An average of a categorical variable does not make much sense. Moreover, if you tried to compute the average of genders defined in numeric values (e.g. male=0, female=1), the output would be interpretable.

It is crucial to become familiar with possibilities of each scale before you choose to add another question to your survey. Consequently, chances to obtain data you did not intend to collect and chances that you will not be able to apply tests you intended are significantly lower.

In the following table you can get a quick overview of possibilities per each measurement scale. :

In the figure below you can find general procedure for choosing a correct analysis based on the measurement scale of your data and number of variables. It shows statistical analyses we covered during the course and aims to help you choose among them based on the nature of dependent variables on the side, and the nature and the number of your independent variables on the other side:

It is highly recommended to think about what type of data you want to collect and what test to use, before you form a question and add to the survey. We highly recommend you NOT to add questions without thinking what type of data you are going to collect with it. If you do so, you may end up with data you did not want to collect, and moreover, with data unsuitable for the test you intended to use.

Here you can find extremely nice overview of statistical test associated with different types of variables:LINK

10.2.3.5 The most frequent types of questions

Here we want to show you the most frequent types of questions students use and what type of data can be collected by using them.

10.2.3.5.1 Number entry question
Text or number entry question

Figure 10.2: Text or number entry question

A number entry question is a recommended type of question if you are interested in obtaining ratio data type. Ratio data type gives you flexibility to apply a broad range of statistical analyses such as regression analysis, correlation computation, t-test (or ANOVA), or factor analysis. Data collected by number entry question is handy to use with data collected by slider questions or with a constant sum question. Note that in this case we treat constant sum data as ratio data and therefore assume that 0 means complete absence.

10.2.3.5.2 Multiple choice question

Multiple Choice with a single answer is a type of closed-ended question that lets respondents select one answer from a defined list of choices.Type of data you obtain is categorical.

Multiple choice question with single answer

Figure 10.3: Multiple choice question with single answer

Statistical test that you can think of when analysing categorical data:

  • Fisher’s exact test
    • Used when frequency in at least one cell is less than 5 . When frequencies in each cell are greater than 5, Chi-square test should be used
    • 1 dependent variable and 1 independent variable with 2 or more levels/factors
    • Hypothesis: Is there a significant difference in frequencies between values observed in cells and values expected in cells
  • Chi-square test
    • Goodness of fit: when you only have 1 dependent variable and none independent variables
      • Hypothesis: Is there a significant difference in frequencies between values observed in cells and values expected in cells ?
    • Chi-Square Test of Independence: when you have 1 dependent variable and 1 independent variable with 2 or more levels/factors.
      • Hypothesis: Is there an association between categorical variable X and categorical variable Y?
  • Binomial logistic regression
    • Used when you have an independent variable of at least interval scale and dependent variable is a categorical variable that can take on exactly two values (1 or 0, i.e., yes or no).
  • Categorical variables can be used as predictors in regression (as dummy variables).
Multiple choice question with multiple answers

Figure 10.4: Multiple choice question with multiple answers

It is important to distinguish multiple choice questions with single and multiple answers (which will be presented later) as their analysis looks differently.

For the analysis of results collected with multiple choice question with multiple possible answers, we can use Cochran’s Q test. Although we did not mention it before, it is not too different from what you have already learned about other tests.

The Cochran’s Q test and associated multiple comparisons require the following assumptions:

  1. Responses are dichotomous and from k number of matched samples.
  2. The subjects are independent of one another and were selected at random from a larger population.
  3. The sample size is sufficiently “large.” (As a rule of thumb, the number of subjects for which the responses are not all 0’s or 1’s, n, should be ≥ 4 and nk should be ≥ 24)
10.2.3.5.3 Rank order question
Rank order question

Figure 10.5: Rank order question

A rank order question asks respondents to compare items to each other by placing them in order of preference. Note that the data obtained from a rank order question shows an order of a respondent’s preference, but not the difference between items. For instance, if it turns out that the most important feature of a fitness tracker for a respondent XY is “Measuring steps” and the second most important feature “Calories burned,” we don’t know for how much more important is the former one in comparison to the latter one.

In order to analyze results from a rank order question, we use Friedman rank sum test.

Friedman rank sum test is used to identify whether there are any statistically significant differences between the distributions of 3 or more paired groups. It is used when the normality assumptions for using one-way repeated measures ANOVA are not met. Another case when Friedman rank rum test is used is when the dependent variable is measured on an ordinal scale, as in our case.

10.2.3.5.4 Constant Sum question
Constant sum question

Figure 10.6: Constant sum question

If you wish to obtain information about how much one attribute is preferred over another one, you may use a constant sum scale. The total box should always be displayed at the bottom to make it easier for respondents. A constant sum question permits collection of ratio data type. With data obtained we would be able to express the relative importance of the options.

With the data collected we are able to answer the question: what factor is the most important for our respondents when they go out for a dinner?

In order to answer this question we need to conduct a repeated measures ANOVA.

This type of ANOVA is used for analyzing data where the same subjects are measured more than once. In our case we have every respondent measured on each of the factors (locations, price, ambience and customer service). Repeated measures ANOVA is an extension of the paired-samples t-test. This test is also referred to as a within-subjects ANOVA. In the within-subject experimental design the same individuals are measured on the same outcome variable under different time points or conditions.

10.2.3.6 Scaling techniques

When it comes to scaling techniques, they are meant to study the relationship between objects. The basic scaling techniques classification is on comparative and non-comparative scales.

The noncomparative scale each object is scaled independently of the other objects. The resulting data is supposed to be measured in an interval and ratio scaled.

Comparative scales (or nonmetric scaling) compare direclty the stimulus object. For example, the respondent might be asked directly about his preference between domestic and foreign beer brands. As a result, the comparative data collected can only be interpreted in relative terms. In the following sections we will walk through both types of comparative scales and briefly introduce them.

10.2.3.6.1 Comparative scale: Paired Comparison
  • Respondent is presented with two objects and asked to select one according to some criterion.
  • The nature of resulting data is ordinal
  • Assumption of transitivity (if X > Y and Y > Z, then X > Z) enables the paired comparison data to be converted into a rank order. To do so, you need to indetify the number of times the object is preferred by adding up all the matrices.
  • Effective when the number of objects is limited as it requires the direct comparison, and a bigger number of objects makes the comparison becomes unmanagable.
  • Example:
    For each pair, please indicate which of the two brands of beer in the pair you prefer.
10.2.3.6.2 Comparative scale: Rank Order
  • Allow a certain set of brands or products to be simultaneously ranked based upon a specific attribute or characteristic.
  • The rank order scaling is a good proxy for to the shopping setting as there are simultaneous comparisons of objects.
  • The rank order scaling results in the data of ordinal nature.
  • Example:
    Rank the various brands of beer in order of preference. Begin by picking out the one brand that you like most and assign it a number 1. Then find the second most preferred brand and assign it a number 2. Continue this procedure until you have ranked all the brands of beer in order of preference. No two brands should received the same rank number.

10.2.3.6.3 Comparative scale: Constant sum
  • Respondents allocate a constant sum of units (e.g., points, dollars) among a set of stimulus objects with respect to some criterion.
  • Constant sum is similar to rank order, but it carries specific units.
  • The resulting data does not just indicate important factors, but also by how much a factor supersedes another one.
  • Constant sum scaling can be used to observe the comparative significance respondents assigned to various factors of a subject.
  • Example:
    There are 8 attributes of bottled beers. Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each attribute.

  • Basic analysis of constant-sum data involves tabulation of responses and presenting them as either quantities (e.g., “on average, 7 points were allocated to”high alcohol level“), or, as proportions (”On average, 7% of points were allocated to “high alcohol level”).
10.2.3.6.4 Non-Comparative Scales: Continuous Rating Scales
  • Participants rate the objects by placing a mark at the appropriate position on a line that runs from one extreme of the criterion variable to the other.
  • One of the advantages of the continuous rating scale is that it is easy to administer.

  • Once the ratings are collected, you can splits up the obtained ratings into categories and then assign those depending on the category in which the ratings fall.
10.2.3.6.5 Non-Comparative Scales: Itemized Rating Scales
  • The respondents are provided with a scale that has a number or brief description associated with each category.
  • The categories are ordered in terms of scale position, and the respondents are required to select the specified category that best describes the object being rated.
  • The commonly used itemized rating scales are the Likert, semantic differential and Stapel scales.
10.2.3.6.6 Itemized Rating Scales: Likert scale
  • Requires respondents to indicate their attitude towards the given object through the degree of agreement or disagreement with each of a series of statements within typically five or seven categories.
  • Reversed code of some items increases validity.
  • One limitation is time required to answer a question on a Likert scale. Compared to other itemized scaling techniques, Likert scale is more time consuming as each respondent is required to read every statement given in a questionnaire before assigning a numerical value to it.

In the table below you can find a couple of commonly measured constructs in marketing research such as attitude, importance, purchase intention and similar.

10.2.3.6.7 Itemized Rating Scales: Semantic Differential
  • Typically, participants rate objects on a number of itemized, seven-point rating scales bounded at each end by one of two bipolar adjectives.

  • Semantic differential can measure respondent attitudes towards something (products,concepts, items, people…).

  • It helps you find the respondent’s position is on a scale between two bipolar adjectives such as “Sweet-Sour” or “Bright-Dark.” In comparison to Likert scale, which uses generic scales (e.g. extremely dissatisfied to extremely satisfied), semantic differential questions are posed within the context of evaluating attitudes.

  • Widely used rating scale in marketing research due to its versatility

When creating a semantical difference question, you should consider the following:

  • Number of categories:

  • Balanced vs. unbalanced:

  • Odd/even number of categories:

  • Forced vs. non-forced response

  • Verbal description:

10.2.3.7 Questionnaire structure

The sequence of questions in a questionnaire could play important role. For instance, more sensitive questions (such as demographic-related questions) are usually placed at the end as they can trigger change in respondent’s behavior.

If you plan to conduct an online survey, then you need to think about the respondent’s experience while doing your questionnaire. For instance, spread the content over more short pages and do not have fewer long pages. In online surveys, two questions on one page is a useful rule of thumb. Generally, respondents are reluctant to read and fill out long questionnaire pages. Hence, long pages will lead to a higher dropout rate. In order to reduce dropout rate state how long the survey will approximately take in the introduction of the questionnaire. Take into account that tools like Qualtrics provide the estimated response time in the survey overview.

Consider that the most of people usually use their phones to fill it out. Think about how the questionnaire will appear on a phone screen too. In that regard, think of length of questions especially.

In the end, the questionnaire structure has to be aligned with the research design. For example, if your research design features an experiment, this needs to be reflected in the questionnaire (e.g., you need to assign the respondents randomly to the experimental conditions in case of a between-subjects comparison).

10.2.3.7.1 Questionnaire structure for a between-subjects design

In a between-subject design you randomly assign each respondent to different experimental conditions. They would then complete tasks only in the condition to which they are assigned.

For instance, we would like to test the effect of two advertisements on purchase intention. Therefore, one group of (randomly assigned) respondents will be exposed to one advertisement version while the other group (of randomly assigned respondents) will be exposed to another version. After that, both groups of respondents should express their willingness to buy the advertised product. Evenutally, if the dependent variable (e.g. willingness to buy) is measured on interval or ratio scale, then you can use independent t-test to compare group means. The whole experimental design should be organised as following:

Qualtrics is a great tool to conduct an appropriate survey in between-subject design. In order to randomly assign your respondents to a test group or a control group, and to know to which condition each respondent belongs, a randomizer needs to be set up in advance in the survey flow. Below you can find detailed explanation how to add it to your survey.

How to set up a randomizer in Qualtrics

Here is how to set up a randomizer in Qualtrics, so that your participants are going to be assigned either to A or B condition.

First, navigate to the Survey tab and open your Survey Flow.

Then click Add Below or Add a New Element Here, depending to where you want to place a randomizer.

Then choose Randomizer.

Finally, you set the number (the one between - and +) to 1 and check the option “Evenly Present Elements.” Next you edit embedded data fields by naming it (e.g., “Group” and “Control,”“Test Group 1,”“Test Group 2.”)

It is very imporant to think about the place to set a randomizer in a survey workflow. You want to place it always before you branch your survey flow, so that you can keep track of which respondent was exposed to which condition. If you do not set a randomizer before branching, it would remain unknown what condition each respondent was exposed to. Here is how it was done in our example of Qualtrics survey.

After respondents are randomly assigned either to A or B condition, this was used as a criterion for branching, i.e., asking respondents in a condition A and B different block of questions.

10.2.3.7.2 Questionnaire structure for a within-subjects design

This type of experimental design involves exposing each respondent to all of the user experimental conditions you’re testing. This way, each respondent will test all of the conditions.

For instance, we would like to test again the effect of two advertisements on purchase intentions, but this time in a within-subject design. First, each respondent will be exposed to the first version of advertisement and right after that asked to rate his/her willingness to buy the advertised product. Subsequently, each participant will be shown another version of advertisement and again rate his/her willingness to purchase the advertised product. Finally, we can compare group means with paired sample t-test (given that data is measured on interval or ratio scale).

10.2.3.8 Question wording

Generally, question wording should enable each respondent to understand questions and to be able to answer them with reliability. Reliability means that, if a respondent was asked the same question again, he/she would give the same answer again. A number of common problems regarding the question wording have been identified, so we will address the most important ones.

In order to ensure reliability, the issue in terms of who, what, when and where should be defined in each question.

Incorrect

Example: Which brand of shampoo do you use?
Who (the respondent): It is not clear whether this question relates to the individual respondent or the respondent’s total household.
What (the brand of shampoo): It is unclear how the respondent is to answer this question if more than one brand is used.
When (unclear): The time frame is not specified in this question. The respondent could interpret it as meaning the shampoo used this morning, this week, or over the past year.
Where (not specified): At home, at the gym? Where?

Correct

A more clearly defined question is:
Which brand or brands of shampoo have you personally used at home during the last month? In the case of more than one brand, please list all the brands that apply.

Use ordinary words. Words should match the vocabulary level of the participants.

Incorrect

“Do you think the distribution of soft drinks is adequate?”

Correct

“Do you think soft drinks are easily available when you want to buy them?”

Avoid double negative form. Double negative question forms can confuse respondents, especially when they need to answer with “Agree” or “Disagree.”

Incorrect

Do you think that it is not uncommon that boys play basketball?

Correct

In your opinion, is it common that boys play basketball?

Avoid leading questions.Leading questions clue the participant to what the answer should be. Such questions introduce a bias in a particular direction.

Incorrect

“Is Colgate your favorite toothpaste?”

Correct

“What is your favorite brand of toothpaste?”

Avoid ambiguous words. Words such as usually, normally, frequently, often, regularly, and other similar words, do not define frequency clearly enough.

Incorrect

“In a typically month, how often do you go to a movie theater to see a movie?”
a) Never
b) Occasionally
c) Sometimes
d) Often
e) Regularly

Correct

“In a typically month, how often do you go to a movie theater to see a movie?”
a) Less than once
b) 1 or 2 times
c) 3 or 4 times
d) More than 4 times

10.2.3.9 Choose adequate order

One of the last steps in a process of designing a questionnaire is choosing adequate order of questions and instructions for respondents.

At the beginning, you should provide a short and easy-to-understand introduction to the topic. Use simple language and avoid technical terms (e.g., not many people will know the terms “manufacturer brand” and “store brand”). Additionally, in the introduction you should state how long the survey will approximately take.

The opening questions should be interesting, simple and non-threatening. They are crucial because it is the respondent’s first exposure to the questionnaire and is likely to set the tone for the rest of questions in the questionnaire. If too difficult to understand, or sensitive in some way, respondents are likely to stop answering your questions. Qualifying questions (or screening questions) should serve as the opening questions (if applicable). Their purpose is to identify a potential respondent that is eligible to proceed with the research survey.

After the opening part, you should establish an optimal question flow. General questions should precede the specific questions. Questions on one subject, or one particular aspect of a subject, should be grouped together. It may feel confusing to be asked to return to some subject they thought they already gave their opinions about.

As respondents are moving towards the end of the questionnaire, they are likely to become increasingly indifferent and might give careless answers. Therefore, questions of special importance should ideally be included in the earlier part of the questionnaire.

Finally, you should pay particular attention to provide all prescribed definitions and explanations before you ask a question. This ensures that the questions are understood in consistent way by every respondent.

10.2.3.10 Test your questionnaire

Finally, before you distribute the final questionnaire, there are some things to consider. First, you should always pretest your questionnaire before sharing it! Test all aspects of the questionnaire (content, wording, sequence, form & layout, etc.). If possible, use respondents in the pretest that are similar to those who will be included in the actual survey. Ideally, the pretest sample size should be small (in a real scenario this could vary from 15 to 30 respondents; for the group project, a lower number will be sufficient). After each significant revision of the questionnaire, conduct another pretest, using a different sample of respondents. Eventually, code and analyze the responses obtained from the pretest so that you make sure that you collected information you intended to collect.

After testing your questionnaire you should be able to determine whether:

  • The questions are properly framed
  • The questions wording triggers any biases
  • The questions are placed in the optimal order
  • The questions are understandable
  • Specifying questions are needed or some need to be eliminated

Some useful tips:

  • Add a progress bar so that respondents know how many pages are left (see “Look & Feel” menu in Qualtrics).

  • Remember to activate the “Force Response” field under “Validation Options” if you don’t want to allow respondents to skip questions.

  • Check the usability on mobile devices using the preview option (make sure the “Mobile friendly” option is checked).

10.3 Part 2: Collecting data and analysis

The following type of visualization includes statistical test as well:

10.3.1 Collecting data

Your task in this part is to collect real data from real people. More specifically, each group member is supposed to administer the questionnaire to 20 persons, i.e. a group of 6 = 120 people per group project.

10.3.2 Data analysis

In this chapter we will encounter the nature of data you collect when conducting a survey. It will help you in handling your survey data in R, and show you which statistical tests you might apply. Note that in focus of this chapter are not statistical test as they are extensively discussed in the previous chapters.

The purpose of this chapter is primary to help you handle and determine data types from your Qualtrics survey. For more information in regards to what statistical tests to use, assumptions or other details, please consult relevant chapters.

Load in a Qualtrics survey data via package “qualtRics”

After downloading your survey in CSV format, you need to install qualtRics and load it in.

# Load in qualtRics package
# install.packages('qualtRics')
library(qualtRics)

read_survey() is a function that loads in survey results in CSV to R.

# Read the qualtrics survey data
qualtrics <- read_survey("data_analysis_survey.csv")
head(qualtrics, 3)

Current column names are not much helpful in identifying questions from the questionnaire. In order to name columns after corresponding question, the function label_to_colnames() from package sjlabelled can help.

# Using labels as column name
new.colnames <- colnames(label_to_colnames(qualtrics))

As it can happen that two or more column names are identical, we can use make.unique() function to assign different names to columns that are supposed to have same names. For instance, in our case it is column name ‘Selected choice’ that appears twice for two different questions. After we run the function, the resulting names will be ‘Selected choice’ and ‘Selected choice_1.’

new.colnames <- make.unique(new.colnames, sep = "_")

Finally, we can assign unique corresponding names to the columns in our survey data.

colnames(qualtrics) <- new.colnames
head(qualtrics, 3)

In this link you can find a brief, but insightful Introduction to qualtRics package and how to combine Qualtrics and R

Multiple choice with a single answer

Type of data you obtain is categorical, and the output comes in the following form:

During a typical day, in what period of the day you prefer watching movies or TV series on Netflix?
3
4
5
4
5
2

What to do with this data now? First, we need to load it in R and prepare for analysis. The numbers you see in the output R recognizes as numeric. In order to conduct statistical modeling and properly visualize our results, we need to convert our data to a factor class.

A factor (or coding variable) represents different groups of data by using numbers (integers). In fact, factors appear as numeric variables, but they hold meaning of labels/names of data groups, i.e. nominal variable. These data groups are represented in a form of ‘levels.’
In our case, our multiple choice question output will contain 5 data groups after converting it to factor:

# Convert numeric value to factors
qualtrics$`During a typical day, in what period of the day you prefer watching movies or TV series on Netflix?` <- factor(qualtrics$`During a typical day, in what period of the day you prefer watching movies or TV series on Netflix?`,
    levels = c(1:5), labels = c("Never", "Early morning(00:00-06:00)",
        "Morning(06:00-12:00)", "Afternoon(12:00-18:00",
        "Evening (18:00-22:00)"))
# Table
table(qualtrics$`During a typical day, in what period of the day you prefer watching movies or TV series on Netflix?`)
## 
##                      Never Early morning(00:00-06:00) 
##                         19                         18 
##       Morning(06:00-12:00)      Afternoon(12:00-18:00 
##                         22                         35 
##      Evening (18:00-22:00) 
##                         23
10.3.2.0.1 Fischer’s exact
Fisher’s exact test is used to test a hypothesis with data obtained from multiple choice questions with single answer. Results from multiple choice questions with multiple answers are treated with different test.
  • Application: when you have 1 dependent variable and 1 independent variable with 2 or more levels/factors
  • Used when frequency in at least one cell is less than 5 . When frequencies in each cell are greater than 5, Chi-square test should be used.
  • Hypothesis: Is there a significant difference in frequencies between values observed in cells and values expected in cells ?
  • H0: There is no relationship between the two categorical variables.Therefore, two categorical variables are independent. Knowing the value of one variable does not help to predict the value of the other variable.
  • H1: There is a relationship between the two categorical variables.Therefore, two categorical variables are dependent.Knowing the value of one variable helps to predict the value of the other variable.
  • Usually, this type of test is used on 2x2 contingency tables. However, it can be applicable on contingency tables of larger dimensions.

Example: We would like to know whether the preferred period of the day for watching Netflix depends on the respondents’ country of origin.

# Converting characters to factors
qualtrics$`What is your gender? - Selected Choice` <- factor(qualtrics$`What is your gender? - Selected Choice`,
    levels = c(1:2), labels = c("Male", "Female"))
qualtrics$`What is your country of origin? - Selected Choice` <- factor(qualtrics$`What is your country of origin? - Selected Choice`,
    levels = c(1:2), labels = c("Austria", "Germany"))
# Creation of contingency table
fisher_test_table <- table(qualtrics$`What is your country of origin? - Selected Choice`,
    qualtrics$`During a typical day, in what period of the day you prefer watching movies or TV series on Netflix?`)
# Since we have a count less than 5, we should
# apply Fisher's test instead of Chi-square.
# Fisher's test
test <- fisher.test(fisher_test_table)
test
## 
##  Fisher's Exact Test for Count Data
## 
## data:  fisher_test_table
## p-value = 0.575
## alternative hypothesis: two.sided

From the output and from test$p.value we see that the p-value is higher than the significance level of 5%. Like any other statistical test, if the p-value is higher than the significance level, we can not reject the null hypothesis.

In our case, not rejecting the null hypothesis for the Fisher’s exact test of independence means that there is no significant relationship between the two categorical variables. Therefore, knowing the value of one variable does not help to predict the value of the other variable.

Chi-square test: Goodness of fit & Independence test
  1. Goodness of fit
    • Application: when you only have 1 dependent variable and none independent variables
    • Hypothesis: Is there a significant difference in frequencies between values observed in cells and values expected in cells ?
    • H0: There is no significant difference between the observed and the expected frequencies.
    • H1: There is a significant difference between the observed and the expected frequencies.
    • If we don’t specify expected frequency per cell (see in the code below), then it is expected that all cells show an eqaul frequency.
    • Example :‘Do the numbers of respondents who prefer watching Netflix in different periods of a day significantly differ from each other?
  • Note that we did not assume any specific distribution, so we are assuming that each count will have the same or similar number.
# Creating table
mlc_chi_square <- table(qualtrics$`During a typical day, in what period of the day you prefer watching movies or TV series on Netflix?`)

# Chi-square test (without given expected values
# = equal values )
chisq.test(mlc_chi_square)
## 
##  Chi-squared test for given probabilities
## 
## data:  mlc_chi_square
## X-squared = 7.9145, df = 4, p-value = 0.09476

The p-value of the test is higher than 0.05. We can conclude that the numbers of respondents who watch Netflix in different periods of a day are commonly distributed. Observed distribution does not differ significantly from the expected. This result does not surprise if you take a look at the values for each level in the table we created before conducting the test. There you can see that count of answers in each level is more or less not deviating too much. It is visible if you take a look at the previous visualizations as well.

If we are interested in testing more specific distribution, i.e. expect that 40% of our respondents are watching Netflix during evening hours, we can introduce corresponding distribution in the test.

# Expected values in percentages for each alternative. The sum must be 1.
expected_values <- c(0.10, # We expect that 10% of our respondents do not watch Netflix at all.
                     0.20, # We expect that 20% of our respondents watch Netflix in early morning.
                     0.10, # We expect that 10% of our respondents watch Netflix in morning.
                     0.20, # We expect that 20% of our respondents watch Netflix in afternoon.
                     0.40  # We expect that 40% of our respondents watch Netflix in evening.
                    )
# Chi-square test with expected values
chisq.test(mlc_chi_square, p=expected_values)
## 
##  Chi-squared test for given probabilities
## 
## data:  mlc_chi_square
## X-squared = 32.722, df = 4, p-value = 0.000001362

This time the p-value of the test is lower than 0.05. We have an evidence that observed distribution does significantly differ from the expected distribution (10%/20%/10%/20%/40%).

  1. Chi-Square Test of Independence Application:when you have 1 dependent variable and 1 independent variable with 2 or more levels/factors Hypothesis: Is there an association between categorical variable X and categorical variable Y? H0: There is no association between the two variables. H1: There is an association between the two variables. Example: Is there an association between gender and the preferred period of a day for watching Netflix?
# Creation of contingency table
chi_square_table <- table(qualtrics$`What is your gender? - Selected Choice`,
    qualtrics$"During a typical day, in what period of the day you prefer watching movies or TV series on Netflix?")
# Chi-square independence test
chisq.test(chi_square_table)
## 
##  Pearson's Chi-squared test
## 
## data:  chi_square_table
## X-squared = 1.5739, df = 4, p-value = 0.8135

Since the p-value (0.8135) is higher than the significance level (0.05), we cannot reject the null hypothesis. Thus, we conclude that there is no association relationship between gender and the preferred period of a day for watching Netflix. Therefore, we can say that the hours spent is independent from the gender of participant.

Multiple choice with multiple answers

In Qualtrics, multiple answers on multiple choice questions are captured in separate columns. For instance, the second respondents chose “Ja!Natürlich” and “Clever” as answers, thus, the rest of alternatives have none value in this row.

Which of the following store brands do you know? (multiple answers possible) - ja! Natürlich. Which of the following store brands do you know? (multiple answers possible) - Clever Which of the following store brands do you know? (multiple answers possible) - Spar Vital Which of the following store brands do you know? (multiple answers possible) - …
NA 1 NA 1
1 1 NA NA
1 NA NA 1
1 NA 1 NA
1 NA 1 1
1 NA 1 NA

Since this type of question provides multiple possible answers, one way to analyze data obtained from this question is in the following form:

# Replacing NA with 0
qualtrics$`Which of the following store brands do you know? (multiple answers possible) - ja! Natürlich.`[is.na(qualtrics$`Which of the following store brands do you know? (multiple answers possible) - ja! Natürlich.`)] = 0
qualtrics$`Which of the following store brands do you know? (multiple answers possible) - Clever`[is.na(qualtrics$`Which of the following store brands do you know? (multiple answers possible) - Clever`)] = 0
qualtrics$`Which of the following store brands do you know? (multiple answers possible) - Spar Vital`[is.na(qualtrics$`Which of the following store brands do you know? (multiple answers possible) - Spar Vital`)] = 0
qualtrics$`Which of the following store brands do you know? (multiple answers possible) - ...`[is.na(qualtrics$`Which of the following store brands do you know? (multiple answers possible) - ...`)] = 0
# qualtrics[38] accesses ja!Natürlich column
# qualtrics[39] accesses Clever column
# qualtrics[40] accesses Spar Vital column
# qualtrics[41] accesses ... column Calculating
# frequency, percentage of respondents and
# percentage of cases
df.cochran <- data.frame(Frequnecy = colSums(qualtrics[38:41]),
    Share_of_respondents = (colSums(qualtrics[38:41])/sum(qualtrics[38:41])) *
        100, Share_of_cases = ((colSums(qualtrics[38:41]))/nrow(qualtrics[38:41])) *
        100)
df.cochran %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
Frequnecy Share_of_respondents Share_of_cases
Which of the following store brands do you know? (multiple answers possible) - ja! Natürlich. 80 31.25000 68.37607
Which of the following store brands do you know? (multiple answers possible) - Clever 62 24.21875 52.99145
Which of the following store brands do you know? (multiple answers possible) - Spar Vital 71 27.73438 60.68376
Which of the following store brands do you know? (multiple answers possible) - … 43 16.79688 36.75214

The share of cases column suggests that, for instance, almost 70% percent of people are familiar with the brand “ja!Naturlich.”

For the analysis of results collected with multiple choice question with multiple possible answers, we can use Cochran’s Q test.Although we did not mention it before, it is not too different from what you have already learned about other tests.

The Cochran’s Q test and associated multiple comparisons require the following assumptions:

  1. Responses are dichotomous and from k number of matched samples.

  2. The subjects are independent of one another and were selected at random from a larger population.

  3. The sample size is sufficiently “large.” (As a rule of thumb, the number of subjects for which the responses are not all 0’s or 1’s, n, should be ≥ 4 and nk should be ≥ 24)

In a within-subjects experiment design with three or more observations of a dichotomous(= just two levels such as “Yes” or “No”) categorical outcome, you utilize Cochran’s Q test to assess main effects. Similarly, in a multiple choice question with multiple answers we have the same respondent going through three or more potential answers with dichotomous(=yes or no) categorical outcome, meaning that responses are not independent from each other.

library(DescTools)
list.cochran <- list(qualtrics$`Which of the following store brands do you know? (multiple answers possible) - ja! Natürlich.`,
    qualtrics$`Which of the following store brands do you know? (multiple answers possible) - Clever`,
    qualtrics$`Which of the following store brands do you know? (multiple answers possible) - Spar Vital`,
    qualtrics$`Which of the following store brands do you know? (multiple answers possible) - ...`)  # imaginary brand
# Replacing NAs in the list with 0 in order to be
# able to run the test
list.cochran <- rapply(list.cochran, f = function(x) ifelse(is.na(x),
    0, x), how = "replace")
# Cochran test
matrix.cochran <- do.call(cbind, list.cochran)
DescTools::CochranQTest(matrix.cochran, alpha = 0.05)
## 
##  Cochran's Q test
## 
## data:  y
## Q = 25.568, df = 3, p-value = 0.00001174

The p-value less than 0.05 indicates that there is enough evidence to conclude that some of the store brands are better known among our respondents than other. In order to take a closer look at it, we need to conduct a post hoc test.

# Post hoc test (Dunn Test)
DunnTest(list.cochran, method = "bonferroni")
## 
##  Dunn's test of multiple comparisons using rank sums : bonferroni  
## 
##     mean.rank.diff      pval    
## 2-1            -36    0.1093    
## 3-1            -18    1.0000    
## 4-1            -74 0.0000073 ***
## 3-2             18    1.0000    
## 4-2            -38    0.0761 .  
## 4-3            -56    0.0014 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

From the results of the Dunn Test, we can see that there is a big difference between 1 (“ja!Natürlich”) and 4(“…”), as well as between 4(“…”) and 3(“Spar Vital”).

10.3.2.1 Rank order question

Intuitive question to ask when it comes to this type of question is the following: which feature is the most important for respondents?

We can answer this question by calculating a mean rank for each feature. Before we do so, we will create a separate data frame and add columns of the response data.

rank.data <- subset(qualtrics, select = stringr::str_detect(names(qualtrics),
    "Measuring steps|Calories burned|Measuring heartbeat|Exercise tracking|Measuring distance"))
head(rank.data) %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Calories burned What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring heartbeat What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Exercise tracking What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring distance
2 4 1 5 3
1 3 5 2 4
1 2 4 5 3
2 1 3 4 5
5 4 3 1 2
4 2 1 3 5

First information we would like to know is how many preference combinations there are, and how repetitive they are. We can obtain that information by creating a summary of the ranking data frame we created.

library(pmr)
test <- rankagg(rank.data)
test
##                  n
##  [1,] 2 1 3 4 5 10
##  [2,] 1 3 2 4 5 19
##  [3,] 2 3 1 4 5 17
##  [4,] 1 2 4 3 5  4
##  [5,] 4 2 1 3 5  3
##  [6,] 3 2 1 5 4 15
##  [7,] 1 3 5 2 4 10
##  [8,] 1 2 4 5 3 10
##  [9,] 2 4 1 5 3  9
## [10,] 1 2 5 4 3  9
## [11,] 5 4 3 1 2  3
## [12,] 2 3 4 5 1  8

The matrix we received as an output is the summary of our ranking data. It shows that, for instance, the preference combination “2,1,3,4,5” repeats 10 times in the data frame. More specifically, it means that there are 10 respondents who prefer the item 2(“Calories burned”) the most, then the item 1(“Measuring steps”), and so on.

Now we can calculate the mean rank for each feature and conclude which feature is the most important to our respondents:

# Mean rank of each fitness tracker feature
destat(test)$mean.rank
## [1] 1.811966 2.581197 2.598291 4.051282 3.957265

As we can observe from the output, the item 1(“Measuring steps”) shows the best mean rank among all items. Therefore, we can assume that the “Measuring steps” is most important for our respondents. However, in order to statistically prove it and become sure that this is not just by mere chance, we can conduct Friedman rank sum test.

Friedman rank sum test is used to identify whether there are any statistically significant differences between the distributions of 3 or more paired groups. It is used when the normality assumptions for using one-way repeated measures ANOVA are not met. Another case when Friedman rank rum test is used is when the dependent variable is measured on an ordinal scale, as in our case.

# Friedman test
friedman.test(as.matrix(rank.data))
## 
##  Friedman rank sum test
## 
## data:  as.matrix(rank.data)
## Friedman chi-squared = 176.42, df = 4, p-value < 0.00000000000000022

Friedman rank sum test has a p-value lower than 0.05, so we can conclude that here are significant differences between at least two features (what we have already seen in our visualization). Even though we have identified differences between preferences towards features in our advanced visualization, we will conduct a post hoc test in order to demonstrate traditional way of calculating pairwise comparisons.

library(rstatix)
rank.data.long <- reshape2::melt(rank.data, value.name = "Rank",
    variable.name = "Feature", stringsAsFactors = TRUE)
posthoc <- wilcox_test(Rank ~ Feature, paired = TRUE,
    p.adjust.method = "bonferroni", data = rank.data.long)
posthoc %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
.y. group1 group2 n1 n2 statistic p p.adj p.adj.signif
Rank What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Calories burned 117 117 1369.0 0.000000 0.000 ****
Rank What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring heartbeat 117 117 2231.0 0.000753 0.008 **
Rank What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Exercise tracking 117 117 354.0 0.000000 0.000 ****
Rank What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring distance 117 117 367.5 0.000000 0.000 ****
Rank What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Calories burned What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring heartbeat 117 117 3214.5 0.512000 1.000 ns
Rank What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Calories burned What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Exercise tracking 117 117 610.5 0.000000 0.000 ****
Rank What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Calories burned What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring distance 117 117 940.0 0.000000 0.000 ****
Rank What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring heartbeat What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Exercise tracking 117 117 1235.0 0.000000 0.000 ****
Rank What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring heartbeat What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring distance 117 117 1307.5 0.000000 0.000 ****
Rank What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Exercise tracking What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring distance 117 117 3534.5 0.816000 1.000 ns

The output table provides us with p-values referring to significance of difference in mean ranks of each pair. For instance, the first 4 rows proves that the differences between the mean rank of the feature “Measuring steps” and each of the rest of features are significant. Consequently, we can conclude that this feature is by far the most important among our respondents.

Another question that may be interesting to explore is whether there are any complementary features ? Or features which overlap each other in its functionality? In order to have a look at that, we can investigate the correlation between ranks assigned to each feature.

# Correlation Matrix
cor.matrix <- cor(rank.data, method = c("spearman"))
cor.matrix
##                                                                                                                                                                             What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps                                                                                                                                                                  1.00000000
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Calories burned                                                                                                                                                                 -0.04651331
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring heartbeat                                                                                                                                                             -0.65690943
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Exercise tracking                                                                                                                                                                0.29633223
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring distance                                                                                                                                                              -0.05958032
##                                                                                                                                                                             What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Calories burned
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps                                                                                                                                                                 -0.04651331
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Calories burned                                                                                                                                                                  1.00000000
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring heartbeat                                                                                                                                                             -0.22216264
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Exercise tracking                                                                                                                                                               -0.10838758
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring distance                                                                                                                                                              -0.11694481
##                                                                                                                                                                             What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring heartbeat
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps                                                                                                                                                                      -0.6569094
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Calories burned                                                                                                                                                                      -0.2221626
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring heartbeat                                                                                                                                                                   1.0000000
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Exercise tracking                                                                                                                                                                    -0.3255840
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring distance                                                                                                                                                                   -0.3817895
##                                                                                                                                                                             What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Exercise tracking
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps                                                                                                                                                                     0.2963322
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Calories burned                                                                                                                                                                    -0.1083876
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring heartbeat                                                                                                                                                                -0.3255840
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Exercise tracking                                                                                                                                                                   1.0000000
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring distance                                                                                                                                                                 -0.4717682
##                                                                                                                                                                             What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring distance
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps                                                                                                                                                                    -0.05958032
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Calories burned                                                                                                                                                                    -0.11694481
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring heartbeat                                                                                                                                                                -0.38178948
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Exercise tracking                                                                                                                                                                  -0.47176821
## What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring distance                                                                                                                                                                  1.00000000

At the first glance we can observe a lot of negative values, meaning that many features correlate negatively relative to each other. In order to make the interpretation easier, we will try to visualise correlations in a form of a correlation matrix.

library(ggcorrplot)
ggcorrplot(cor.matrix)

From the correlation matrix we can confirm that almost all features negatively correlate to each other. An exception is the relationship between feature “Measuring steps” and “Exercise tracking,” which correlates positively. This matrix can be useful for digging deeper in relationship between preferences for features. For instance, we can assume that feature “Measuring steps” and “Exercise tracking” correlate positively because users see them as complementary features. Moreover, if we say that walking is a type of exercise (in case of longer walking routes), we can assume that users, who ranked “Exercise tracking” high, ranked “Measuring steps” high as well, because they perceive it as another type of “Exercise tracking.”

10.3.2.2 Constant Sum question

If you wish to obtain information about how much one attribute is preferred over another one, you may use a constant sum scale. The total box should always be displayed at the bottom to make it easier for respondents. A constant sum question permits collection of ratio data type. With data obtained we would be able to express the relative importance of the options.

What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service id
32 23 32 13 1
25 30 22 23 2
19 21 30 30 3
20 20 20 40 4
30 30 10 30 5
0 20 20 60 6

By computing descriptive statistics per column we get very useful insight in our data:

# Compute descriptive statistics
library(pastecs)
res <- stat.desc(constant.sum)
round(res[, 1:4], 2) %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service
nbr.val 117.00 117.00 117.00 117.00
nbr.null 41.00 2.00 6.00 9.00
nbr.na 0.00 0.00 0.00 0.00
min 0.00 0.00 0.00 0.00
max 40.00 100.00 60.00 100.00
range 40.00 100.00 60.00 100.00
sum 1421.00 3684.00 3014.00 3581.00
median 10.00 30.00 20.00 30.00
mean 12.15 31.49 25.76 30.61
SE.mean 1.00 1.50 1.29 1.48
CI.mean.0.95 1.99 2.97 2.56 2.93
var 117.90 263.11 195.39 255.34
std.dev 10.86 16.22 13.98 15.98
coef.var 0.89 0.52 0.54 0.52

With the data collected we are able to answer the question: what factor is the most important for our respondents when they go out for a dinner?

In order to answer this question we need to conduct a repeated measures ANOVA. This type of ANOVA is used for analyzing data where the same subjects are measured more than once. In our case we have every respondent measured on each of the factors (locations, price, ambiance and customer service). Repeated measures ANOVA is an extension of the paired-samples t-test. This test is also referred to as a within-subjects ANOVA. In the within-subject experimental design the same individuals are measured on the same outcome variable under different time points or conditions.

We need to check all assumptions that need to be fulfilled in order to deploy this type of ANOVA. There are three assumptions that need to check. The first to check that each level of the independent variable is approximately normally distributed. Since we have more than 30 observations at each level, we do not need to proceed further due to the central limit theorem. Second assumption refers to extreme outliers. Let’s have a look at potential outliers:

# Creation of the long version of data frame
library(reshape2)
constant.sum.long <- melt(constant.sum[, -5], variable.name = "Factor",
    value.name = "Points")
# Outliers
constant.sum.long %>%
    group_by(Factor) %>%
    identify_outliers(Points) %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
Factor Points is.outlier is.extreme
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price 80 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price 100 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price 100 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 0 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 50 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 60 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 50 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 60 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 50 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 0 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 0 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 50 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 60 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 50 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 0 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 50 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 0 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 50 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 50 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 50 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 0 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 50 TRUE FALSE
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service 100 TRUE FALSE

The p value seems to be significant, i.e., less than 0.05. As we cannot identify any extreme outliers, we can proceed with deploying repeated measures ANOVA.

# Formatting data
constant.sum.aov <- gather(constant.sum, key = "Factor",
    value = "Points", names(constant.sum)[stringr::str_detect(names(constant.sum),
        "Location|Price|Ambience|Customer Service")])
# One-way repeated measures ANOVA
res.aov <- anova_test(data = constant.sum.aov, dv = Points,
    wid = id, within = Factor)
get_anova_table(res.aov) %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
Effect DFn DFd F p p<.05 ges
Factor 2.56 297.36 33.668 0
0.225
As we know that ANOVA is an omnibus test, we need to conduct post hoc test for further details:
# Post hoc test
pairwise.t.test(constant.sum.long$Points, constant.sum.long$Factor,
    paired = T, p.adjust.method = "holm")
## 
##  Pairwise comparisons using paired t tests 
## 
## data:  constant.sum.long$Points and constant.sum.long$Factor 
## 
##                                                                                                                                                                                                                               What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price            0.0000000000000027                                                                                                                                                                                                   
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience         0.0000000003153773                                                                                                                                                                                                   
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service < 0.0000000000000002                                                                                                                                                                                                 
##                                                                                                                                                                                                                               What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price            -                                                                                                                                                                                                                 
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience         0.030                                                                                                                                                                                                             
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service 0.742                                                                                                                                                                                                             
##                                                                                                                                                                                                                               What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price            -                                                                                                                                                                                                                    
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience         -                                                                                                                                                                                                                    
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service 0.079                                                                                                                                                                                                                
## 
## P value adjustment method: holm

Now we can clearly see that difference between perceived importance of price and location, or price and ambiance, are significant. On the other hand, the difference in perceived importance between customer service and price is not significant.

10.3.2.3 Number entry question

A number entry question is a recommended type of question if you are interested in obtaining ratio data type. We will use this type of question together with a constant sum question type to collect data that can be analyzed with regression analysis.Note that in this case we treat constant sum data as ratio data and therefore assume that 0 means complete absence.

Here is a glimpse in answers on how important is each factor to our respondents when it comes to dinning outside:

What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service Customer Service
32 23 32 13 1
25 30 22 23 43
19 21 30 30 34
20 20 20 40 46
30 30 10 30 17
0 20 20 60 4

Additionally, we asked our respondents how much are they willing to spend on dinner on average. In order to handle data easier, we will create a new data frame where we merge all the data together:

dinner <- subset(qualtrics, select = stringr::str_detect(names(qualtrics),
    paste0(c(" Location", " Price", " Ambience", " Customer Service",
        " Willingness-to-pay"), collapse = "|")))
head(dinner) %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = T)
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service Open-ended questions How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR) You may also, for example, ask about the willingness-to-pay under two different conditions using… - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A You may also, for example, ask about the willingness-to-pay under two different conditions using… - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B Willingness-to-pay (in EUR) Customer Service
32 23 32 13 153 12 54 29 1
25 30 22 23 7 4 3 77 43
19 21 30 30 7 21 32 52 34
20 20 20 40 52 NA NA 31 46
30 30 10 30 117 NA NA 22 17
0 20 20 60 44 NA NA 35 4

Before we conduct a linear regression analysis, we need to take a look at correlation matrix:

correlation <- cor(dinner, method = c("pearson"))
correlation
##                                                                                                                                                                                                                               What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location                                                                                                                                                                                                                    1.00000000
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price                                                                                                                                                                                                                      -0.31732620
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience                                                                                                                                                                                                                   -0.36134355
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                                                                                                                                                                                                           -0.04130346
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                           -0.08112487
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                                                                                                                                                                                                           NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                                                                                                                                                                                                           NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                                                                                                             0.14145397
##  Customer Service                                                                                                                                                                                                                                                                                                                                                                                                                       -0.16688104
##                                                                                                                                                                                                                               What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location                                                                                                                                                                                                                -0.31732620
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price                                                                                                                                                                                                                    1.00000000
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience                                                                                                                                                                                                                -0.21962027
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                                                                                                                                                                                                        -0.60735926
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                         0.02184242
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                                                                                                                                                                                                        NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                                                                                                                                                                                                        NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                                                                                                         -0.07438388
##  Customer Service                                                                                                                                                                                                                                                                                                                                                                                                                     0.08894752
##                                                                                                                                                                                                                               What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location                                                                                                                                                                                                                   -0.36134355
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price                                                                                                                                                                                                                      -0.21962027
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience                                                                                                                                                                                                                    1.00000000
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                                                                                                                                                                                                           -0.40628646
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                            0.11348694
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                                                                                                                                                                                                           NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                                                                                                                                                                                                           NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                                                                                                            -0.32550607
##  Customer Service                                                                                                                                                                                                                                                                                                                                                                                                                       -0.02405881
##                                                                                                                                                                                                                               What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location                                                                                                                                                                                                                           -0.04130346
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price                                                                                                                                                                                                                              -0.60735926
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience                                                                                                                                                                                                                           -0.40628646
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                                                                                                                                                                                                                    1.00000000
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                   -0.06632089
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                                                                                                                                                                                                                   NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                                                                                                                                                                                                                   NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                                                                                                                     0.26412732
##  Customer Service                                                                                                                                                                                                                                                                                                                                                                                                                                0.04415238
##                                                                                                                                                                                                                               Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location                                                                                                                           -0.08112487
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price                                                                                                                               0.02184242
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience                                                                                                                            0.11348694
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                                                                                                                   -0.06632089
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                                                                                                                    1.00000000
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                                                                                                                   NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                                                                                                                   NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                    -0.01518050
##  Customer Service                                                                                                                                                                                                                                                                                                                                0.18247589
##                                                                                                                                                                                                                               You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location                                                                                                                                                                                                                             NA
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price                                                                                                                                                                                                                                NA
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience                                                                                                                                                                                                                             NA
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                                                                                                                                                                                                                     NA
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                     NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                                                                                                                                                                                                             1
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                                                                                                                                                                                                            NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                                                                                                                      NA
##  Customer Service                                                                                                                                                                                                                                                                                                                                                                                                                                 NA
##                                                                                                                                                                                                                               You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location                                                                                                                                                                                                                             NA
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price                                                                                                                                                                                                                                NA
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience                                                                                                                                                                                                                             NA
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                                                                                                                                                                                                                     NA
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                     NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                                                                                                                                                                                                            NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                                                                                                                                                                                                             1
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                                                                                                                      NA
##  Customer Service                                                                                                                                                                                                                                                                                                                                                                                                                                 NA
##                                                                                                                                                                                                                                Willingness-to-pay (in EUR)
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location                           0.14145397
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price                             -0.07438388
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience                          -0.32550607
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                   0.26412732
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                  -0.01518050
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                  NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                  NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                    1.00000000
##  Customer Service                                                                                                                                                                                                                               0.12125571
##                                                                                                                                                                                                                                Customer Service
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location               -0.16688104
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price                   0.08894752
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience               -0.02405881
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service        0.04415238
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                        0.18247589
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                       NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                       NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                         0.12125571
##  Customer Service                                                                                                                                                                                                                    1.00000000

From our data we see, for instance, that some negative correlation between willingness to pay and importance of ambiance as well as some positive correlation between importance of customer service and willingness-to-pay. Let us observe descriptive statistics as well:

psych::describe(dinner) %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
vars n mean sd median trimmed mad min max range skew kurtosis se
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location 1 117 12.14530 10.85823 10 11.25263 14.8260 0 40 40 0.3585257 -0.8903393 1.003844
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Price 2 117 31.48718 16.22079 30 29.83158 14.8260 0 100 100 1.5662904 4.1917874 1.499613
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Ambience 3 117 25.76068 13.97822 20 25.09474 14.8260 0 60 60 0.3807401 -0.3100357 1.292286
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service 4 117 30.60684 15.97949 30 30.74737 14.8260 0 100 100 0.4103958 1.9020992 1.477304
Open-ended questions How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR) 5 117 101.66667 54.16195 103 103.03158 60.7866 1 200 199 -0.1818371 -0.9633914 5.007274
You may also, for example, ask about the willingness-to-pay under two different conditions using… - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A 6 3 12.33333 8.50490 12 12.33333 11.8608 4 21 17 0.0391329 -2.3333333 4.910307
You may also, for example, ask about the willingness-to-pay under two different conditions using… - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B 7 3 29.66667 25.57994 32 29.66667 32.6172 3 54 51 -0.0904583 -2.3333333 14.768585
Willingness-to-pay (in EUR) 8 117 32.99145 26.26801 30 30.28421 29.6520 0 110 110 0.8007002 0.0124325 2.428479
Customer Service 9 117 49.35897 29.47777 47 49.29474 40.0302 0 98 98 0.0342022 -1.1897398 2.725221

We see that difference between mean and median does not suggest (at the first sight) great effect of outliers.

Let us now do linear regression analysis:

dinner <- as_tibble(dinner)
dinner <- dplyr::rename(dinner, Location = ends_with("Location",
    ignore.case = FALSE), Price = ends_with("Price",
    ignore.case = FALSE), Ambience = ends_with("Ambience",
    ignore.case = FALSE))

mlr.dinner <- lm(` Willingness-to-pay (in EUR)` ~ Location +
    Price + Ambience + ` Customer Service`, data = dinner)
summary(mlr.dinner)
## 
## Call:
## lm(formula = ` Willingness-to-pay (in EUR)` ~ Location + Price + 
##     Ambience + ` Customer Service`, data = dinner)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -40.810 -18.205  -3.314  14.059  74.274 
## 
## Coefficients:
##                     Estimate Std. Error t value   Pr(>|t|)    
## (Intercept)         55.31553   11.57393   4.779 0.00000538 ***
## Location            -0.06739    0.25556  -0.264   0.792503    
## Price               -0.28455    0.16117  -1.765   0.080205 .  
## Ambience            -0.69755    0.19088  -3.654   0.000394 ***
## ` Customer Service`  0.10988    0.07931   1.386   0.168646    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 24.72 on 112 degrees of freedom
## Multiple R-squared:  0.1449, Adjusted R-squared:  0.1144 
## F-statistic: 4.745 on 4 and 112 DF,  p-value: 0.001421

Out of all factors of importance when dinning out, the only one that suggests significance at 0.05 level of significance is ambience. From the summary we can conclude that increase in importance of ambience by 1 point, leads to decrease in willingness to pay by -0.697554.

confint(mlr.dinner) %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
2.5 % 97.5 %
(Intercept) 32.3832720 78.2477971
Location -0.5737479 0.4389706
Price -0.6038940 0.0347931
Ambience -1.0757599 -0.3193481
Customer Service -0.0472542 0.2670130

From confidence intervals, We can conclude that when we do not consider any of given factors (location, price, ambience and customer service), willingness to pay will be somewhere between 32.383272EUR and 78.2477971EUR. Besides that, for each increase in importance of dinner ambiance by one point, there will be an average decrease of willingness to pay between -1.0757599 and -0.3193481.

library(ggstatsplot)
ggcoefstats(x = mlr.dinner, title = "Willingness to pay predicted by importance of factors")

There are couple of things we need to consider when we do multiple linear regression. One of them are potential outliers in our data. Here we identify and visualize them:

# Outliers
outlier_values <- boxplot.stats(mlr.dinner$residuals)$out  # outlier values.
outlier_values
##       12       44       49 
## 70.56037 64.19796 74.27359

We identified observations that belong to outlier values. We can even visualize them too:

boxplot(mlr.dinner$residuals, main = "Willingnes to pay",
    boxwex = 0.1)

In addition, we need to observe whether there are any influential observations:

plot(mlr.dinner, 4)

A rule of thumb to determine whether an observation should be classified as influential or not is to look for observation with a Cook’s distance > 1 .We see from the graph that there are no influential observations.

Another thing to consider is linearity, i.e. that the relationship between the dependent and the independent variable can be reasonably approximated in linear terms:

# Linear specification
library(car)
avPlots(mlr.dinner)

In our example it does not seem that linear relationships can be reasonably assumed for all variables.

As we already learned, another important assumption of the linear model is that the error terms have a constant variance (i.e., homoscedasticity):

# Breusch-Pagan Test
library(lmtest)
bptest(mlr.dinner)
## 
##  studentized Breusch-Pagan test
## 
## data:  mlr.dinner
## BP = 1.1478, df = 4, p-value = 0.8866

The null hypothesis for this test is that the error variances are all equal, and our result is insignificant. Therefore, this assumption is met.

Another assumption to be met is that the error term is normally distributed. One way to check for normal distribution of the data is to employ statistical with the null hypothesis that the data is normally distributed. One of these is a Shapiro–Wilk test:

shapiro.test(resid(mlr.dinner))
## 
##  Shapiro-Wilk normality test
## 
## data:  resid(mlr.dinner)
## W = 0.94757, p-value = 0.0001763

When the assumption of normally distributed errors is not met (as it is not met in our case), this might again be due to a misspecification of your model, in which case it might help to transform your data.

Finally, we need to check for multicollinearity, the case when there is a strong linear relationship between the independent variables:

correlation <- cor(dinner, method = c("pearson"))
correlation
##                                                                                                                                                                                                                                  Location
## Location                                                                                                                                                                                                                       1.00000000
## Price                                                                                                                                                                                                                         -0.31732620
## Ambience                                                                                                                                                                                                                      -0.36134355
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service -0.04130346
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                 -0.08112487
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                 NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                 NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                   0.14145397
##  Customer Service                                                                                                                                                                                                             -0.16688104
##                                                                                                                                                                                                                                     Price
## Location                                                                                                                                                                                                                      -0.31732620
## Price                                                                                                                                                                                                                          1.00000000
## Ambience                                                                                                                                                                                                                      -0.21962027
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service -0.60735926
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                  0.02184242
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                 NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                 NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                  -0.07438388
##  Customer Service                                                                                                                                                                                                              0.08894752
##                                                                                                                                                                                                                                  Ambience
## Location                                                                                                                                                                                                                      -0.36134355
## Price                                                                                                                                                                                                                         -0.21962027
## Ambience                                                                                                                                                                                                                       1.00000000
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service -0.40628646
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                  0.11348694
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                 NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                 NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                  -0.32550607
##  Customer Service                                                                                                                                                                                                             -0.02405881
##                                                                                                                                                                                                                               What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service
## Location                                                                                                                                                                                                                                                                                                                                                                                                                                        -0.04130346
## Price                                                                                                                                                                                                                                                                                                                                                                                                                                           -0.60735926
## Ambience                                                                                                                                                                                                                                                                                                                                                                                                                                        -0.40628646
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                                                                                                                                                                                                                    1.00000000
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                   -0.06632089
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                                                                                                                                                                                                                   NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                                                                                                                                                                                                                   NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                                                                                                                     0.26412732
##  Customer Service                                                                                                                                                                                                                                                                                                                                                                                                                                0.04415238
##                                                                                                                                                                                                                               Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)
## Location                                                                                                                                                                                                                                                                                                                                        -0.08112487
## Price                                                                                                                                                                                                                                                                                                                                            0.02184242
## Ambience                                                                                                                                                                                                                                                                                                                                         0.11348694
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                                                                                                                   -0.06632089
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                                                                                                                    1.00000000
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                                                                                                                   NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                                                                                                                   NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                    -0.01518050
##  Customer Service                                                                                                                                                                                                                                                                                                                                0.18247589
##                                                                                                                                                                                                                               You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A
## Location                                                                                                                                                                                                                                                                                                                                                                                                                                          NA
## Price                                                                                                                                                                                                                                                                                                                                                                                                                                             NA
## Ambience                                                                                                                                                                                                                                                                                                                                                                                                                                          NA
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                                                                                                                                                                                                                     NA
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                     NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                                                                                                                                                                                                             1
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                                                                                                                                                                                                            NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                                                                                                                      NA
##  Customer Service                                                                                                                                                                                                                                                                                                                                                                                                                                 NA
##                                                                                                                                                                                                                               You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B
## Location                                                                                                                                                                                                                                                                                                                                                                                                                                          NA
## Price                                                                                                                                                                                                                                                                                                                                                                                                                                             NA
## Ambience                                                                                                                                                                                                                                                                                                                                                                                                                                          NA
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                                                                                                                                                                                                                     NA
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                     NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                                                                                                                                                                                                            NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                                                                                                                                                                                                             1
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                                                                                                                                                                                                                      NA
##  Customer Service                                                                                                                                                                                                                                                                                                                                                                                                                                 NA
##                                                                                                                                                                                                                                Willingness-to-pay (in EUR)
## Location                                                                                                                                                                                                                                        0.14145397
## Price                                                                                                                                                                                                                                          -0.07438388
## Ambience                                                                                                                                                                                                                                       -0.32550607
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service                   0.26412732
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                                  -0.01518050
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                                  NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                                  NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                                    1.00000000
##  Customer Service                                                                                                                                                                                                                               0.12125571
##                                                                                                                                                                                                                                Customer Service
## Location                                                                                                                                                                                                                            -0.16688104
## Price                                                                                                                                                                                                                                0.08894752
## Ambience                                                                                                                                                                                                                            -0.02405881
## What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Customer Service        0.04415238
## Open-ended questions      How much are you willing to pay for the previously described product? - Willingness-to-pay (in EUR)                                                                                                        0.18247589
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - A                       NA
## You may also, for example, ask about the  willingness-to-pay under two different conditions using... - Here you may include the experimental treatment (e.g., video, text, pictures) - Willingness-to-pay (in EUR) - B                       NA
##  Willingness-to-pay (in EUR)                                                                                                                                                                                                         0.12125571
##  Customer Service                                                                                                                                                                                                                    1.00000000

By observing our correlation matrix, we can see that non of the coefficients suggest values close to 0.8 or 0.9. Consequently, we conclude that there are no concerns regarding the multicolinearity between independent variables.

10.3.3 Reporting

After you are done with statistical analysis, you are ready to create visually appealing and understandable graphs for your final report. In the following sections you can get certain ideas (and R code) for visualization of data obtained by frequently asked types of questions.

The format (e.g., data frame, matrix, list or similar) in which you have your data stored in R plays important role when you visualize that data. Therefore, reshaping data to the required form will be always a prerequisite for any visualization.

The focus of the reporting section is on data visualisation, but do not forget to make correct interpretations and add them to your final report. How to communicate results of respective statistical test is a part of chapters before, so consult corresponding chapters if you are not sure how to report results of certain statistical test.

Multiple choice question visualisation

In order to visualize a survey data obtained from multiple choice question with single answer, a data format needs to be in the appropriate format. Here we proceed with data format adaptation from the point where we stopped:

# Converting long format to the
# visualisation-friendly format
mlc_visualisation <- as.data.frame(table(qualtrics$`During a typical day, in what period of the day you prefer watching movies or TV series on Netflix?`))
# Naming columns
names(mlc_visualisation) <- c("Time", "Count")
# Observing
library(kableExtra)
mlc_visualisation %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
Time Count
Never 19
Early morning(00:00-06:00) 18
Morning(06:00-12:00) 22
Afternoon(12:00-18:00 35
Evening (18:00-22:00) 23

R package ggplot2 allows you to create visually appealing graphs. Below you can see how to create simple versions of a bar chart and a pie chart.

# Multiple choice question with single answer - a
# bar chart
library(ggplot2)
p <- ggplot(data = mlc_visualisation, aes(x = Time,
    y = Count, fill = Time)) + geom_bar(stat = "identity") +
    geom_text(aes(label = paste0("n=", round(Count))),
        position = position_stack(vjust = 0.5)) + scale_fill_brewer(palette = "Blues") +
    labs(x = NULL, y = NULL, fill = NULL, title = "The period of the day you prefer watching movies?") +
    theme_classic() + theme(axis.line = element_blank(),
    axis.text = element_blank(), axis.ticks = element_blank(),
    plot.title = element_text(hjust = 0.5, color = "#666666"))
p

# Multiple choice question with single answer - a
# pie chart
p <- ggplot(mlc_visualisation, aes(x = "", y = Count,
    fill = Time)) + geom_bar(width = 1, stat = "identity") +
    coord_polar("y", start = 0) + geom_text(aes(label = paste0("n=",
    round(Count))), position = position_stack(vjust = 0.5)) +
    scale_fill_brewer(palette = "Blues") + labs(x = NULL,
    y = NULL, fill = NULL, title = "The period of the day you prefer watching movies?") +
    theme_minimal() + theme(axis.line = element_blank(),
    axis.text = element_blank(), axis.ticks = element_blank(),
    plot.title = element_text(hjust = 0.5, color = "#666666"))
p

10.3.3.1 Multiple choice question with multiple answers

If our multiple choice question has more possible answers, we would need first to calculate share of cases when each possible answer was selected.

setDT(df.cochran, keep.rownames = TRUE)
colnames(df.cochran)[1] <- "Brand"
df.cochran %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
Brand Frequnecy Share_of_respondents Share_of_cases
Which of the following store brands do you know? (multiple answers possible) - ja! Natürlich. 80 31.25000 68.37607
Which of the following store brands do you know? (multiple answers possible) - Clever 62 24.21875 52.99145
Which of the following store brands do you know? (multiple answers possible) - Spar Vital 71 27.73438 60.68376
Which of the following store brands do you know? (multiple answers possible) - … 43 16.79688 36.75214

After we make sure we have our data in the required form, we can create a nice bar chart:

# Multiple choice question with multiple answers
# - a bar chart
library(ggplot2)
p <- ggplot(data = df.cochran, aes(x = Brand, y = Share_of_cases,
    fill = Brand)) + geom_bar(stat = "identity") +
    geom_text(aes(label = paste0(round(Share_of_cases),
        "%")), position = position_stack(vjust = 0.5)) +
    scale_fill_brewer(palette = "Blues") + labs(x = NULL,
    y = NULL, fill = NULL, title = "Brands repsondents are familiar with") +
    theme_minimal() + theme(axis.line = element_blank(),
    axis.ticks = element_blank(), plot.title = element_text(hjust = 0.5,
        color = "#666666"))
p

10.3.3.1.1 Rank order question

In case of ranked data, one need to transform data from wide format to long format first.

# Packages
library(reshape2)
library(ggpubr)
library(rstatix)
library(ggstatsplot)
# Data in wide format
head(rank.data) %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Calories burned What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring heartbeat What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Exercise tracking What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring distance
2 4 1 5 3
1 3 5 2 4
1 2 4 5 3
2 1 3 4 5
5 4 3 1 2
4 2 1 3 5
# Data in long format
head(rank.data.long) %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
Feature Rank
What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps 2
What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps 1
What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps 1
What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps 2
What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps 5
What features are important to you when evaluating fitness trackers? Please order the following items from the most important to the least important. - Measuring steps 4

Simple way to depict ranks is a chart of box plots:

# Rank order question - box plots
p <- ggplot(rank.data.long, aes(x = Feature, y = Rank,
    fill = Feature)) + geom_boxplot() + theme_minimal() +
    ggtitle(label = "Perceived importance of features") +
    theme(axis.text = element_blank())
p

Package ggstatsplot() provides a great feature, which enables creation of a plot and conducting a statistical test at the same time.

# Rank order question - ggstatsplot
ggstatsplot::ggwithinstats(
  data = rank.data.long,
  x = Feature,
  y = Rank,
  type = "np",
  pairwise.comparisons = TRUE, # show pairwise comparison test results
  title = "What features are important to you when evualting fitness trackers?")

10.3.3.2 Constant Sum question

Required data format for a data obtained from constant sum question is similar to ranked data.

# Data in long format
head(constant.sum.long) %>%
    kableExtra::kbl(align = "c") %>%
    kable_paper("hover", full_width = F)
Factor Points
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location 32
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location 25
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location 19
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location 20
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location 30
What factors do you consider when choosing a place to go for a dinner? Please allocate 100 points among the attributes so that your allocation reflects the relative importance you attach to each factor. - Location 0

Here is one way to visualize data obtained from constant sum question.

# Constant sum question
p <- constant.sum.long %>%
    filter(Factor != "id") %>%
    ggplot(aes(x = Factor, y = Points, fill = Factor)) +
    geom_boxplot() + theme_minimal() + ggtitle("What factors do you consider when choosing a place to go for a dinner?")
p

ggstatsplot::ggwithinstats(
  data = constant.sum.long %>% filter(Factor!="id"), # excluding "id" column from the data
  x = Factor,
  y = Points,
  type = "p",
  bf.message = F,
  pairwise.comparisons = TRUE, # show pairwise comparison test results
  title = "What factors do you consider when choosing a place to go for a dinner?")

10.4 Frequently asked questions

Here we will post the most frequent issues you might face with handling Qualtrics data in R.

10.4.1 Multiple answers stored in one cell in CSV

Issue: When exported from Qualtrics to CSV, answers on multiple choice questions with multiple answers are stored in one cell. In the picture below you can see that this issue appears in the column “Q2,” where a respondent chose two answers (“1” and “2”), and these two answers are merged together in one cell.

Solution:

First, when you go to export your data from Qualtrics (“Data & Analysis” > “Export & Import” > “Export data”) choose CSV, and in the bottom-right corner you will find “More options.” After you click it, scroll down a bit, and there you should tick “Split multi-value fields into columns.” Please make sure that you are using the correct settings in Qualtrics export as depicted below:

So, make sure you tick:

  • Use numeric values
  • Remove line breaks
  • Split multi-value fields into columns

This should result in your multi-value fields being divided into columns as depicted below.

10.4.2 Labels for numeric values in CSV output

Issue: When exported from Qualtrics to CSV, answers are coded as numeric values, and I don’t know which value corresponds to which label(=answer)?

Solution:

You can check it or even change it in Qualtrics by doing the following steps:

  1. Navigate to the Survey tab and select the question you want to check labels for.

  1. Click the gray gear to the left to access the Question Options and choose Recode Values.

There you can see how Qualtrics coded your responses and you can potentially change it.

10.4.3 Bar chart for multiple choice question with multiple answers

Issue: How to create a bar chart for multiple answers on multiple choice questions?

Solution:

Let’s load the packages qualtRics and ggplot2 and Qualtrics survey data first:

library(qualtRics)
library(ggplot2)
qualtrics_1 <- read_survey("data/mrda_2.csv")

We would like to visualize question 2 (multiple choice question with multiple answers) which has 4 categories:

qualtrics_1[, c("Q2_1", "Q2_2", "Q2_3", "Q2_4")]

We see that we have some NA values that needs to be handeled. Therefore, we replace NA values with 0 for each category:

qualtrics_1$Q2_1 <- ifelse(is.na(qualtrics_1$Q2_1),
    0, qualtrics_1$Q2_1)
qualtrics_1$Q2_2 <- ifelse(is.na(qualtrics_1$Q2_2),
    0, qualtrics_1$Q2_2)
qualtrics_1$Q2_3 <- ifelse(is.na(qualtrics_1$Q2_3),
    0, qualtrics_1$Q2_3)
qualtrics_1$Q2_4 <- ifelse(is.na(qualtrics_1$Q2_4),
    0, qualtrics_1$Q2_4)

Third, we compute share for each category:

share_1 <- sum(qualtrics_1$Q2_1)/nrow(qualtrics_1)
share_2 <- sum(qualtrics_1$Q2_2)/nrow(qualtrics_1)
share_3 <- sum(qualtrics_1$Q2_3)/nrow(qualtrics_1)
share_4 <- sum(qualtrics_1$Q2_4)/nrow(qualtrics_1)

Finally, we add category shares to the rest of the data:

shares <- data.frame(share = rbind(share_1, share_2,
    share_3, share_4), response = c("yes, at uni",
    "yes, at job", "yes, other", "no"))
head(shares)

If you are not sure which numeric value refers to which label, you can find how to do it under question “Labels for numeric values in CSV output”.

Now we are set to produce a bar chart. Please note two important points:

  • We use reorder() function to wrap around the variable on x-axis in aesthetics part of ggplot function. In this way our bar chart will be shown in descending order.
  • We use coord_flip() function to turn our bar chart from being vertical to horizontal position.
ggplot(shares, aes(x = reorder(response, share), y = share)) +
    geom_col(aes(fill = response)) + labs(x = "", y = "",
    title = "Share of responses") + geom_text(aes(label = sprintf("%.0f%%",
    share/sum(share) * 100)), hjust = -0.2, size = 6) +
    theme_minimal() + ylim(0, 0.8) + scale_fill_brewer(palette = "Blues") +
    theme(axis.text.x = element_text(size = 16), axis.text.y = element_text(size = 16),
        plot.title = element_text(hjust = 0.5, color = "#666666"),
        legend.position = "none", title = element_text(size = 20)) +
    coord_flip()

In the end, to save generated plot, we can use ggsave() function. The plot will be saved in your working directory.

ggsave("bar_chart.jpg", height = 5, width = 8.5)

10.4.4 How to create a radar plot?

Issue: How can I create a radar plot and compare numeric values across different categories or groups?

Solution:

To explain this issue, we will use a data frame with two categories and several numeric variables.

head(Radar_chart)

In this data frame we merged two information from a survey:

  • Ranking(R) - how participants evaluated the city of Vienna on the dimensions of stability, education, health care, and culture (the scores for each dimension are derived from multi-item scales consisting of 7-point Likert-scales).
  • Importance(I) - how important participants judge each of the dimensions to be on a 7-point Likert-scale.

We wish to create a radar plot to directly compare ranking and importance of each variable.

First, we create to separate data frames; one for “Ranking”

library(dplyr)
library(ggplot2)
library(ggiraph)
library(ggiraphExtra)

# Creation of Ranking table
Ranking <- Radar_chart[, 1:4]
# Assigning the corresponding row name
Ranking$group <- "Ranking"

head(Ranking)

…and one for “Importance”

# Creation of Importance table
Importance <- Radar_chart[, 5:8]
# Assigning the corresponding row name
Importance$group <- "Importance"
head(Importance)

Now we want to bind these two data frames (Ranking and Importance), but beforehand we need to make sure that they have the same names of columns.

colnames(Ranking) <- c("Stability", "Education", "Healthcare",
    "Culture", "group")
colnames(Importance) <- c("Stability", "Education",
    "Healthcare", "Culture", "group")

Our data frames are now prepared to be combined in one:

# Connecting two data frames by rows
Radar_chart_new <- rbind(Ranking, Importance)

Now we can run ggRadar() to create a radar plot as follows:

# Radar plot
ggRadar(data=Radar_chart_new,
        aes(color=group), # Each category in the column "Name" will be assigned to different color
        interactive = FALSE, # When hover over the graph values appear
        rescale = FALSE, # If TRUE, all continuous variables in the data.frame are rescaled.
        ylim = 2, # y coordinates ranges.
        alpha = 0.35) # Transparency of colors in the graph
Radar chart

Figure 10.7: Radar chart

10.4.5 Vertical Likert line chart

Additionally, we can calculate mean values and compare them with ggPair():

Ranking_mean <- apply(Radar_chart_new[Radar_chart_new$group ==
    "Ranking", 1:4], 2, mean)
Ranking_mean <- data.frame(mean = t(Ranking_mean),
    group = "Ranking")
Importance_mean <- apply(Radar_chart_new[Radar_chart_new$group ==
    "Importance", 1:4], 2, mean)
Importance_mean <- data.frame(mean = t(Importance_mean),
    group = "Importance")

Before plotting we need to bind two data frames by rows:

Pair_chart <- rbind(Ranking_mean, Importance_mean)
Pair_chart$group <- as.factor(Pair_chart$group)

Finally, we can create a pair plot using the ggPair() function as follows:

library(ggiraph)
library(ggiraphExtra)
# Pair plot
ggPair(Pair_chart, horizontal = TRUE, interactive = FALSE,
    aes(color = group))
Pair chart

Figure 10.8: Pair chart

10.4.6 Diverging stacked barchart

Let’s use an example data frame again, where we observe the scores on 4 variables on a 7-point Likert-scale.

head(likert_chart)

Now we can use the likert() function from the HH package to create the Diverging stacked barchart as follows:

library(HH)
likert(t(likert_chart)[, 7:1], horizontal = TRUE, main = "Diverging stacked barcharts",
    xlab = "Percent", auto.key = list(space = "right",
        columns = 1, reverse = TRUE))

10.4.7 Collapse/recode categories

Issue: If you have certain number of categories (e.g. countries) and you would like to aggregate them by specific criteria (e.g. continents), how can you do it?

Solution:

There are several ways to do it, but we will show you the most intuitive.

For this purpose we will create a data frame:

# generate random data
df <- data.frame(country_id = round(runif(n = 100,
    min = 1, max = 7), 0))
# code factor variable for country
df$country <- factor(df$country_id, levels = 1:7, labels = c("Bangladesh",
    "Japan", "Austria", "Germany", "Italy", "USA",
    "Taiwan"))
str(df)
## 'data.frame':    100 obs. of  2 variables:
##  $ country_id: num  6 6 4 4 3 4 3 4 5 2 ...
##  $ country   : Factor w/ 7 levels "Bangladesh","Japan",..: 6 6 4 4 3 4 3 4 5 2 ...

In our data frame we have two columns, “country_id” and “country.”

Now we will create a third column, “region,” and assign each country to corresponding continent. For that purpose, we use recode function to assign region by country and create new variable for region:

library(car)
df$region = recode(df$country, "'Bangladesh'='Asia'; 'Japan'='Asia'; 'Austria'='Europe'; 'Germany'='Europe'; 'Italy'='Europe'; 'Taiwan'='Asia'; 'USA'='other'")
head(df)

This also works with numeric values:

df$region_1 = as.factor(recode(df$country_id, "1='Asia'; 2='Asia'; 3='Europe'; 3='Europe'; 4='Europe'; 5='Asia'; 6='other'; 7 = 'Asia'"))
head(df)

Alternatively, you can use gsub() function to replace each category individually:

df$region_2 = gsub("Bangladesh", "Asia", df$country)
df$region_2 = gsub("Japan", "Asia", df$region_2)
df$region_2 = gsub("Austria", "Europe", df$region_2)
df$region_2 = gsub("Germany", "Europe", df$region_2)
df$region_2 = gsub("Italy", "Europe", df$region_2)
df$region_2 = gsub("Taiwan", "Asia", df$region_2)
df$region_2 = gsub("USA", "other", df$region_2)
df$region_2 <- as.factor(df$region_2)
head(df)