##### R-code for computing rho_L values in Table 5.4. # This code searches the rho value of the downward EWMA chart for detecting # process variance shifts such that a pre-specified ARL0 value is reached. # Inputs # la --- lambda value (i.e., the weighting parameter) # rho --- the critical value chosen such that the pre-specified # ARL0 value is reached. arl0 = function(la,rho){ set.seed(100) rep=10000 # number of replicated simulations N=2000 # the longest length of the observation sequence AARL0=0 # AARL0 denotes the actual ARL0 value num=0 # count of simulations with OC signals L=1-rho*sqrt(2*la/(2-la)) for(j in 1:rep){ # the j-th replicated simulation x=rep(0,N) # the observation sequence en=rep(0,N) # the EWMA charting statistic x = rnorm(N) # generate N(0,1) observations en[1]=la*x[1]^2+(1-la)*1 if(en[1]= ARL0){ print("rhoL is too large") } A0=arl0(la,rhoU) if(A0 <= ARL0){ print("rhoU is too small") } for(i in 1:100){ print(i) rhot = (rhoL+rhoU)/2 A0 = arl0(la,rhot) if(abs(A0-ARL0) <= eps1 | abs(rhoU-rhot) <= eps2){ break } if(A0 < ARL0){ rhoL=rhot } if(A0 > ARL0){ rhoU=rhot } } ##### # After running this code, in R, just type # > rhot # obtain the searched rho value # > A0 # find the actual ARL_0 value