R Tutorial: Measurement, validity & reliability

Learn how to design and evaluate surveys for reliability and validity in R. The tutorial covers converting survey items to factors, reverse-coding negatively worded questions using char::recode, and verifying your work with psych::responsefrequencies to confirm items are mirror images before analysis.
Chapters
The objective of this course is to help you craft surveys possessing both reliability and validity. These are complex concepts which you'll learn more about throughout the course. Let's introduce the basic ideas in this lesson. We can define measurement as the process of observing and recording. To do that, we generally need some kind of tool or instrument. Consider, for example, a ruler. It's a tool we use to measure something. Height. Of course, measuring something like consumer brand perceptions is a little trickier than measuring height. We need to check if it's calibrated, so to speak. Namely, we need to check if our survey is reliable and valid. Let's take an in depth look at each measurement. Reliability means that we are measuring consistently and we can reproduce what we are measuring. We already checked one type of reliability, equivalence as measured by inter rater reliability. There are several other types we'll cover the most common in the remainder of the course. Now for validity, are we measuring what we claim to measure? Just as with reliability, there are several types of validity. Here we have the so called three C's of validity. Again, we already measured the first content. We'll cover the others later in the course. Let's touch back briefly on our flowchart. Here we constructed a set of items to measure customer satisfaction using the tools from the last lesson and collected the data, which puts us between steps two and three in our flowchart. Now what? We're in the exploratory data analysis or eda, phase of the process. We want to learn about our data before modeling it. First, let's check response frequencies. Are respondents unanimous in rating each item, or is there a range of opinions? We can get a great visualization of this with the Likert package. To do this, we first pass our dataframe to the Likert function. All items must be converted to factors for this function, so we'll do that using dplyr's mutateif function, converting all integer variables to factors. We can pass our new object here to plot a bar chart of our response frequencies. We also need to check for items that are worded in the opposite way, so to speak, of the other items. To take an example, let's examine the items of our customer satisfaction survey. All these items carry positive connotations except the item difficult to use. A company certainly doesn't want its site to be difficult to use, so we want to measure the opposite of the responses here. This is called reverse coding. Let's create a new variable, difficulttouse R, which is a recoded version of the difficult to use item. To do that we will use the recode function from char. This is not to be confused with the recode function from dplyr, so we will explicitly call from the char package here. Next we specify how to Recode the values ones become 5s, 2s become 4s, and so forth. 3s will stay 3s, so no need to include that in our syntax. Let's confirm what we just did there, using select from dplyr to analyze just our two items of interest, we will use the response frequencies function from Psych. Let's also round the output for readability. We can see the two items are indeed reverse images of each other. Okay, we're ready to explore our survey data. Let's get started.
More from Richie

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon







