Using R
, I am replicating the Table 1 results of this paper https://www.tandfonline.com/doi/abs/10.1080/03610926.2014.985841. I wrote the following r function
However, my output deviates significantly. Please see the equation below. I considered sample size n = 5
and generated from rnorm(n, 0,1)
. Please see my r codes
below. Could you please provide a hint to me? Thanks
rm(list = ls())
cvalue = function(n, alpha) {
rep = 1000 # number of repetitions
stat = NULL
for (i in 1:rep) {
e1 = rnorm(n, 0, 1) # standard Brownian motion 1
e2 = rnorm(n, 0, 1) # standard Brownian motion 2
for(j in 1:n){
t = j ; s = j-1 # t <= s
W1 = cumsum(e1)[1:s] # Z(s)
W2 = cumsum(e2)[1:t] # Z(t)
W12 = exp(-t) * exp(-s) # find exp(-t) * exp(-s)
}
stat = c(stat, max(W12*(W1- W2))) # line above eq (19) and get sup of that
}
critical = quantile(stat, 1 - alpha) # find the (1-alpha) quantile
return(critical)
}
cvalue(5,0.05)