This function performs the estimation of a SETAR model on the basis of the asymptotic theory of Hansen ("Sample Splitting and Threshold Estimation", Econometrica, 2000): Y_(t)= a1*Y_(t-1)+a2*Y_(t-2)+···+ap*Y_(t-p)(Y_(t-d)<=gamma) + b1*Y_(t-1)+b2*Y_(t-2)+···+bp*Y_(t-p)(Y_(t-d)>gamma) + e_(t) This program makes use of procedures based on GAUSS code of Bruce Hansen to estimate a SETAR model with 2 regimes both under the hypothesis of homoskedasticity and heteroskedasticity. In the last case the error term is supposed to be a Martingale Difference. For both case are also computed: 1) The confidence interval for the threshold parameter 2) The confidence interval for the autoregressive coefficients 3) The test for a threshold in linear regression (Linearity Test) The return value is a list with the fitted values and residuals Y_h and ehat, where Y is the name of the input series. Changes: v1.5: internal change, replace sprintf command with function form (gretl team) v1.4: correct version requirement (to 2016a), new author email v1.3: extend the help text, minor corrections