## Friday, 6 September 2013

### Correlations

In this post, two types of Correlations will be discussed, the non-parametric correlation called Spearman's Rank Correlation, and the parametric correlation called the Pearson Correlation.

Spearman's Rank Correlation

Spearman's Rank Correlation $\rho$ is a non-parametric measure of the relationship between two variables, and tests whether these variables have a monotonic relationship.

Suppose two populations, with the same number of samples, have a monotonic relationship. If these two populations were paired together, and the pairs sorted by the magnitude of the first element in ascending order, the second elements would be ordered by magnitude in ascending order too. Conversely if the first element of the pair was used to order the pairs in descending order, the second element of the pair would be ordered in descending order too. This relationship would hold true if we  ordered the second element of the pair, and examined the ordering of the first element.  Thus, each of the pair of samples would be ordered in the same direction.

If two populations are anti-monotonic with respect to each other, then if these two populations were paired together, and the pairs sorted by the magnitude of the first element in ascending order, the second elements would be ordered by magnitude in descending order. Conversely if the first element of the pair was used to order the pairs in descending order, the second element of the pair would be ordered in  ascending order. This relationship would hold true if we ordered the second element of the pair, and examined the ordering of the first element.  Thus, each of the pair of samples would be ordered in the opposite direction.

Spearman's Rank Correlation is bounded in value, between $-1$ and $+1$, for when the variables are related in either an anti-monotonic or monotonic manner with each other respectively, and is given by the following equation:-

$\Large \rho=\frac{\sum_{i=1}^{n}{(x_i-\bar{x})(y_i-\bar{y})}}{\sqrt{\sum_{i=1}^{n}(x_i-\bar{x})^2\sum_{i=1}^{n}(y_i-\bar{y})^2}}$ (Eq. 1)

where $x_i$ and $y_i$ are the result of converting $n$ (raw) samples $x[i]$ and $y[i]$ to their ranks respectively, and $\bar{x}$ and $\bar{y}$ are the mean of the ranks $x_i$ and $y_i$ respectively.

If there are no duplicate values of the raw samples ($x[i]$ and $y[i]$), i.e. no tied ranks, the above formula (Eq. 1) simplifies to

$\Large \rho=1-\frac{6\sum_{i=1}^{n}d_i^2}{n(n^2-1)}$ (Eq. 2)

where $d_i=x_i-y_i$. A derivation of this follows.

When there are no ties

$\sum_{i=1}^{n}(x_i-\bar{x})^2=\sum_{i=1}^{n}(y_i-\bar{y})^2$ (Eq. 3)

Also, $\bar{x}=\bar{y}$ regardless of whether there are ties or not.

Expanding the left hand side of (Eq. 3), we have

$\large \sum_{i=1}^{n}(x_i-\bar{x})^2=\sum_{i=1}^{n}(x_i^2-2x_i\bar{x}+\bar{x}^2)$

$\large =\frac{n(n+1)(n+2)}{6}-\frac{n(n+1)^2}{2}+\frac{n(n+1)^2}{4}$

$\large =\frac{n(n^2-1)}{12}$ (Eq. 4)

where we have used the identities

$\large \sum_{i=1}^{n}x_i^2=1^2+2^2+...+n^2=\frac{n(n+1)(n+2)}{6}$

and

$\large \sum_{i=1}^{n}x_i=1+2+...+n=\frac{n(n+1)}{2}$

Thus, the denominator of (Eq. 1) is $\large \frac{n(n^2-1)}{12}$.

Examining the numerator of (Eq. 1), we can expand this to

$\sum_{i=1}^{n}(x_i-\bar{x})^2$ - $\sum_{i=1}^{n}(x_i-\bar{x})^2$ + $\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})$

Using (Eq. 3) , we can further expand the numerator  to

$\sum_{i=1}^{n}(x_i-\bar{x})^2$ - $0.5\sum_{i=1}^{n}(x_i-\bar{x})^2$ $0.5\sum_{i=1}^{n}(y_i-\bar{y})^2$  + $\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})$

Dividing the expanded numerator by the denominator, (Eq. 1) becomes

$\Large \rho=1-\frac{\sum_{i=1}^{n}(x_i-\bar{x}-y_i+\bar{y})^2}{2\sum_{i=1}^{n}(x_i-\bar{x})^2}$

Substituting (Eq. 4), we have

$\Large \rho=1-\frac{6\sum_{i=1}^{n}(x_i-y_i)^2}{n(n^2-1)}$

If we denote $d_i=x_i-y_i$, we end up with

$\Large \rho=1-\frac{6\sum_{i=1}^{n}d_i^2}{n(n^2-1)}$

which is the simplified expression for $\rho$ when no ties are present.

As Spearman's Rank Correlation is a non-parametric test, it will be robust to the presence of outliers in the datasets.

Spearman's Rank Correlation - A worked example

Consider the raw sample pairs ($x[i]$,$y[i]$) as below

1 , 1
5 , 4
3 , 2
3 , 3

Their ranks ($x_i$,$y_i$) are on the right:-

($x[i]$,$y[i]$)    ($x_i$,$y_i$)      ($x_i$-$\bar{x}$)     ($y_i$-$\bar{y}$)
1 , 1         1, 1          -1.5         -1.5
5 , 4         4, 4           1.5           1.5
3 , 2      2.5, 2              0          -0.5
3 , 3      2.5, 3              0           0.5

The numerator of $\rho$ is ($-1.5 \times -1.5 + 1.5 \times 1.5 + 0 \times -0.5 + 0 \times 0.5$), which is $4.5$. The denominator of $\rho$ is $\sqrt{(2.25 + 2.25 + 0 + 0) \times (2.25 + 2.25 + 0.25 + 0.25)}$ which is $4.743416$.  Thus $\rho$ is $4.5/4.743416$, which is $0.948683$.

There is a Spearman Rank Correlation Calculator in this blog, which can be found here.

Pearson Correlation

The Pearson Correlation is the parametric equivalent of the Spearman Rank Correlation, and is given by the equation

$\Large r=\frac{\sum_{i=1}^{n}{(x[i]-\bar{x})(y[i]-\bar{y})}}{\sqrt{\sum_{i=1}^{n}(x[i]-\bar{x})^2\sum_{i=1}^{n}(y[i]-\bar{y})^2}}$

where $x[i]$ and $y[i]$ are the raw samples from the two populations that are to be correlated against, and $\bar{x}$ and $\bar{y}$ their respective means.

Like the Spearman Rank Correlation, the Pearson Correlation has a minimum of $-1$ and a maximum of +1. Unlike the Spearman Rank Correlation, it is sensitive to the value of the sample, and will be $+1$ only if the two populations are exactly linearly related with positive gradient, and $-1$ only if the two populations are exactly linearly related with negative gradient.

It is worth noting that the square of the Pearson Correlation ($r^2$) is the Coefficient of Determination, that was encountered in the Linear Regression post, in this blog. There is a Pearson Correlation Calculator in this blog, which can be found here

1. Hello Everyone out there,I am here to give my testimony about a Herbalist doctor who helped me . I was infected with HERPES SIMPLEX VIRUS in 2011, i went to many hospitals for cure but there was no solution, so I was thinking how can I get a solution out so that my body can be okay. One day I was in the river side thinking where I can go to get solution. so a lady walked to me telling me why am I so sad and i open up all to her telling her my problem, she told me that she can help me out, she introduce me to a doctor who uses herbal medication to cure HERPES SIMPLEX VIRUS and gave me his email, so i mail him. He told me all the things I need to do and also give me instructions to take, which I followed properly. Before I knew what is happening after two weeks the HERPES SIMPLEX VIRUS that was in my body got vanished . so if you are also heart broken and also need a help, you can also email him at {oliha.miraclemedicine@gmail.com}
or whatsapp him number: +2349038382931. or website is https://olihamiraclemedicine.webs.com/
Contact him today and you will have a testimony...Good luck!

Dr. OLIHA Also Cures:
1. HIV/AIDS
2. HERPES 1/2
3. CANCER
4. ALS (Lou Gehrigâ€™s disease)
5. Hepatitis B
6. chronic pancreatic
7. Emphysema
8. COPD (Chronic Obstructive Pulmonary Disease

1. INDEED DR SAYO HERBAL HEALER HAS THE CURE FOR FOLLOWING HERPES VIRUS, HIV/AIDS, CANCER ALL TYPES, DIABETES, HEPATITIS A/B, PAD, ETC......FOR MORE INFORMATION VISIT HIS WEBSITE: http://sayoherbalhome.com/ I was once a victim of the herpes virus with many symptoms on my body, I was cured of the virus thanks to the help of Dr Sayo herbal medicine. I saw most of his patient testimonials on blogs and social media pages, cured of various disease/virus and illnesses. I contacted him on his email address to which he replied and asked me a few questions and the preparation method for which I paid, he sent me the herbal medicines and instructions on how to take it I apply the herbal medicine for 4 weeks and the symptoms on my body were healed after taking the herbal medicine treatment, I went for test and my result was negative with know trace of virus in my blood and am completely cured. You can also be cured, contact him on his email:  sayoherbalhealer@gmail.com  or WhatsApp him on +2349012175679 or visit his facebook page: https://www.facebook.com/SayoHerbalHealer

2. DR OYAGU herbal medicine is a good remedy for herpes simplex virus cure. My name is MIGNON WRIGHT , am from USA,I am here to give my testimony about DR OYAGU who helped me in my life, i want to inform the public how i was cured from (HERPES SIMPLEX VIRUS) by DR OYAGU, i visited different hospital but they gave me list of drugs like Familiar, Zovirax, and Valtrex which is very expensive to treat the symptoms and never cured me. I was browsing through the Internet searching for remedy on HERPES and i saw comment of people talking about how DR OYAGU cured them, when i contacted him he gave me hope and send a Herbal medicine to me that i took and it seriously worked for me, am a free person now without any problem, my HERPES result came out negative, I pray to God to never let me and my family forget you in our life, am now cured permanently, you can also get your self cured my friends if you really need this doctor help, you can reach him on his website ;https://oyaguspellcaster.wixsite.com/oyaguherbalhome Email: oyaguherbalhome@gmail.com or via whatsapp +2348101755322

3. All thanks to Dr Raymond for helping me to get my penis longer and bigger with his cream in just two week his cream is very active and also it work fast for everyone who have used it, the best thing about his herbal cream is that it does not have side effects and the results is permanent. Note he can also cure the below sicknesses and disease PREMATURE EJACULATIONLOW SPERM COUNTERECTILE DYSFUNCTIONHIV/AIDS CUREHERPES CUREINFECTION CUREPILESTROKEHEART FAILUREYou can email him if you need his help via: drraymondherbalcenter@gmail.com or WhatsApp him via: +2348116744524

4. I'm here to testify about what DR. OYAGU did for me. I have been suffering from (GENITAL HERPES VIRUS) disease for the past 2 years and had constant pain and inching, especially in my private part. During the first year, I had faith in God that i would be cured someday. This disease started circulating all over my body and I have been taking treatment from my doctor, few weeks ago I came across a testimony of Shayla Bosschart on the internet testifying about a Man called DR. OYAGU on how he cured her from 7 years HSV 2. And she also gave the email address of this man, advise anybody to contact him for help on any kind of diseases that he would be of help, so I emailed him telling him about my (HSV 2) he told me not to worry that I was going to be cured!! Well, I never doubted him I have faith he can cure me too,, DR. OYAGU prepared and sent me Healing Soap, roots and herbs which I took. In the first one week, I started experiencing changes all over me, after two weeks of using his Roots/ Herbs, Oil and Soap, I was totally cured. no more inching , pain on me anymore as DR. OYAGU assured me. After some time I went to my doctor to do another test behold the result came out negative. So friends my advise is if you have such disease or know anyone who suffers from it or any other disease like HPV, HBV, HIV, ALS, HBP, CANCER etc. you can contact DR. OYAGU for help via email} oyaguherbalhome@gmail.com visit his website https://oyaguspellcaster.wixsite.com/oyaguherbalhome whatsapp him through his mobile} +2348101755322. , Thanks once again DR. OYAGU for making me a happy woman again.

5. Am Here To Give My Testimony About A Doctor Who Helped Me In My Life. I Was Infected With HERPES SIMPLEX VIRUS In 2019, I Went To Many Hospitals For Cure But There Was No Solution, So I Was Thinking How Can I Get A Solution Out So That My Body Can Be Okay. One Day I Was In The River Side Thinking Where I Can Go To Get Solution. So A Lady Walked To Me Telling Me Why Am I So Sad And I Open Up All To Her Telling Her My Problem, She Told Me That She Can Help Me Out, She Introduce Me To A Doctor Who Uses Herbal Medication To Cure HERPES SIMPLEX VIRUS And Gave Me His Email, So I Mail Him. He Told Me All The Things I Need To Do And Also Give Me Instructions To Take, Which I Followed Properly. Before I Knew What Is Happening After Two Weeks The HERPES SIMPLEX VIRUS That Was In My Body Got Vanished . So If You Are Also Heart Broken And Also Need A Help, You Can Also contact Him Through Dr. Oyagu reach him oyaguherbalhome@gmail.com visit his website https://oyaguspellcaster.wixsite.com/oyaguherbalhome Or whatsapp him via +2348101755322

6. DR OYAGU herbal medicine is a good remedy for herpes simplex virus cure. My name is MIGNON WRIGHT , am from USA,I am here to give my testimony about DR OYAGU who helped me in my life, i want to inform the public how i was cured from (HERPES SIMPLEX VIRUS) by DR OYAGU, i visited different hospital but they gave me list of drugs like Familiar, Zovirax, and Valtrex which is very expensive to treat the symptoms and never cured me. I was browsing through the Internet searching for remedy on HERPES and i saw comment of people talking about how DR OYAGU cured them, when i contacted him he gave me hope and send a Herbal medicine to me that i took and it seriously worked for me, am a free person now without any problem, my HERPES result came out negative, I pray to God to never let me and my family forget you in our life, am now cured permanently, you can also get your self cured my friends if you really need this doctor help, you can reach him on his website ;https://oyaguspellcaster.wixsite.com/oyaguherbalhome Email: oyaguherbalhome@gmail.com or via whatsapp +2348101755322

7. Especially superb!!! Exactly when I search for this.I found this webpage at the top of every single online diary in web crawler.

My web page ::: 휴게텔
(jk)

8. I'm 40 years old female I tested genital herpes (HSV1-2) positive in 2016. I was having bad outbreaks. EXTREMELY PAINFUL. I have try different kinds of drugs and treatment by the medical doctors all to know was avail. Six months ago I was desperately online searching for a helpful remedies for genital herpes (HSV1-2) cure, which I come across some helpful remedies on how Dr OYAGU have help so many people in curing genital herpes (HSV1-2) with the help of herbal treatment because I too believe there is someone somewhere in the world who can cure herpes completely. At of the past 2 months, however, I've been following his herpes protocol Via oyaguherbalhome@gmail.com or +2348101755322 and it stopped all outbreaks completely! To my greatest surprise I was cured completely by following the protocol of his herbal medicine . Don't be discouraged by the medical doctors. There is a cure for HSV with the help of herbs and roots by a herbalist Dr call Dr OYAGU he is so kind and truthful with his herbal treatment, kindly contact him for more information Via oyaguherbalhome@gmail.com or WhatsApp DR on +2348101755322 or visit his website https://oyaguspellcaster.wixsite.com/oyaguherbalhome you will be lucky as I am today

9. I'm here to testify about what DR. OYAGU did for me. I have been suffering from (GENITAL HERPES VIRUS) disease for the past 2 years and had constant pain and inching, especially in my private part. During the first year, I had faith in God that i would be cured someday. This disease started circulating all over my body and I have been taking treatment from my doctor, few weeks ago I came across a testimony of Shayla Bosschart on the internet testifying about a Man called DR. OYAGU on how he cured her from 7 years HSV 2. And she also gave the email address of this man, advise anybody to contact him for help on any kind of diseases that he would be of help, so I emailed him telling him about my (HSV 2) he told me not to worry that I was going to be cured!! Well, I never doubted him I have faith he can cure me too,, DR. OYAGU prepared and sent me Healing Soap, roots and herbs which I took. In the first one week, I started experiencing changes all over me, after two weeks of using his Roots/ Herbs, Oil and Soap, I was totally cured. no more inching , pain on me anymore as DR. OYAGU assured me. After some time I went to my doctor to do another test behold the result came out negative. So friends my advise is if you have such disease or know anyone who suffers from it or any other disease like HPV, HBV, HIV, ALS, HBP, CANCER etc. you can contact DR. OYAGU for help via email} oyaguherbalhome@gmail.com visit his website https://oyaguspellcaster.wixsite.com/oyaguherbalhome whatsapp him through his mobile} +2348101755322. , Thanks once again DR. OYAGU for making me a happy woman again.

10. It's a pleasure for me to write this testimony about this wonderful thing that happened to me last week on how i got my HIV aids cured, i have been reading so-many post of some people who were cured of HIV, but i never believed them, I was hurt and depressed so I was too curious and wanted to try dr.odoma then i contacted him on his email on drodomasolutionhome20@gmail.com when i contact him, he assured me 100% that he will heal me, i pleaded with him to help me out, it's a great success that he healed just as he promised, he told me that in three days time that i should go and check on my HIV status, I was floored that when i went to the hospital to check of my status that i was HIV negative, i never thought possible that dr.odoma can do miracles, i never really believed in magic but I played along with a little hope and faith and after everything but dr odoma changed my life and made me a true believer you can contact him drodomasolutionhome20@gmail.com or whatsapp Number: +2348100649947..visit his website:
https://drodomasolutionhome.simdif.com/
(facebook page https://www.facebook.com/Drodomaherbalmedicine/) he said that he is also specialize on the following diseases: HERPES, HIV, ALS, HPV, DIABETES, HEPATITIS B, CANCER,SICKLE CELL, VIRGINAL DRYNESS, And Bring Back Your Ex back.

11. God is Good! I promised God that I would share my testimony on this blog. I had all the signs of STD Virus but I was not too sure as to which one. I did a lot of online research and scared myself straight for a whole week before going to see the nurse. She took one look at my genital part and first said that it could just be the anatomy of my body, then she said it looked like genital warts and that I may have herpes. I was devastated. She gave me some medicine for the herpes and some cream for the warts. I was also tested for every single STD including herpes. I went home and cried searching the web for all sorts of cures for herpes and awaiting my results. I saw a post whereby Dr. Oyagu cured Herpes and other diseases, I copied his contacts out and added him on whats app via (+2348101755322). The next day my test result was ready and i confirmed Herpes positive. I told Dr.Oyagu about my health problems and he assured me of cure. He prepared his herbal medicine and sent it to me. I took it for 14 days (2 weeks). Before the completion of the 14 days in which I completed the dose, the Blisters and Warts that were on my body was cleared. I went back for check-up and I was told I'm free from the virus. Dr. Oyagu cures all types of diseases and viruses with the help of his herbal medicine. You can reach Dr. Oyagu via his email address on (oyahuherbalhome@gmail.com) or WhatsApp him on (+2348101755322) Visit His website on https://oyaguspellcaster.wixsite.com/oyaguherbalhome

12. INDEED DR SAYO HERBAL HEALER HAS THE CURE FOR FOLLOWING HERPES VIRUS, HIV/AIDS, CANCER ALL TYPES, DIABETES, HEPATITIS A/B, PAD, ETC......FOR MORE INFORMATION VISIT HIS WEBSITE: http://sayoherbalhome.com/ I was once a victim of the herpes virus with many symptoms on my body, I was cured of the virus thanks to the help of Dr Sayo herbal medicine. I saw most of his patient testimonials on blogs and social media pages, cured of various disease/virus and illnesses. I contacted him on his email address to which he replied and asked me a few questions and the preparation method for which I paid, he sent me the herbal medicines and instructions on how to take it I apply the herbal medicine for 4 weeks and the symptoms on my body were healed after taking the herbal medicine treatment, I went for test and my result was negative with know trace of virus in my blood and am completely cured. You can also be cured, contact him on his email:  sayoherbalhealer@gmail.com  or WhatsApp him on +2349012175679 or visit his facebook page: https://www.facebook.com/SayoHerbalHealer

13. Are you battling with any health related issues or infection is not the end of your life, why not contact a herbal practitioner for cure Dr Oyagu has herbal remedies and permanent solution for all your health related problems. recommend him to you today only because i have also used his herbal medicine and it worked perfectly on my health problem, you can actually save yourself from giving your hard earned money to Scammers if only you can contact Dr Oyagu today for genuine and Permanent cure herbal products . Pls help share this post to save yourself and your love ones. Dr Oyagu is specialize in these areas, Permanent herbal supplements for anxiety and depression, HIV/AIDS, Diabetes, Epilepsy, Blood, Cancer, HPV, ALS, herpes etc. Email: oyaguherbalhome@gmail.com or visit his website https://oyaguspellcaster.wixsite.com/oyaguherbalhome Or Cell Whatsapp Number +2348101755322 thank you

14. I'm so excited to share my testimonies about the Good Work of Dr odoma who cured my HIV/AIDS with his herbs, I never thought that I would live on earth before the year runs out. I have been suffering from a deadly disease (HIV) for the past (2)years now; I have spent a lot of money going from one Hospital to another looking for ways to get rid of this disease, the hospital has been my home everyday. Constant checks up have been my hobby not until this fateful day, I was searching
through the internet, I saw a testimony on how Dr Odoma helped someone in curing his HIV disease using his healing
Herbs, quickly I copied his email just to give him a test I spoke to him, he asked me to a preparation for the herbs items, of which I did exactly what he instructed me to do, he told me that he is going to provide the herbal cure to me, which he
did, few days after i went back to the same hospital that previously confirmed me as HIV/AIDS positive and this time the result declared me negative to the deadly disease of HIV/AIDS....so I decided to share my testimony, that nothing is impossible with God, God use a man to healed me. No matter what you are passing through, no matter how deadly the sickness is and no matter what the situation is, God that did mine is still going to do yours, suffering from AIDS, ALS, asthma.. Cancer, any kind of disease, you can reach him now via ? Gmail address: (DR odomasolutionhome20@gmail. com) WhatsApp number (+2348100649947)

15. Greatest thanks to Dr Oyagu for his herbal medicine that he prepared for me and when I start using it in just 2weeks I was completely cured and that ended my HERPES SIMPLEX 1&2 DISEASE i am so happy and grateful to Dr Oyagu . after reading about him on a testimony of Jason Cash on a blogger. I knew suddenly Dr Oyagu was the right Doctor to cure my HERPES SIMPLEX 1&2 DISEASE. I discuss with Dr Oyagu and he prepared a herbal medicine for me and when it got sent to me in south Korean . I used the herbal medicine in 2weeks and i went for check up again. after 15years of suffering from HERPES SIMPLEX 1&2 at last i am smiling once again. Dr Oyagu also has remedy to others disease like COLD SORES,HIV/AIDS,DIABETES.CANCER,HIGH BLOOD PRESSURE AND MANY MORE. I oblige everyone to contact this powerful herbalist Dr Oyagu and be free from your suffering. contact his WhatsApp line: +2348101755322 or visit his Website https://oyaguspellcaster.wixsite.com/oyaguherbalhome Email:Oyaguherbalhome@gmail.com

16. I got diagnose of herpes virus last year, and i was taking some drugs prescribed for me by my family doc the drugs could not work and the herpes in my system was very terrifying that i was so depressed the good news is that i never gave up in searching for natural cure for herpes virus ,cause i believe so much in herbal medication.. One faithful morning i read a comment from a lady called Destiny Hudson on how she was cured with natural herbs made by DR.OYAGU from somewhere is West Africa, i immediately copied out his contact email via oyaguherbalhome@gmail.com and explain all my herpes problem to him via his email. the big truth is that it took just two week for his herbal medication to cure me completely without side affect. Till date am herpes virus free and all thanks to Dr OYAGU for his good deeds for me, Once again am very happy to share this great testimony of DR OYAGU cure hurry up now and contact him via his email address (oyaguherbalhome@gmail.com Call & WhatsApp him on (+2348101755322 ) and see what he can do

17. Life is always beautiful when you have good health.i have be in pain for almost 1 year had HSV 1&2 and I was lonely and sad, luckily I was directed to a very kind and Great Dr Oliha who helped me cure my HSV 1&2 and today I am free from the virus and very healthy thank you so much Dr Oliha .Email
oliha.miraclemedicine@gmail.com
you can also whatsapp/Call him; +2349038382931