VOOZH about

URL: https://www.analyticsvidhya.com/blog/2021/01/beginners-guide-to-pearsons-correlation-coefficient/

⇱ Pearson Correlation Coefficient - A Beginners Guide


India's Most Futuristic AI Conference Is Back – Bigger, Sharper, Bolder

  • d
  • :
  • h
  • :
  • m
  • :
  • s

Reading list

Beginner’s Guide to Pearson Correlation Coefficient

Apurva Last Updated : 24 Jan, 2025
5 min read

When we try to infer something from what we have heard or read, the first step we do is relate a few of the parameters or scenes, etc. with each other and then proceed. Correlation means to find out the association between the two variables and Correlation coefficients are used to find out how strong the is relationship between the two variables. The most popular correlation coefficient is Pearson’s Correlation Coefficient. It is very commonly used in linear regression.

This article was published as a part of the Data Science Blogathon.

What is Pearson’s Correlation Coefficient?

Pearson Correlation Coefficient (r), often denoted as r, measures the strength and direction of a linear relationship between two continuous variables. It ranges from -1 to 1, where:

👁 Image

Example of Pearson’s Correlation Coefficient

Consider the example of car price detection where we have to detect the price considering all the variables that affect the price of the car such as carlength, curbweight, carheight, carwidth, fueltype, carbody, horsepower, etc.

Correlation can be found out between continuous variables using python:

We can see in the above scatterplot, as the carlength, curbweight, carwidth increases price of the car also increases. So, we can say that there is a positive correlation between the above three variables with car price. Here, we also see that there is no correlation between the carheight and car price.

Cars with high prices have very low mileage as compared to the low range of cars. Hence, in this case, we can say that there is a negative correlation between car price and mileage.

Values of Pearson Correlation Coefficient (r)

Value of ‘r’ ranges from ‘-1’ to ‘+1’. Value ‘0’ specifies that there is no relation between the two variables. A value greater than ‘0’ indicates a positive relationship between two variables where an increase in the value of one variable increases the value of another variable. Value less than ‘0’ indicates a negative relationship between two variables where an increase in the value of one decreases the value of another variable.

👁 types of correlation

Pearson correlation draws a line of best fit through two variables, indicating the distance of data points from this line. A ‘r’ value near +1 or -1 implies all data points are close to the line. An ‘r’ value close to ‘0’ suggests data points are scattered around the line.

Considering the same example of the car price, let’s find out the ‘r’ value using ‘pearsonr’ function in python.

As stated earlier, the value of Pearson correlation for Price vs Curbweight is 0.835 and as there is no correlation between Price and Carheight, hence the Pearson Correlation value between Price & Carheight is near to 0 which is 0.12.

Assumptions for a Pearson Correlation

  1. Data must be from random or representative samples for meaningful statistical inferences.
  2. Both variables should be continuous and follow a normal distribution.
  3. Homoscedasticity is crucial, ensuring similar variance around the line of best fit.
  4. Extreme outliers, whether univariate or multivariate, impact the Pearson Correlation Coefficient (r). For instance, plotting age vs. loan amount reveals a correlation, but reversing the variables might yield inconclusive results. Consider these assumptions when interpreting correlations for robust analysis.
👁 python code

Conclusion

Understanding Pearson’s Correlation Coefficient is foundational for anyone delving into statistics or data analysis. This guide has demystified the calculation and interpretation of r, offering insights into the strength and direction of linear relationships between variables. Armed with this knowledge, beginners can make informed decisions about data relationships. As a widely used statistical tool, Pearson’s Correlation Coefficient provides a valuable entry point into quantitative analysis, unlocking possibilities for deeper exploration and comprehension of data patterns. Embrace the power of correlation to unravel meaningful insights from your datasets.

References

Frequently Asked Questions

Q1. What does Pearson correlation tell you?

A. Pearson correlation measures the strength and direction of the linear relationship between two continuous variables. It provides a value between -1 and 1, where 1 indicates a perfect positive linear relationship, -1 indicates a perfect negative linear relationship, and 0 indicates no linear relationship.

Q2. Why Pearson correlation is used in research?

A. Pearson correlation is used in research to assess the degree of association between two continuous variables. It helps researchers understand how changes in one variable correspond to changes in another, facilitating insights into patterns, trends, and potential dependencies within the data.

Q3. What is the difference between Pearson and Spearman?

A. Pearson correlation measures the strength and direction of the linear relationship between two continuous variables, assuming that the relationship is linear and variables are normally distributed. Spearman correlation, on the other hand, measures the strength and direction of the monotonic relationship between two variables, making it suitable for non-linear relationships and ordinal data. While Pearson correlation assesses linear associations, Spearman correlation assesses monotonic associations.

Q4. What is a good Pearson R correlation?

A. The interpretation of the Pearson correlation coefficient (R) depends on the context and the field of study. Generally, an R value close to 1 or -1 indicates a strong linear relationship, while an R value close to 0 indicates a weak linear relationship or no linear relationship at all. However, what constitutes a “good” correlation can vary based on the specific research question, the nature of the variables being studied, and the domain-specific standards or guidelines.

The media shown in this article is not owned by Analytics Vidhya and is used at the Author’s discretion.

Login to continue reading and enjoy expert-curated content.

Free Courses

Generative AI - A Way of Life

Explore Generative AI for beginners: create text and images, use top AI tools, learn practical skills, and ethics.

Getting Started with Large Language Models

Master Large Language Models (LLMs) with this course, offering clear guidance in NLP and model training made simple.

Building LLM Applications using Prompt Engineering

This free course guides you on building LLM apps, mastering prompt engineering, and developing chatbots with enterprise data.

Improving Real World RAG Systems: Key Challenges & Practical Solutions

Explore practical solutions, advanced retrieval strategies, and agentic RAG systems to improve context, relevance, and accuracy in AI-driven applications.

Microsoft Excel: Formulas & Functions

Master MS Excel for data analysis with key formulas, functions, and LookUp tools in this comprehensive course.

Responses From Readers

Flagship Programs

GenAI Pinnacle Program| GenAI Pinnacle Plus Program| AI/ML BlackBelt Program| Agentic AI Pioneer Program

Free Courses

Generative AI| DeepSeek| OpenAI Agent SDK| LLM Applications using Prompt Engineering| DeepSeek from Scratch| Stability.AI| SSM & MAMBA| RAG Systems using LlamaIndex| Building LLMs for Code| Python| Microsoft Excel| Machine Learning| Deep Learning| Mastering Multimodal RAG| Introduction to Transformer Model| Bagging & Boosting| Loan Prediction| Time Series Forecasting| Tableau| Business Analytics| Vibe Coding in Windsurf| Model Deployment using FastAPI| Building Data Analyst AI Agent| Getting started with OpenAI o3-mini| Introduction to Transformers and Attention Mechanisms

Popular Categories

AI Agents| Generative AI| Prompt Engineering| Generative AI Application| News| Technical Guides| AI Tools| Interview Preparation| Research Papers| Success Stories| Quiz| Use Cases| Listicles

Generative AI Tools and Techniques

GANs| VAEs| Transformers| StyleGAN| Pix2Pix| Autoencoders| GPT| BERT| Word2Vec| LSTM| Attention Mechanisms| Diffusion Models| LLMs| SLMs| Encoder Decoder Models| Prompt Engineering| LangChain| LlamaIndex| RAG| Fine-tuning| LangChain AI Agent| Multimodal Models| RNNs| DCGAN| ProGAN| Text-to-Image Models| DDPM| Document Question Answering| Imagen| T5 (Text-to-Text Transfer Transformer)| Seq2seq Models| WaveNet| Attention Is All You Need (Transformer Architecture) | WindSurf| Cursor

Popular GenAI Models

Llama 4| Llama 3.1| GPT 4.5| GPT 4.1| GPT 4o| o3-mini| Sora| DeepSeek R1| DeepSeek V3| Janus Pro| Veo 2| Gemini 2.5 Pro| Gemini 2.0| Gemma 3| Claude Sonnet 3.7| Claude 3.5 Sonnet| Phi 4| Phi 3.5| Mistral Small 3.1| Mistral NeMo| Mistral-7b| Bedrock| Vertex AI| Qwen QwQ 32B| Qwen 2| Qwen 2.5 VL| Qwen Chat| Grok 3

AI Development Frameworks

n8n| LangChain| Agent SDK| A2A by Google| SmolAgents| LangGraph| CrewAI| Agno| LangFlow| AutoGen| LlamaIndex| Swarm| AutoGPT

Data Science Tools and Techniques

Python| R| SQL| Jupyter Notebooks| TensorFlow| Scikit-learn| PyTorch| Tableau| Apache Spark| Matplotlib| Seaborn| Pandas| Hadoop| Docker| Git| Keras| Apache Kafka| AWS| NLP| Random Forest| Computer Vision| Data Visualization| Data Exploration| Big Data| Common Machine Learning Algorithms| Machine Learning| Google Data Science Agent
👁 Av Logo White

Continue your learning for FREE

Forgot your password?
👁 Av Logo White

Enter OTP sent to

Edit

Wrong OTP.

Enter the OTP

Resend OTP

Resend OTP in 45s

👁 Popup Banner
👁 AI Popup Banner