PC Review


Reply
Thread Tools Rate Thread

Correlation-Coefficient

 
 
daniel chen
Guest
Posts: n/a
 
      30th Jan 2006
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 With Quote
 
 
 
 
=?Utf-8?B?SmVycnkgVy4gTGV3aXM=?=
Guest
Posts: n/a
 
      30th Jan 2006
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 With Quote
 
daniel chen
Guest
Posts: n/a
 
      31st Jan 2006
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" <post_a_reply@no_e-mail.com> wrote in message
news:39D4E6F7-9050-4E7F-A4A1-(E-Mail Removed)...
> 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 With Quote
 
daniel chen
Guest
Posts: n/a
 
      31st Jan 2006
Hi Jerry,
You answered my question. Thanks

"Jerry W. Lewis" <post_a_reply@no_e-mail.com> wrote in message
news:39D4E6F7-9050-4E7F-A4A1-(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
spearman correlation coefficient =?Utf-8?B?TWFyY2VsIExhYm9udMOp?= Microsoft Excel Misc 1 12th May 2005 04:00 AM
Correlation Coefficient Issue Diane Microsoft Excel Worksheet Functions 8 17th Dec 2004 03:48 AM
Correlation coefficient (r) Phil C Microsoft Excel Charting 3 14th Aug 2004 04:27 AM
Correlation coefficient for log plot.. Phil C Microsoft Excel Charting 2 6th Aug 2004 08:34 AM
correlation coefficient when I have totals for each data pair =?Utf-8?B?ZGFu?= Microsoft Excel Misc 1 15th Mar 2004 05:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:34 PM.