Adding fweights and aweights to numpy.corrcoef

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding fweights and aweights to numpy.corrcoef

Corin Hoad
Hello,

Would it be possible to add the fweights and aweights keyword arguments from np.cov to np.corrcoef? They would retain their meaning from np.cov as frequency- or importance-based weightings respectively.

Yours,
Corin Hoad

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Adding fweights and aweights to numpy.corrcoef

Sebastian Berg
I seem to recall that there was a discussion on this and it was a lot
trickier then expected.
I think statsmodels might have options in this direction.

- Sebastian


On Thu, 2018-04-26 at 15:44 +0000, Corin Hoad wrote:

> Hello,
>
> Would it be possible to add the fweights and aweights keyword
> arguments from np.cov to np.corrcoef? They would retain their meaning
> from np.cov as frequency- or importance-based weightings
> respectively.
>
> Yours,
> Corin Hoad
> _______________________________________________
> NumPy-Discussion mailing list
> [hidden email]
> https://mail.python.org/mailman/listinfo/numpy-discussion
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Adding fweights and aweights to numpy.corrcoef

josef.pktd


On Thu, Apr 26, 2018 at 11:59 AM, Sebastian Berg <[hidden email]> wrote:
I seem to recall that there was a discussion on this and it was a lot
trickier then expected.

But given that numpy has the weights already for cov, then I don't see any additional issues
whith adding it also to corrcoef.

corrcoef is just rescaling the cov, so there is nothing special to add except that corrcoef hands off the options to cov.

 
I think statsmodels might have options in this direction.

statsmodels still has only fweights (case weights) for covariance and correlation

Josef
 
- Sebastian


On Thu, 2018-04-26 at 15:44 +0000, Corin Hoad wrote:
> Hello,
>
> Would it be possible to add the fweights and aweights keyword
> arguments from np.cov to np.corrcoef? They would retain their meaning
> from np.cov as frequency- or importance-based weightings
> respectively.
>
> Yours,
> Corin Hoad
> _______________________________________________
> NumPy-Discussion mailing list
> [hidden email]
> https://mail.python.org/mailman/listinfo/numpy-discussion
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion



_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Adding fweights and aweights to numpy.corrcoef

Corin Hoad
I seem to recall that there was a discussion on this and it was a lot
trickier then expected.

But given that numpy has the weights already for cov, then I don't see any additional issues
whith adding it also to corrcoef.
 
corrcoef is just rescaling the cov, so there is nothing special to add except that corrcoef hands off the options to cov.

This was my understanding. I am currently just using my own copy of corrcoef which forwards the aweights and fweights arguments directly to np.cov. Is this the correct approach?

Corin Hoad

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Adding fweights and aweights to numpy.corrcoef

Corin Hoad
Are there any further thoughts on this? If it's simply allowing corrcoef to hand off the keyword arguments to cov I can make a simple PR with the change.

Corin Hoad

On Fri, 27 Apr 2018 at 10:44 Corin Hoad <[hidden email]> wrote:
I seem to recall that there was a discussion on this and it was a lot
trickier then expected.

But given that numpy has the weights already for cov, then I don't see any additional issues
whith adding it also to corrcoef.
 
corrcoef is just rescaling the cov, so there is nothing special to add except that corrcoef hands off the options to cov.

This was my understanding. I am currently just using my own copy of corrcoef which forwards the aweights and fweights arguments directly to np.cov. Is this the correct approach?

Corin Hoad

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Adding fweights and aweights to numpy.corrcoef

josef.pktd


On Fri, May 11, 2018 at 7:43 AM, Corin Hoad <[hidden email]> wrote:
Are there any further thoughts on this? If it's simply allowing corrcoef to hand off the keyword arguments to cov I can make a simple PR with the change.

No further thoughts from my side. I don't see a problem.

Aside: And the degrees of freedom correction, which was one of the ambiguous issues in the cov case, will not matter in the corrcoef case because it cancels in the latter.

Josef

 


Corin Hoad

On Fri, 27 Apr 2018 at 10:44 Corin Hoad <[hidden email]> wrote:
I seem to recall that there was a discussion on this and it was a lot
trickier then expected.

But given that numpy has the weights already for cov, then I don't see any additional issues
whith adding it also to corrcoef.
 
corrcoef is just rescaling the cov, so there is nothing special to add except that corrcoef hands off the options to cov.

This was my understanding. I am currently just using my own copy of corrcoef which forwards the aweights and fweights arguments directly to np.cov. Is this the correct approach?

Corin Hoad

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion



_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Adding fweights and aweights to numpy.corrcoef

Corin Hoad
The discussed changes are implemented in PR #11078

Corin

On Fri, 11 May 2018 at 15:07 <[hidden email]> wrote:
On Fri, May 11, 2018 at 7:43 AM, Corin Hoad <[hidden email]> wrote:
Are there any further thoughts on this? If it's simply allowing corrcoef to hand off the keyword arguments to cov I can make a simple PR with the change.

No further thoughts from my side. I don't see a problem.

Aside: And the degrees of freedom correction, which was one of the ambiguous issues in the cov case, will not matter in the corrcoef case because it cancels in the latter.

Josef

 


Corin Hoad

On Fri, 27 Apr 2018 at 10:44 Corin Hoad <[hidden email]> wrote:
I seem to recall that there was a discussion on this and it was a lot
trickier then expected.

But given that numpy has the weights already for cov, then I don't see any additional issues
whith adding it also to corrcoef.
 
corrcoef is just rescaling the cov, so there is nothing special to add except that corrcoef hands off the options to cov.

This was my understanding. I am currently just using my own copy of corrcoef which forwards the aweights and fweights arguments directly to np.cov. Is this the correct approach?

Corin Hoad

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion