Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
daniel chen
 
Posts: n/a
Default Correlation-Coefficient

The following macro is to find the Linear Correlation-Coefficient
of a selected range. I'd like to use a Selection "Rng" instead of
a fixed range "C2:C11"
Can it be done?

Sub RSQ()
Dim Rng As Variant
Rng = Selection
Range("G10") = "= RSQ(C2:C11,ROW(C2:C11))": _
Range("G10") = Range("G10").Value
' I want to replace C2:C11 with Rng in the line above
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.misc
Jerry W. Lewis
 
Posts: n/a
Default Correlation-Coefficient

Sub RSQ()
Dim Rng As Variant
Rng = Selection
Range("G10").FormulaArray = "= RSQ(" & Selection.Address & ",ROW(" &
Selection.Address & "))": _
Range("G10") = Range("G10").Value
' I want to replace C2:C11 with Rng in the line above
End Sub

Your terminology is not exactly correct. RSQ is the square of the
correlation coefficient. Also, in Excel versions prior to 2003, CORREL()^2
is numerically better
than RSQ().

Jerry

"daniel chen" wrote:

The following macro is to find the Linear Correlation-Coefficient
of a selected range. I'd like to use a Selection "Rng" instead of
a fixed range "C2:C11"
Can it be done?

Sub RSQ()
Dim Rng As Variant
Rng = Selection
Range("G10") = "= RSQ(C2:C11,ROW(C2:C11))": _
Range("G10") = Range("G10").Value
' I want to replace C2:C11 with Rng in the line above
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.misc
daniel chen
 
Posts: n/a
Default Correlation-Coefficient

You are correct. I should use
Range("G10") = "=G10^0.5": Range("G10") = Range("G10").Value
How do I replace C2:C11 with Rng

"Jerry W. Lewis" wrote in message
...
Sub RSQ()
Dim Rng As Variant
Rng = Selection
Range("G10").FormulaArray = "= RSQ(" & Selection.Address & ",ROW(" &
Selection.Address & "))": _
Range("G10") = Range("G10").Value
' I want to replace C2:C11 with Rng in the line above
End Sub

Your terminology is not exactly correct. RSQ is the square of the
correlation coefficient. Also, in Excel versions prior to 2003,
CORREL()^2
is numerically better
than RSQ().

Jerry

"daniel chen" wrote:

The following macro is to find the Linear Correlation-Coefficient
of a selected range. I'd like to use a Selection "Rng" instead of
a fixed range "C2:C11"
Can it be done?

Sub RSQ()
Dim Rng As Variant
Rng = Selection
Range("G10") = "= RSQ(C2:C11,ROW(C2:C11))": _
Range("G10") = Range("G10").Value
' I want to replace C2:C11 with Rng in the line above
End Sub





  #4   Report Post  
Posted to microsoft.public.excel.misc
daniel chen
 
Posts: n/a
Default Correlation-Coefficient

Hi Jerry,
You answered my question. Thanks

"Jerry W. Lewis" wrote in message
...
Sub RSQ()
Dim Rng As Variant
Rng = Selection
Range("G10").FormulaArray = "= RSQ(" & Selection.Address & ",ROW(" &
Selection.Address & "))": _
Range("G10") = Range("G10").Value
' I want to replace C2:C11 with Rng in the line above
End Sub

Your terminology is not exactly correct. RSQ is the square of the
correlation coefficient. Also, in Excel versions prior to 2003,
CORREL()^2
is numerically better
than RSQ().

Jerry

"daniel chen" wrote:

The following macro is to find the Linear Correlation-Coefficient
of a selected range. I'd like to use a Selection "Rng" instead of
a fixed range "C2:C11"
Can it be done?

Sub RSQ()
Dim Rng As Variant
Rng = Selection
Range("G10") = "= RSQ(C2:C11,ROW(C2:C11))": _
Range("G10") = Range("G10").Value
' I want to replace C2:C11 with Rng in the line above
End Sub





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Correlation Tables -- Setup Zeelotes Excel Worksheet Functions 12 October 18th 05 10:37 AM
spearman correlation coefficient Marcel Labonté Excel Discussion (Misc queries) 1 May 12th 05 04:00 AM
How do I use the "Correlation" dialog box with multiple ranges? Paulf6 Excel Discussion (Misc queries) 1 April 4th 05 09:14 PM
Correlation matrix Peppino Excel Worksheet Functions 1 March 10th 05 01:32 PM
Correlation Coefficient Issue Diane Excel Worksheet Functions 8 December 17th 04 03:48 AM


All times are GMT +1. The time now is 07:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"