MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 31st, 2003, 09:18 AM   #1
dodgymanc
New Member
 
Join Date: Mar 2003
Location: Manchester
Posts: 4
Default Spearmans Rank

Is there a formula or function on Excel that allows me to calculate Spearmans Rank Correlation Coefficient?
dodgymanc is offline   Reply With Quote
Old Mar 31st, 2003, 10:22 AM   #2
barkley
Board Regular
 
barkley's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 148
Default

Not too hot on the old Statistics front, was not my best module at Uni But you'll probably know more about the following excerpt than me:
"
Pearson or Spearman correlation?
If you choose correlation, choose between standard (Pearson) correlation and nonparametric (Spearman) correlation. Pearson correlation calculations are based on the assumption that both X and Y values are sampled from populations that follow a Gaussian distribution, at least approximately. With large samples, this assumption is not too important. If you don't wish to make the Gaussian assumption, select nonparametric (Spearman) correlation instead. Spearman correlation is based on ranking the two variables, and so makes no assumption about the distribution of the values.
"
http://www.graphpad.com/instatman/Pe...rrelation_.htm

So have a look at the PEARSON function in Excel and see if that can be of any use to you.
barkley is offline   Reply With Quote
Old Mar 31st, 2003, 12:50 PM   #3
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,207
Default

******** ******************** ************************************************************************>
Microsoft Excel - Spearman Rank Correlation Coefficient.xls___Running: xl2000 : OS = Windows Windows 2000
(F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)bout
=

A
B
C
D
E
F
G
H
I
J
K
L
1
***Rank*Of**Method*1*Method*2
2
XY*XYdd-squaredN12***
3
15914.4*8711*30*r-squared0.800563873
4
17915.2*7524r-Spearman0.8951049*degrees*of*freedom10
5
10011.3*9.581.52.25***Fs40.14136675
6
452.5*121111***p0.00009
7
38422.7*1100*****
8
23014.9*46-24*****
9
1001.41*9.512-2.56.25*****
10
32015.81*2.53-0.50.25*****
11
804.19*111011*****
12
22015.39*5411*****
13
32017.25*2.520.50.25*****
14
2109.52*69-39*****
statspearman (3)*

[HtmlMaker 2.32] To see the formula in the cells just click on the cells hyperlink or click the Name box
PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.


Formulas are...

D3:

=IF(ISNUMBER(A3),AVERAGE(RANK(A3,$A$3:$A$14),RANK(A3,$A$3:$A$14)+COUNTIF($A$3:$A$14,A3)-1),"")

E3:

=IF(ISNUMBER(Q3),AVERAGE(RANK(B3,$B$3:$B$14),RANK(B3,$B$3:$B$14)+COUNTIF($B$3:$B$14,B3)-1),"")

F3:

=D3-E3

G3:

=F3*F3

I2:

=COUNT(A3:A14)

I3:

=SUM(G3:G14)

I4:

=1-6*I3/(I2^3-I2)

L3:

=RSQ(E3:E14,D3:D14)

L4:

=COUNT(D3:D14)-2

L5:

=L4*(L3/(1-L3))

L6:

=FDIST(L5,1,L4)

For method 1, see Siegel (1956, p. 202) plus

http://www.zephryus.demon.co.uk/geog.../spear.html#n6

and for Method 2, see...

http://udel.edu/~mcdonald/statspearman.html

I believe Method 2 is computationally easier and the formulas involved are insensitive to empty cells in X.
Aladin Akyurek is offline   Reply With Quote
Old Mar 15th, 2008, 10:30 AM   #4
jexcel3
Board Regular
 
Join Date: Nov 2007
Posts: 153
Default Spearmans Rank

I use the spearman coefficient alot. I wanted to see if it is possilble for me to get help on creating an UDF that do this for me. I have attached this old thread to show what the full formula looks like.

My data source is a little differenct. I already have the ranked data in Column B and C

A1 Column title B1 Rank1 C1 Rank2
A2 XYZ B2 1 C2 3
A3 ABC B3 2 C3 1.5
A4 AAA B4 3 C3 1
etc etc etc

So i wanted to create a UDF in column D and be able filldown the udf and have the Correlation number in Column E. This number would be like the result in cell I4 in the example below. This might be to much for excel to handle..Any thoughts?
jexcel3 is offline   Reply With Quote
Old Mar 15th, 2008, 11:08 AM   #5
jexcel3
Board Regular
 
Join Date: Nov 2007
Posts: 153
Default Re: Spearmans Rank

My data example did not post right.

Column A would be the managers
Column B is the first ranked data series
Column C is the second ranked data series
Column D is the UDF
Cell E2 would be the result

Sorry for the confusion

j
jexcel3 is offline   Reply With Quote
Old Mar 15th, 2008, 11:54 AM   #6
Claymationator
Board Regular
 
Claymationator's Avatar
 
Join Date: Sep 2006
Posts: 685
Default Re: Spearmans Rank

Quote:
Originally Posted by jexcel3 View Post
My data example did not post right.

Column A would be the managers
Column B is the first ranked data series
Column C is the second ranked data series
Column D is the UDF
Cell E2 would be the result

Sorry for the confusion

j
I am not sure if this is quite what you are looking for, but this has an example spreadsheet of how to calculate this with a dataset of up to 1000 observations.

http://udel.edu/~mcdonald/statspearman.xls

This site also has some information explaining the spreadsheet as well as a few other helpful links when calculating the spearman's rank.

http://udel.edu/~mcdonald/statspearman.html

Hope that helps.
__________________
Microsoft Windows 7
Microsoft Office 2007
Claymationator is offline   Reply With Quote
Old Mar 15th, 2008, 12:01 PM   #7
jexcel3
Board Regular
 
Join Date: Nov 2007
Posts: 153
Default Re: Spearmans Rank

thank you !!!!!
jexcel3 is offline   Reply With Quote
Old Mar 15th, 2008, 12:16 PM   #8
Claymationator
Board Regular
 
Claymationator's Avatar
 
Join Date: Sep 2006
Posts: 685
Default Re: Spearmans Rank

Quote:
Originally Posted by jexcel3 View Post
thank you !!!!!
You're welcome, and thanks to Aladin that had posted the link earlier in the thread.

Quote:
and for Method 2, see...

http://udel.edu/~mcdonald/statspearman.html
__________________
Microsoft Windows 7
Microsoft Office 2007
Claymationator is offline   Reply With Quote
Old Mar 21st, 2008, 03:37 PM   #9
jexcel3
Board Regular
 
Join Date: Nov 2007
Posts: 153
Default Re: Spearmans Rank

Aladin,

Your example spreadsheet and formulas are very very very helpful!!!

I have one question. Spearman coef handles the ties by taking the average ie the 4s in the below example (8.5)

Code:
Data	Rank      Frmla
12.45	1	1.0
10.11	2	2.0
8.32	3	3.0
7.45	4	4.0
6.55	5	5.0
5.1	6	6.0
4.3	7	7.0
4	8	8.5
4	8	8.5
2.1	10	10.0
1.22	11	11.0
But when there are 3 fours in the below example, it rounds the rank 8...is that functioning correctly?...i think it is but i wanted to ask ya

Code:
Data 1	Rank	Frmla
12.45	1	1.0
10.11	2	2.0
8.32	3	3.0
7.45	4	4.0
6.55	5	5.0
5.1	6	6.0
4	7	8.0
4	7	8.0
4	7	8.0
2.1	10	10.0
1.22	11	11.0

Last edited by jexcel3; Mar 21st, 2008 at 03:46 PM.
jexcel3 is offline   Reply With Quote
Old Mar 21st, 2008, 05:18 PM   #10
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,207
Default Re: Spearmans Rank

Quote:
Originally Posted by jexcel3 View Post
Aladin,

Your example spreadsheet and formulas are very very very helpful!!!

I have one question. Spearman coef handles the ties by taking the average ie the 4s in the below example (8.5)

Code:
Data    Rank      Frmla
12.45    1    1.0
10.11    2    2.0
8.32    3    3.0
7.45    4    4.0
6.55    5    5.0
5.1    6    6.0
4.3    7    7.0
4    8    8.5
4    8    8.5
2.1    10    10.0
1.22    11    11.0
But when there are 3 fours in the below example, it rounds the rank 8...is that functioning correctly?...i think it is but i wanted to ask ya

Code:
Data 1    Rank    Frmla
12.45    1    1.0
10.11    2    2.0
8.32    3    3.0
7.45    4    4.0
6.55    5    5.0
5.1    6    6.0
4    7    8.0
4    7    8.0
4    7    8.0
2.1    10    10.0
1.22    11    11.0
Yes...

In the first situation, the consecutive rankings for 4 would be: 8 and 9 with average(8,9) yielding 8.5.

In the 2nd situtation, the consecutive rankings for 4 would be: 7, 8, and 9, with average(7,8,9) yielding 8.
Aladin Akyurek is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 01:04 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2011 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes