I want to use the function to calculate the arl of cusum however I meet a problem when I run the code it shows "Error in if (r[i] > h1) break : missing value where TRUE/FALSE needed" to me. I don't know how to write the correct code
myfun2<-function(c1,h1){
r=rep(0,500)
for (i in 1:499){
r[i+1]<-max(0,c1[i]+0.85*r[i])
(arl<-i)
if(r[i]>h1) break
}
result<-arl
}
m=sapply(c,h=0.1865,myfun2)