Calculate Polychoric Correlation in R

Calculate Polychoric Correlation in R, The correlation between ordinal variables is calculated using polychoric correlation.

Remember that ordinal variables are categorical possible values and natural order.

Some of the common scales measured on an ordinal scale mentioned below,

  1. Low, Medium, High
  2. Dislike a Lot, Dislike a Little, Neither Like Nor Dislike, Like a Little, Like it a Lot
  3. Small, Medium, High

Etc…

Polychoric correlation has a value ranging from -1 to 1, where:

Grouped Data Mean and Standard Deviation Calculator »

A value of -1 denotes a perfect negative correlation, 0 denotes no correlation and a perfect positive correlation is indicated by a value of 1.

Calculate Polychoric Correlation in R

In R, we can compute the polychoric correlation between two ordinal variables using the polychor(x, y) function from the polycor package.

The examples below demonstrate how to use this function in practice.

tidyverse in r – Complete Tutorial » Unknown Techniques »

Approach 1: Calculate Polychoric Correlation for Ratings

Assume you want to know if there is a high correlation between the rating systems of two different rating companies.

We ask each company to rate 20 different videos on a scale of 1 to 3, with 1 being the best and 3 being the worst.

1 denotes “High”, 2 denotes “Medium” and 3 denotes “Low”

To calculate the polychoric correlation between the ratings of the two companies, we can use the R code below.

Descriptive Statistics in R »

library(polycor)
company1 <- c(2, 2, 3, 1, 3, 2, 3, 3, 2, 1, 3, 1, 1, 3, 3, 1, 3, 1, 3, 2)
company2 <- c(1, 1, 2, 2, 2, 3, 2, 2, 2, 2, 3, 1, 2, 2,32, 1, 3, 1, 2, 3)

We can now compute the polychoric correlation between ratings.

polychor(company1, company2)
[1] 0.6053117

The polychoric correlation is determined to be 0.6053117. This value is quite high, indicating a strong positive relationship between the ratings from each company.

Or we can make use of DescTools package,

Usage

CorPolychor(x, y, ML = FALSE, control = list(), std.err = FALSE, maxcor=.9999)
library(DescTools)
CorPolychor(company1, company2)
0.6053118

Approach2: Calculate Polychoric Correlation for product Ratings

Assume you want to know whether or not two different brands in personal care products have any correlation between their customer ratings.

What is neural network in machine learning? »

Let’s take 20 customers who experienced the product and asked them to rate their overall likeability on a scale of 1 to 5, where:

1 indicates “Dislike a Lot”, 2 indicates “Dislike a Little”, 3 indicates “Neither Like Nor Dislike”, 4 indicates “Like it a Little”,  5 indicates “Like it a Lot”

To calculate the polychoric correlation between the ratings of the two products’ overall likeability, we can use the R code below.

library(polycor)
product1 <- c(5, 5, 4, 2,2, 3, 3, 5, 2, 5, 3, 5, 4, 5, 4, 4, 5, 4, 5, 5)
product2 <- c(2, 2, 3, 4, 5, 3, 4, 2, 1, 4, 1, 5, 2, 2, 5, 5, 1, 5, 1, 2)

Now we can calculate the polychoric correlation between ratings

Log Rank Test in R-Survival Curve Comparison »

polychor(product1, product2)
[1] -0.225602

The polychoric correlation is determined to be -0.225602.

Or

CorPolychor(product1, product2)
-0.225602

This value is not closer to zero, indicating that there is little negative correlation between the product ratings. Based on the rating majority of the consumers liked product 1 in comparison to product 2.

Draw a trend line using ggplot-Quick Guide »

Subscribe to our newsletter!

[newsletter_form type=”minimal”]

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

19 − eleven =