The random variable Y is said to have a two-parameter APE distribution denoted by APE(α, λ), with the shape and scale parameters as α > 0 and λ > 0, respectively, if the PDF of Y for y > 0 is
f(y; α, λ) = (log α /α−1 )λe^(−λy)α^(1−e^(−λy)) ,if α = 1
= λe^(−λy) ,if α = 1
= 0,otherwise
The CDF of Y for y > 0 becomes
F(y; α, λ) = [α^(1−e^(−λy))−1] /(α−1), if α = 1
= 1 − e^(−λy),if α = 1
y=1 4 4 7 11 13 15 15 17 18 19 19 20 20 22 23 28 29 31 32 36 37 47 48 49 50 54 54 55 59 59 61 61
66 72 72 75 78 78 81 93 96 99 108 113 114 120 120 120 123 124 129 131 137 145 151 156 171
176 182 188 189 195 203 208 215 217 217 217 224 228 233 255 271 275 275 275 286 291 312
312 312 315 326 326 329 330 336 338 345 348 354 361 364 369 378 390 457 467 498 517 566
644 745 871 1312 1357 1613 1630.
n=109
alpha estimated =0.00366583
lambda estimated =0.0009550325
When I tried coding this using R, I first found the cdf; #CDF OF APE
cdf <- function(alpha,lambda){
if(alpha!=1){
apecdf<-((alpha^(1-exp(-lambda*y)))-1)/ (alpha-1)}else if(alpha==1){
apecdf<- 1-(exp(-lambda*y))}
return(apecdf)
}
#k-s test statistic and p-Value for APE
t <- ks.test(y,cdf(0.00366583,0.0009550325),shape=0.00366583,scale=0.0009550325)
t
RESULT:
Two-sample Kolmogorov-Smirnov test
data: y and cdf(0.00366583, 0.0009550325)
D = 1, p-value < 2.2e-16
alternative hypothesis: two-sided
What am I doing wrong here?
I need to get the ks-statistic= 0.0742, p-value=0.5852 (somewhat near these)
ks.testexpressly assumes the reference distribution you supply was determined independently of the data rather than estimated from the data. The estimation process makes it (far) more likely that the data will look close to the distribution. – whuber Jul 15 '20 at 12:40ks.testto use a self written cdf for the purpose of a one sample test. – Tim-TU Jul 15 '20 at 16:46ks.testworks by demonstrating why and how the warning "ties should not be present for the Kolmogorov-Smirnov test" was returned.However,
– Tim-TU Jul 16 '20 at 04:16Second, the question is edited so that the given parameters are the maximum likelihood estimates of the sample and then my answer is completely wrong and I will delete it immediately. – Tim-TU Jul 16 '20 at 04:23