On Sat, 27 Mar 2021, Allin Cottrell wrote:
 On Sat, 27 Mar 2021, Periklis Gogas wrote:
> What is the actual algorithm that Gretl uses to estimate the Hurst 
> exponent?
> Is it the Anis-Lloyd corrected R/S or the DFA?
 You can see exactly what gretl is doing in
 
https://sourceforge.net/p/gretl/git/ci/master/tree/plugin/fractals.c
 See hurst_calc() in particular. 
If you find C code hard to read, here's a near-literal Hansl translation:
<hansl>
set verbose off
function scalar get_depth(scalar T)
     return floor(log2(T) - 2)
end function
function scalar cum_range (const matrix x, scalar xbar)
     c = cum(x - xbar)
     return maxc(c) - minc(c)
end function
function matrix hurst_calc (const matrix x, scalar n, scalar depth)
     matrix Z = mshape(NA, depth, 3)
     m = n
     loop i = 1 .. depth
         RS = 0
         nsub = floor(n/m)
         loop j = 1 .. nsub
             ini = 1 + (j-1)*m
             fin = ini + m - 1
             scalar xbar = meanc(x[ini:fin])
             scalar r = cum_range(x[ini:fin], xbar)
             s = sdc(x[ini:fin], 0)
             RS += r / s
         endloop
         RS /= nsub
         Z[i,1] = RS
         Z[i,2] = log2(m)
         Z[i,3] = log2(RS)
         m = floor(m/2)
     endloop
     return Z
end function
### test with simulated data
nulldata 300
set seed 123
series x = normal()
depth = get_depth($nobs)
Z = hurst_calc({x}, $nobs, depth)
print Z
gnuplot 3 2 --matrix=Z --output=display
V = {}
b = mols(Z[,3], 1 ~ Z[,2], null, &V)
cs = b[2] ~ sqrt(diag(V)[2])
modprint cs "Hurst"
# compare with native
hurst x --plot=display
</hansl>
-------------------------------------------------------
   Riccardo (Jack) Lucchetti
   Dipartimento di Scienze Economiche e Sociali (DiSES)
   Università Politecnica delle Marche
   (formerly known as Università di Ancona)
   r.lucchetti(a)univpm.it
   
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------