Function to Move Correl over one column at a time

N

Number_Cruncher

I'm tring to set up a correlation matrix where a table contains the
same headings in both the x and y axis. I then use this formula to
find the correlation:

=CORREL($B$2:$B$253,B$2:B$253)

This returns 1 since it is the correlation of itself. The next column
over produces this formula:

=CORREL($B$2:$B$253,C$2:C$253)

What is the best way to write a formula that does not require me to
manually switch the B to a C for each and every row --- over 300 of
them.

=CORREL($C$2:$C$253,C$2:C$253)

Thanks for any help you can offer.
 
D

David Biddulph

I suggest that you look at Excel help for absolute and relative addressing,
so that you understand the meaning of the $ signs in your formula.
 
N

Number_Cruncher

I suggest that you look at Excel help for absolute and relative
addressing,
so that you understand the meaning of the $ signs in your formula.
-
David Biddulph

The formula that I've written works perfectly to copy from column B
over to column CX or however far the matrix goes. The problem is that
I need a way so that I do not have to change the B to C to D, etc,
when I move down one row. I'm trying to use this formula but am not
getting it right:

=CORREL(OFFSET($B$2,0,SUM(ROW()-CELL("Row",$B$253)),$A$264),OFFSET($B
$2,0,SUM(COLUMN()-CELL("Col",$B$253)),$A$264))

As to reading the help file --- I did that first, and when that
failed, I came looking for help. I certainly appreciate the fact that
for those with more expeience this is easy to do.
 
N

Number_Cruncher

I got it via a search of this group:

=CORREL(INDEX($B$2:$CX$253,0,MATCH($A257,$B$1:$CX$1,0)),INDEX($B$2:$CX
$253,0,MATCH(B$256,$B$1:$CX$1,0)))
 
D

David Biddulph

Perhaps you need to explain more clearly what you are trying to do.
In which cell do you have your original =CORREL($B$2:$B$253,B$2:B$253)
formula?
What do you want to do to that when you go across one column?
What do you want to do to the original formula when you go down one row?
OFFSET may be the right answer, but if you explain what you're looking for
we can probably help.
 
M

Mike Middleton

Number_Cruncher -

As an aside, since you're replicating the results of the Correlation tool in
Excel's Analysis ToolPak, I checked in Excel 2007 to see if it could handle
"over 300 of them," just in case you were referring to the number of
variables instead of the number of values for each variable. I can report
that the Correlation tool of the Excel 2007 Analysis ToolPak will produce
pairwise correlations for 301 variables.

- Mike
http://www.mikemiddleton.com
 
N

Number_Cruncher

Again, I searched this forum and found the exact answer to my question
which is the formula:

=CORREL(INDEX($B$2:$CX$253,0,MATCH($A257,$B$1:$CX$1,0)),INDEX($B
$2:$CX
$253,0,MATCH(B$256,$B$1:$CX$1,0)))

For those wanting to produce a correlation matrix manually the above
will do it perfectly.

Thanks anyway!
 
D

David Biddulph

I'm interested as to what you've got in the extra cells you didn't mention
earlier, such as A257, B256, and column 1. I guess that these are your row
and column labels?
Your original question was about moving references across one column at a
time, but you didn't clarify what you wanted moving where. IYou were trying
to use OFFSET, and I said that I thought it ought to do the trick.

Perhaps I can try to guess what you're aiming for?

If B257 is the cell where you've got
=CORREL($B$2:$B$253,B$2:B$253)
you've found that if you copy that to C257 you get
=CORREL($B$2:$B$253,C$2:C$253)
and then in D257 you get
=CORREL($B$2:$B$253,D$2:D$253)

I'm now guessing that what you may have been trying to ask for was how to go
down to cell B258 and get
=CORREL($C$2:$C$253,B$2:B$253) , and so on downwards, trying to increment
the *column* reference in the first part of your formula as you increased
the *row* in which your formula was sitting.

In that case, then I think you were right trying to use OFFSET, and what you
needed may have been something like
=CORREL(OFFSET($B$2,0,ROW()-ROW($B$257),252,1),B$2:B$253), but for some
reason I get a #N/A from that, though I get the right answer if I replace
ROW()-ROW($B$257) by zero.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top