# Correlation Tutorial

## What is Correlation?

Correlation shows a mutual relationship or connection between two or more things. Pearson’s correlation (R) is a correlation coefficient commonly used in linear regression

Result of a correlation is called correlation coefficient ("r") ranges from -1.0 to +1.0. The closer r is to +1 or -1 the more closely the two variables are related.

## Interpreted correlation with the help of graph

### Scatter plot:

It is a graph in which the values of two variables are plotted along X axis and Y axis showing the pattern of the resulting points and telling any correlation present.

1. Scatter Diagram showing perfect positive correlation 2. Scatter Diagram showing perfect Negative correlation 3. Scatter Diagram showing Low degree of Positive correlation 4. Scatter Diagram showing Low degree of Negative correlation 5. Scatter Diagram showing No Correlation Types of correlation coefficient formulas.

1) Karl Pearson’s Coefficient of Correlation Method:>

There are several correlation coefficient formulas but one of the most commonly used formula is Pearson’s correlation coefficient formula.

Correlation coefficient = r = 2) Sample correlation coefficient

rxy = sxy/sxsy

sx and sy are the sample standard deviations, and sxy is the sample covariance.

3) Sample correlation coefficient

pxy = σxyx σy )

Population correlation coefficient uses σx and σy as the population standard deviations, and σxy as the population covariance.

## How to calculate correlation

• Calculate correlation by hand

For ex:

 No Weekly attendance (x) Number of chocolate bars sold (y) 1 413 5884 2 399 6014 3 455 6215 4 472 6916 5 538 7209 6 503 7223 7 612 8158 Sum 3392 47619

Now first calculate xy, x2 and y2

 No Weekly attendance (x) Number of chocolate bars sold (y) xy x2 y2 1 413 5884 2430092 170569 34621456 2 399 6014 2399586 159201 36168196 3 455 6215 2827825 207025 38626225 4 472 6916 3264352 222784 47831056 5 538 7209 3878442 289444 51969681 6 503 7223 3633169 253009 52171729 7 612 8158 4992696 374544 66552964 Sum 3392 47619 23426162 1676576 327941307

Now use the correlation coefficient formula

Correlation coefficient = r = Which will be

= (7) (23426162) – (3392) (47619) / √ [{(7) (1676576) – (3392)2} {(7) (327941307) – (47619)2}]

= 2459486 / √ (230368) (28019988)

=0.97

1. Calculate correlation in excel

To calculate correlation, we can use formula CORREL or we can go to Data Analysis where select correlation to calculate.

1st using formula CORREL

Step 1 = write formula CORREL in excel below is the screen shot. After that select your data like given in below screenshot When you done with selecting data press enter this will given you correlation point between those data in this case it is 0.784940133

Note: this formula give you the correlation point of between two data set only if you have multiple variables the you can use second type of formula.

2nd using correlation from Data Analysis.

Step 1: select data analysis from Data tab, below is the screen shot Step 2: Select correlation and then in input range select your data set as given in below screenshot. Note: Make sure your labels in first row is checked if your data has labels otherwise unchecked it and make sure you have numerical data only as it doesn’t work in non-numeric data.

Step 3: After selecting the data range press ok which will give you the correlation point like given below.
{"ft_lang_label":"__label__en","ft_lang_prob":0.81020653,"math_prob":0.9752074,"size":3524,"snap":"2021-43-2021-49","text_gpt3_token_len":956,"char_repetition_ratio":0.17869318,"word_repetition_ratio":0.11616954,"special_character_ratio":0.35329172,"punctuation_ratio":0.065656565,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9983023,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],"im_url_duplicate_count":[null,5,null,5,null,5,null,5,null,5,null,10,null,10,null,5,null,5,null,5,null,5,null,5,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-11-27T00:31:23Z\",\"WARC-Record-ID\":\"<urn:uuid:ca2cee7b-f71b-4c16-9414-1219d19a88b6>\",\"Content-Length\":\"40830\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a0d0722f-860a-4718-8617-87c9f37531d2>\",\"WARC-Concurrent-To\":\"<urn:uuid:35da0130-1b8b-45fa-9475-40c73f5fc27f>\",\"WARC-IP-Address\":\"160.153.92.200\",\"WARC-Target-URI\":\"https://www.myassignmenthelp.net/correlation-tutorial\",\"WARC-Payload-Digest\":\"sha1:QCGK4OLTRXEKJGPUHWNFZZ4MG4WPE7MU\",\"WARC-Block-Digest\":\"sha1:VLIBQLCAILA7HGRJXJ76A7RBWE2FB4BZ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964358074.14_warc_CC-MAIN-20211126224056-20211127014056-00456.warc.gz\"}"}