I am trying to modify the code mkTrend.R from 'fume' package to implement Hamed and Rao (1998) variance correction approach.

From the code of mkTrend, the following line is very confusing (Line-29 to Line-34)

Now, Please help me with the following three questions

  • According to literature the auto correlation function is to be calculated from the ranks of observations. In the program. auto correlation is calculated for rank(lm(x ~ I(1:n))$resid) instead of simple rank(x)

acf(rank(lm(x ~ I(1:n))$resid), lag.max=(n-1), plot=FALSE)$acf[-1] -> ro

  • Similarly based on the confidence interval value from normal distribution table, only values that cross the significance bounds are considered.

qnorm((1+ci)/2)/sqrt(n) -> sig

rep(NA,length(ro)) -> rof

for (i in 1:(length(ro))) {

if(ro[i] > sig || ro[i] < -sig) {

rof[i] ro

Similar questions and discussions