Submind YouTube summaries
Thumbnail for Great R Packages for Health Data Analytics - Likert Plot: Livestream Recording

Great R Packages for Health Data Analytics - Likert Plot: Livestream Recording

Watch on YouTube

Video summary

In this livestream recording titled "Great R Packages for Health Data Analytics," Monica Wahi introduces viewers to specialized visualization techniques designed for health data analysis, specifically focusing on the Likert plot. As an epidemiologist and data scientist who utilizes both SAS and R, she aims to bridge the gap between traditional statistical software and the advanced graphing capabilities of R. The session highlights four unique plots—the Likert, upset, dumbbell, and scree plots—that are not standard in typical biostatistics packages but are highly effective for interpreting survey responses. Wahi emphasizes that while SAS users might feel limited by their software's inability to generate these specific visualizations, they can still perform the necessary analysis in SAS and export the data to R for advanced plotting, effectively combining the strengths of both platforms. The core of the demonstration involves creating a Likert plot to visualize survey responses on a five-point scale ranging from strongly disagree to strongly agree. Wahi explains that this plot is particularly useful because it automatically sorts items based on the percentage of agreement, placing the most agreed-upon statements at the top and the most disagreed-upon at the bottom. The visualization clearly distinguishes between positive responses, negative responses, and neutral opinions in the middle, allowing researchers to quickly identify which aspects of a psychometric instrument or product are resonating with respondents and which are not. She advises against calculating simple means for Likert data, noting that treating ordinal variables as continuous is a common novice mistake that can lead to misleading conclusions, similar to how one should not average star ratings on review sites. To achieve these results, Wahi walks through the R code required to prepare the data, which involves handling missing response levels and converting numeric inputs into factors to preserve their ordinal nature. She demonstrates a clever workaround for datasets where certain response options are completely absent by generating fake data to fill gaps before merging it back with the real dataset. After cleaning the data and replacing generic column headers with meaningful survey statements, she utilizes a specific package to generate the final plot. The process ensures that the visualization accurately reflects the distribution of opinions without distorting the underlying ordinal data, providing a clear first-pass analysis tool for researchers dealing with complex survey results from applications or medical records. The video concludes with Wahi promoting an upcoming online workshop called "Application Basics," which aims to teach researchers how to navigate and analyze data from various computer applications effectively. She notes that modern research roles increasingly require the ability to interpret data structures and terminology used in application development, a skill set this workshop is designed to build. Attendees of her current Likert plot session receive free access to these future workshops, which cover topics like factor analysis and other advanced plotting techniques. Wahi encourages viewers to follow her company page for updates on upcoming events and invites those interested in the broader public health data science rebrand program to sign up for an interview, reinforcing her commitment to helping researchers become experts in their field through accessible education.
Read the full video transcript
well hello everybody and welcome to today's live stream um I'm Monica wahi and I'm here today to start showing you some really cool plots and this is part of my um great R packages for health data analytics and it's my R tricks for SAS users so oh welcome haric con I'm glad you're here um oh make sure that you download the slide everybody download the slides because guess what I'm going to show you is I'm going to show you some links right so on the screen right now um the the uh slides that I'm sharing you'll see there's four plots okay not four plot four plots right there's this lyker plot this upset plot this dumbbell plot and the scree plot and these are unusual plots they're not the ones you normally see in BIO statistics I want to make sure that you follow our company page and find out because I'm going to be doing the live stream today we're going to cover this plot here this liyer plot but we're going to cover these other ones in the future and I want to show them to you I'm I'm going to show you them in R um so I'm a data scientist in the health sort of domain because I'm an epidemiologist and I use both SAS and R but what I'm going to show you you can do an r and you don't need to worry that's sad SAS doesn't do these plots because you can do the analysis you can get the numbers out of SAS and so I'll even show you that today with the lier plot now if you're an R user you're probably oh it's good to see you seil um if you're an R user you're probably familiar with the um Package ggplot 2 which is a great uh graphing package and I call these non gplot 2 plots but that's not technically correct they're just not run in the-- Mill ggplot two plots they I think they leverage ggplot 2 but I'm just getting technical about it now if you download the slides you'll see that there's um on this slide you have these links okay and today if I'm going to be going over what's on the second link this lered plot it's a blog post that goes along with this and it's if you go to that blog post you can download the code and the data I'm using today to demonstrate and then on the next slide you'll notice that it says something about factor analysis this pertains to the scre plot which is like I said follow our company page when I post that event you can come and you'll find out about this all right all right so here we are in R now if you go to that blog post on the Liker plot you'll see that I've sort of organize the blog post in like step one step two I think I even brought up uh here's here it is so you'll see how it says you know kind of down here like see this one two three stuff okay that's what I'm talking about in this code where it says step one step two but I'm actually going to run all this code and jump ahead to step nine because I want to first show you what I'm talking about I first want to show you what this plot is you know when you're like doing like a cooking um video and you want to see what it looks like after it's cooked first before you do the recipe that's what we're doing here okay so it comes out like this but let me just stretch it out so even if you're a SAS user you don't really use R you'll see that this was kind of pretty easy I just ran all this code and this came out and I'm stretching it out to make it look nice now if I wanted to save this I could go over here file save as I usually choose jpic and then over here I could just save it as a JPEG right but I first want to just um interpret this for you okay so I'll show you the data set but what this data set had was it was a bunch of lyer scale statements as you can see here this was the responses one was strongly disagree two was somewhat disagree three was neither agree nor disagree four was somewhat agree and five was strongly agree and I actually took some real answers from a survey I just made up the statements these are just like gibberish statements okay so I want to show you and I just pulled out like five of them you know I was helping somebody do a survey and there are a lot more more items but I just want to show you how to interpret this okay now these five items the reason they're in this order has to do with the results okay so let's look at the results first I want to show you this x axis so see this zero in the middle then it says percentage 50 100 and then here it says 50 100 this green side is the agree side so you can kind of see of the people on this side you know how many get to agree um and here you can see that if you take this green and the light green together it says 51% over here that's what that means and this is 36% for this one so what it did was it first calculated that and then it sorted it in that order so this first one here this is the 51 is the biggest and then 36 32 30 26 so the most agreed with one is at the top so you can imagine if if you're doing like a psychometric instrument and then these are like the five items on one of your subscales you'd be like I'd like to see if they're all sort of close or if they're kind of different because let's look down here this one so this is strongly disagree right and see this the strongly plus someone it it's 60% and what's kind of nice about this is you can really tell like of the disagrees most of them are strongly over here and of the agrees most of the are strongly over here okay but I haven't really gone over this middle one and this is the the disagree over here like this is 40% this is 36% see this middle one this gray shows you how many people said they they didn't they didn't have an uh that neither agree nor disagree and some people call that neutral but I like to put it neither agreen or disagree because sometimes you just don't have an opinion but see how like 30 % we here that's kind of weird like people shouldn't be putting this a lot so they don't have a strong opinion sometimes that can be an issue so this is nice here so you can see how if you're studying if you're doing a bunch of surveys I I don't recommend putting all of your Liker answers into one plot I recommend taking groups and putting them in and then that way um um I'm sorry I don't know what's going on with my phone um I I recommend just putting groups of them in at a time so you can compare them like on domains and then that way you can make this visualization and it makes it easier for you to make decisions all right so that's the visualization and now I'm going to show you how to make it and I'm just looking over here to see if anybody's got any questions okay so I'm I'm going to just clear this console here and I'm going to start at the beginning so this is r and you can set the working directory I set the working directory to whatever we're doing today um and then Step One is I read in my survey data set so I'm going to read this in and I'm just going to show you what it looks like and it's called survey one so what survey one looks like is it's got a study ID with this this number that starts with 14755 and if I scroll down it's got 47 um people in it and it it's got five columns they're called q1 Q2 Q3 Q4 Q5 and you just saw the legend that's the legend of what they were asked they were asking statements and they had to rate them now the problem I had with this data set and I've had this before is so imagine you ask a statement and it's a really awesome statement like everybody agrees with it that means that it doesn't like let's say five is a super awesome statement that everybody agrees with they're going to answer to Q5 five or four there or even maybe three but nobody's going to answer one or two and if you get this situation where nobody answers one of the levels you've got to do a workaround for this plot so that's actually built into this code okay and it's kind of a cloy workaround so please don't laugh at me it works okay and it helps you understand kind of how R works so imagine that you're in SAS and you've got a a ton of data or whatever you could theoretically just trim out these columns you know like even if you had like thousands like I think if you had a real million records if you just trimmed out these columns and you pulled it out you could just do exactly you know read it into R and do this thing I just did okay so what's the first thing we're going to do is steps two and three is where we design and make fake data and this is really fun in art because it's not that easy to do in SAS so notice how study ID is a column and q1 is a column or whatever well what we're doing for our fake data is just making columns so I made a column called study ID which is just a vector with a bunch of these nine um uh values in it why because then I can filter these out again I know these are fake data and see q1 for the first one I'm going to say everybody q1 is going to say one two 3 four five like 99991 is going to say one one one11 for each and the next one's going to say 2 two two two two for each you can see what I'm doing right I'm making sure that each one um that each one has uh uh that value in it just to game the system all right and then I'm going to take these columns and sew them together or splice them together by using a data frame command into a data uh frame called fake right so let's just make fake all right so let's uh run fake there's my fake data it looks just like the real data only I'm gaming it so I'm making sure it's got the values in each of now I'm going to actually bind rbind or row bind fake to survey one to generate survey 2 this looks a lot like um merging in in SAS right so we're going to just merge these together and here's survey two and see I've got the fake data at the end now here's something that's not going to happen in SAS and happens in r um right now if I ask what class or what is the data type like class if I go um what is it survey 2 q1 it says numeric we cannot do this plot with numeric data we have to use ordinal data and if you you know like 1 2 3 4 5 is ordinal and so you have to classify it as a factor in R which doesn't happen in sense right so how you change like you could change let's say you had character numbers number stored characters you could change them to numeric using as numeric well this is called as Factor so we create these new set of variables called q1 uncore f for factor which is the factor version of these variables so that's what we're going to do here and now when we see survey 2 after I ran this here's the factor version of all these it looks the same but when you do the class like class survey to q1f for Factor see it's a factor class and you're probably like okay Monica they look the same well the problem is they behave differently okay the factors are going to behave like ordinal variables or like nominal variables they're going to behave like categorical variables so one means a category right so now the next step step five I create this um Vector called Factor levels now these are going to be what ends up in the legit okay so this is so if you had said neutral instead of neither agree nor disagree then this is where you would do that so I run that and I it's just a vector that says these levels okay and I have to put them in order of 1 2 3 4 5 that's how it knows okay now I'm going to shove the factor levels onto each of my Factor variables see the underscore f um it's the same factor levels I'm just shoving them on to I always say shoving it because it uses this Arrow that's probably very rude right so now actually I want to show show you survey too because it looks a little different now remember how a minute ago all of these like these looked like numbers and these also look like numbers well now they don't cuz we basically if you remember sas's formats like you can attach formats to levels of categorical variables this is kind of the same thing is you can attach these Factor levels to factor variables it's like the analogous thing all right let's go bottom here all right so we've made it through now we're on step six and in step six what we want to do is remove our fake data we had our fake data was there to hold the placers to make sure that when we did like Q4 Factor levels it wasn't missing one of these because if like everybody said strongly agree somewhat agree you neither agree or disagree and we're missing this it would error out at the steps so we prevented that with our CL but now we have to get rid of the fake data so we're going to create survey 3 by keeping survey 2 only the study IDs that are less than this 99 right so we'll do that and I realize it's a clu but here we go so now we know you can see the at number of rows remember in our actual survey data set we had 20 47 all right so now the only problem is let let me use a a call names here so call names survey 3 so we have a lot of columns we're not going to plot like we're only going to plot these Factor columns so the next step is to create survey 4 where we just keep the columns now now notice here we don't want Study ID for the plot we don't want we don't want any of these we want this one and these and see this one and this eight this is column 8 and column 9 and this is column 7 so this is me saying brackets survey three brackets I want all the rows that's the comma like everything you know that's why I didn't put anything before I want all the rows and just columns 7 through 11 now hard coding columns you want in your code is risky but we're just making a plot data set so we can get away with it right so we'll do that and then now when I do um let me see if this works say hey see I I used the up Arrow it worked again now let me see uh this is curvey yeah so now survey 4 only has these um these column names in it all right so those columns but that these column names are not what we we want the actual statement to come out on the plot so this is where I was using real survey data just a few question or statements from real survey data this is where I just replaced these VAR headings with just nonsense statements and so I I made these nonsense statements and called them VAR headings and now I attached them see this names I made them the column headings I I replaced q1f with I want to live in a world with unicorns I I think that's how it ended up let's look at it here yeah so now I I replaced them with the and I know that sounds weird right like in SAS you could never make a column heading that's a sentence you know but welcome to R right you get to break some sess rules makes it feel good finally we get to the plot so remember when you're using R you have to if you're using a package you got to install the package right so I already installed the package ler that's what we're using and so we call it up with the library now how how to you can see here I'm running the lyer command on this plot data set that I work so hard to make and that creates this object P then then I use this ler barplot command with all of these settings in it to generate this object a and then I plot a so this is super complicated I encourage you to read the blog post to figure all this out so you can see these are just um options I'm setting really like I think if I run P here okay so what if you p is just the um portions that come out and then if I run this like or bar plot on P these are all these settings I generate a and then when we plot a this is what we get all right and if you go you can get all of this code and even an explanation of all of those options at that um uh at that blog post what we just talked about was like analyzing this Liker plot like producing this lered plot from survey dat basically it's survey data right so if you're in my audience right now you've probably done surveys and pro you probably do research and you're probably used to like making a research protocol or making a plan and Gathering data and then trying to you do a plot like I just showed you with it but nowadays researchers like us are expected to actually know more than that we're expected to like be able to analyze data from applications in fact somebody I was just talking to yesterday talk to me about one of these data providers you can log in and you can analyze and counter data and you can analyze data from medical records and from Labs at real hospitals real world data is what it's called but that person even though they're really intelligent was very confused like they didn't know they're like Monica I don't know what to connect I don't know what data sets to connect I don't know what makes sense I should I look at inpatient should I look at outpatient what makes sense with my research question and I was like yeah what if you're expected to analyze data from an application it's really not that straightforward so because of that I came up with this Workshop called application Basics um the big picture is our themed this month so this is an on online workshop with the learning objective to understand data sets from applications well enough to analyze them and produce results and if you come to the workshop you're going to learn about Computer Applications like how these applications are designed like the teams that designed them and how the data are stored in the applications you're going to learn the terminology around application development so you can start using it to communicate and with this knowledge you can break through communication barriers to get the answers you need to complete your analysis and be seen as an expert so here are some details about the workshop um again it's called application Basics the big picture and it's Saturday and Sunday um March 23rd and 24th and each session starts at noon eastern time and lasts about 3 hours and it's an interactive Zoom online um workshop and a normal price for a workshop like that is about $250 to $750 per Workshop when you have these two-day interactive workshops where you can network with data scientists but lucky you because you attended my lyer scale Workshop uh today my leer plot Workshop your cost is free I have not found another Workshop like this that has that delivers this information to a research audience um and I have gotten a lot of very positive feedback from the participants so I really would hope that you would sign up for our workshop and again follow our company page and make sure you stay up to date about our um events because I'm going to show you how to do those other three plots you saw and especially if you're into psychometric analysis like making psychometric instruments or analyzing data from them you know I'm going to have something on factor analysis so you're going to want to know about that next time you do a survey you want to use definitely use the leered plot it's really great for um a it's it's really great for um interpretation so what will happen is especially like let's say you've got a product and you've got a statements about this product and they're all positive like the product was fun to use the product was easy to use the product was intuitive to use the product was um made me feel comfortable the product made me feel confident you can throw them all in one lyker plot and it'll sort it out for you like if the product did not make them feel comfortable that's going to be on the bottom right it really just helps you with the first pass of trying to sort out the Liker data like I remember I used to get Liker data and I'm like well what do I do do I just make the percent that agree and what you're never supposed to do is make a mean out of it right Cal that's the wrong thing to do because then you're not handling it as an ordinal variable you're handling it as a continuous variable it's a what is it a novice's common mistake but then you're like make you know I'm shaming these novices for making means out of ordinal variables but that's what we do right like if you go on um Yelp or you know Uber or whatever you see oh 4.5 I have a good driver you know you're not supposed to make a mean out of it right and so if I'm yelling at everybody you're not supposed to make a mean out of it then what are you supposed to do so uh the this is my answer you're supposed to do the like your plot well thank you every everybody for showing up today I really appreciate it when you come to my live streams because I don't like to talk to nobody and I just love seeing everybody's faces here on zoom and I hope you have a wonderful Tuesday and a very good week thank you for watching this video which is part of the public health to data science Rebrand program if you are interested in joining the program please sign up for a 30-minute Zoom interview using the link in the description