2

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 enter image description here

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)
score324
  • 325
  • 2
  • 10
  • I am having difficulties ascertaining how your code implements anything in the foregoing equations. Could you supply your explanations of what you think the code is doing, line by line? – whuber Mar 15 '21 at 16:56
  • @whuber I have added line-by-line descriptions. – score324 Mar 15 '21 at 17:26
  • Thank you. But (1) why do you use the line preceding (19) rather than (19) itself; (2) where do you obtain the *double* suprema; and (3) why doesn't your computation of $Z$ agree with its formula in terms of $W$? – whuber Mar 15 '21 at 18:26
  • @whuber, first, I used the line preceding (19) which is easier to simulate. Second question, we always have `t >=s >=0`. Thus, I took the suprema only once. To answer the last question, `Z(t) = W(t)/e^{-t)`. I thought that `Z(t)` is the standard Wiener process. Therefore, I simply generated from the standard normal distribution. Is that correct? – score324 Mar 15 '21 at 19:05
  • @whuber, first, I used the line preceding (19) which is easier to simulate. Also, we can write in terms of `Z(t)`. That is , `sup sup e(-t)e(-s)(Z(s) - Z(t))`. – score324 Mar 15 '21 at 19:13
  • The line preceding (19) is algebraically identical to 19, just a bit more complicated. Your second response looks circular, because what you call "Z" in the comments is represented by the variables `W1` and `W2`. This might be the crux of your problem. How are you interpreting the expression "$W(e^{-t})/e^{-t}$"? The meaning is unclear because you haven't included the definitions or much context, but it would seem that "$W(e^{-t})$" is intended to be the value of a standard Brownian motion at "time" $e^{-t}.$ – whuber Mar 15 '21 at 19:54

0 Answers0