NAs in cor() function

474 Views Asked by At

I'm trying to calculate the Pearson correlation for my data. So far I successfuly did it for daily and hourly returns, however I'm struggeling with Minuten returns.

This is what I did:

cor_df_min <- merge(usdt_min_return_cor, pax_min_return_cor, dgx_min_return_cor, btc_min_return_cor)
cor_df_min


Correlation_matrix_min = cor(cor_df_min, use = "pairwise.complete.obs")
print(Correlation_matrix_min)

But I still have NAs in my correlation matrix as you can see below:

             ClosePrice ClosePrice.1 ClosePrice.2 ClosePrice.3
 ClosePrice   1.00000000   0.02417688           NA   0.01711407
 ClosePrice.1 0.02417688   1.00000000   0.03966081  -0.20275678
 ClosePrice.2         NA   0.03966081   1.00000000           NA
 ClosePrice.3 0.01711407  -0.20275678           NA   1.00000000

Note: I have quite a few missing values and values very close or equal to zero in my data. Is that the problem? How can I fix it?

0

There are 0 best solutions below