The numpy library will return the Theil-Sen slope and intercept from a set of data. It also provides a confidence interval on the slope. Is it possible to use this confidence interval along with the original data to produce a regression confidence interval similar to those in Simple Linear Regression:

$$ CI = t*\sigma*\sqrt{\frac{1}{n}+\frac{\left(x-x̄\right)^2}{SSx}} $$

Is it still valid to use the Theil-Sen estimator to calculate a regression variance and mean-square-residual, to then calculate the confidence interval?

  • $\begingroup$ I've seen a variety of different intercepts used with the Theil slope. How are you calculating the intercept? (Or is it that you don't particularly mind which choice it is?) Note that CI's are for population quantities.The CI formula you give there is a CI for the conditional mean. Are you seeking an interval for some specific quantity? Or are you more trying to find out whether there's a population quantity that we could get an interval for? (the questions are somewhat connected) $\endgroup$
    – Glen_b
    Oct 26, 2017 at 23:12
  • $\begingroup$ I believe numpy uses the median x and median y values with the slope to produce the regression line. I’m hoping to use the confidence interval to help asses goodness of fit and provide confidence intervals on values produced from using the regression line. $\endgroup$ Oct 27, 2017 at 0:27
  • $\begingroup$ Again, a confidence interval for a line is not an interval for the fitted line; but some particular population line (include any additional information in your question). While scipy.stats.mstats.theilslopes has "median(y) - medslope*median(x)", it's not the only possibility - if that's what you want you'd need to explore the properties of that intercept and the slope together. Figuring out a nonparametric interval for the intercept will be tricky, let alone a simultaneous one for both of them. Bootstrapping would be a possibility, if used in large samples with a suitable choice of procedure $\endgroup$
    – Glen_b
    Oct 27, 2017 at 1:22
  • $\begingroup$ However, there are a number of issues to worry about in that case e.g. consider "the relative error of the bootstrap quantile variance estimator is of precise order $n^{-1/4}$" (Hall & Martin (1988), "Exact convergence rate of bootstrap quantile variance estimator" Probability Theory and Related Fields, 80:2 (December) pp261–268) ... suggesting that a plain bootstrap may not be the most efficient choice. There's also no strictly pivotal quantity; exchangeability will be an issue (what are we bootstrapping --- residuals?) $\endgroup$
    – Glen_b
    Oct 27, 2017 at 1:39
  • $\begingroup$ If you were after an interval under some parametric assumption other possibilities may arise (e.g. simulation perhaps, or some approximate asymptotic interval) $\endgroup$
    – Glen_b
    Oct 27, 2017 at 1:45


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.