I have a xts dataset data.price which is the daily share prices of 163 companies.
the data set has 163 columns and 1826 rows.
I want to take the log daily return of the share price and I am using the following code:
A<-log(data.price)
data.return <- diff(A)/A[-length(A)]
but I noticed that there are many 0 values that are disrupting the output.
So I was thinking to solve the problem by adding a small number to the 0 values.
diff(A)<- ifelse(diff(A) == 0, diff(A)+0.0000001,diff(A))
The problem is when I am applying this code my Rstudio is crushing and I need to restart the session.
I tried to take a smaller amount of data, A<-A[1:100,] and applied the same code and it worked without any problems.
Where could be the problem?
Aucun commentaire:
Enregistrer un commentaire