Dear R-helpers,
I was testing the truncgof CRAN package, found something that looked
like a bug, and did my job: contacted the maintainer. But he did not
reply, so I am resending my query here.
I installed package truncgof and run the example for function ad.test. I
got the following output:
set.seed(123)
treshold <- 10
xc <- rlnorm(100, 2, 2) # complete sample
xt <- xc[xc >= treshold] # left truncated sample
ad.test(xt, "plnorm", list(meanlog = 2, sdlog = 2), H = 10)
Supremum Class Anderson-Darling Test
data: xt
AD = 3.124, p-value = 0.12
alternative hypothesis: two.sided
treshold = 10, simulations: 100
So I cannot reject the hipothesis (at a standard confidence level) that
the original sample comes from a lognormal distribution (as it is the
case).
But let us try to iterate on this example:
set.seed( 123 )
treshold <- 10
foo <- function(){
xc <- rlnorm(100, 2, 2) # complete sample
xt <- xc[xc >= treshold] # left truncated sample
ks.test(xt, "plnorm", list(meanlog = 2, sdlog = 2), H =
10)$p.value
}
results <- replicate( 100, foo() )
Then:
results
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.16 0.18
0.19 0.2
25 7 9 3 1 2 3 4 1 1 2 2 1 1
3 2
0.21 0.22 0.26 0.27 0.28 0.3 0.31 0.32 0.33 0.36 0.38 0.4 0.44 0.49
0.54 0.55
2 2 1 3 1 2 1 1 1 2 1 2 1 1
2 1
0.56 0.57 0.62 0.7 0.76 0.78 0.96 0.98
1 2 1 1 1 1 1 1
This is, in a 45% of the cases, you would reject the H_0 hypothesis,
which happens to be true, at the 5% "standard" confidence level.