Dingo
Dingo

Reputation: 113

IndexError: tuple index out of range using Partial Correlation function

I'm using the partial correlation function developed by Fabian Pedregosa-Izquierdo (a MatLab copy of parrcor).

However, I'm trying to apply it to my data I keep getting the following error:

 Traceback (most recent call last):
File "atd.py", line 280, in <module>
partialcorr = partial_corr(values_outliers)
File "/Users/dingo/Desktop/ATD/MiniProjATD/partial_corr.py", line 50, in partial_corr
p = C.shape[1]
IndexError: tuple index out of range

My values_outliers is an np.array as follows: https://pastebin.com/AHhwmpTg

The implementation of the partial correlation code can be found here: https://gist.github.com/fabianp/9396204419c7b638d38f

Thank you very much!

Upvotes: 0

Views: 91

Answers (1)

Ryan Walker
Ryan Walker

Reputation: 3286

The function you posted expects to receive an n x m matrix as an argument. You are passing it an array of length n. To get your data into the right shape, you can do something like:

my_data = [1.234, 5.6789, -32.101]
C = np.array(my_data).reshape((-1,1))
partial_corr(C)

The (-1,1) argument to reshape says to put all the data in the first column of n x 1 array.

Upvotes: 1

Related Questions