Reputation: 149
I was trying to run some entropy()
calculations on Force Platform data and i get a warning message:
> library(entropy)
> d2 <- read.csv("c:/users/SLA9DI/Documents/data2.csv")
> entropy(d2$CoPy, method="MM")
[1] 10.98084
> entropy(d2$CoPx, method="MM")
[1] 391.2395
Warning message:
In log(freqs) : NaNs produced
I am sure it is because the entropy()
is trying to take the log of a negative number. I also know R can do complex numbers using complex()
, however i have not been successful in getting it to work with my data. I did not get this error on my CoPy data, only the CoPx data, since a force platform gets Center of Pressure data in 2 dimensions. Does anyone have any suggestions on getting complex()
to work on my data set or is there another function that would work better to try and get a proper entropy calculation? Entropy shouldn't be that much greater in CoPx compared to CoPy. I also tried it with some more data sets from other subjects and the same thing was popping up, CoPx entropy measures were giving me warning messages and CoPy measurements were not. I am attaching a data set link so anyone can try it out for themselves and see if they can figure it out, as the data is a little long to just post into here.
Edit: Correct Answer
As suggested, i tried the table(...)
function and received no warning/error message and the entropy output was also in the expected range as well. However, i apparently overlooked a function in the package discretize()
and that is what you are supposed to use to correctly setup the data for entropy calculation.
Upvotes: 1
Views: 1402
Reputation: 25454
I think there's no point in applying the entropy
function on your data. According to ?entropy
, it
estimates the Shannon entropy H of the random variable Y from the corresponding observed counts y
(emphasis mine). This means that you need to convert your data (which seems to be continuous) to count data first, for instance by binning it.
Upvotes: 3