I am using the ks.benftest from the BenfordTests package in R to calculate the D Statistic and p-value of a distribution with respect to a distribution that conforms with Benford Law. The problem I have is that the ks.benftest function gives me a different result from just using function ks.test.
The code I used for both functions with the data is below:
x <- c(rep(1,10),rep(2,5),rep(3,3),rep(4,5),rep(5,6),7)
y <- c(rep(1,9),rep(2,5),rep(3,4),rep(4,3),rep(5,3),rep(6,2),rep(7,2),8,9)
x variable is the distribution I want to confirm follows benford distribution; y variable follows the benford distribution
z<- as.data.frame(t(rbind(x,y)))
pval_bftest <- ks.benftest(z$x,digits=1)$p.value
Dstat_bftest <- ks.benftest(z$x,digits=1)$statistic
pval_bftest = 0.1001
Dstat_bftest = 1.032541
However, when I use the ks.test function, I get very different results
ksTest <- ks.test(z$x,z$y,alternative=c("two.sided"))
ksTest
Two-sample Kolmogorov-Smirnov test
data: z$x and z$y
D = 0.16667, p-value = 0.799
alternative hypothesis: two-sided
Does anyone know what I'm doing wrong? I should get similar results, but I'm not.
Thanks
T