'R ecdf function gives only 0 or 1 values

my dataset consists of stock prices. My final goal is to fit for practice a copula to two stocks.

However, while trying to transform my data to a [0,1] scale with the ecdf function, I get a weird ecdf-plot for one stock. enter image description here

The function works fine for the other stock. enter image description here

I searched for dissimilarities in the data set, but both variables don't have missing values and consist only of numbers in string format.

The code:

DFM.roh <- read.xlsx("C:\\Users\\Simon\\Documents\\ML Seminar\\Deutscher Finanzmarkt Daten.xlsx")
DFM <- data.frame(X_bei = DFM.roh$s_bei, X_bayn = DFM.roh$s_bayn)

y_a <- ecdf(DFM$X_bei)(DFM$X_bei)
ecdfs_a <- sort(y_a, decreasing = FALSE)
plot(ecdfs_a)

y_b <- ecdf(DFM$X_bayn)(DFM$X_bayn)
ecdfs_b <- sort(y_b, decreasing = FALSE)
plot(ecdfs_b)

Data sample in R: enter image description here

Data samle in excel: enter image description here



Solution 1:[1]

Apparently, the problem consisted of 3 digit numbers with two decimal digits (instead of predominantly 4 digit numbers with two decimal digits). After replacing every figure by the equivalent number without strings and decimal digits, it worked.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Simon Lenk