No announcement yet.
  • Filter
  • Time
  • Show
Clear All
new posts

  • Add Confidence intervals to median spline

    I would like to add 95% confidence intervals to a median spline. It does not appear to be an option of mspline and the other confidence interval shading options seem to be determined by a regression plot

    for example,

    use, clear
    tw (qfitci mpg weight, nofit fintensity(10)) (scatter mpg weight, msize(*.5)) (mspline mpg weight)
    Is there a way to have the shading determined by the spline as opposed to the quadratic regression?

  • #2
    That's not as desirable as you might think. The essence of Stata's median spline is to slice the (x, y) space into so many vertical bands, calculate medians of y and x within each band, and then join up the medians with some kind of spline, cubic I imagine. What you can tune is just the number of bands.

    That often works well when what you're plotting is in principle a smooth curve and graphically you want ... a smooth curve.

    It can be a quick and dirty way of looking for pattern in bivariate data.

    But it's not strongly statistical. There is no idea, as I understand it, of weighting or in any other way considering the number of points or the variability within each band.

    All that said, I don't know any way to get this easily.

    If you want some data-driven smoother than data fit, I would reach for a different spline procedure, fractional polynomials, or (personal favourite) local polynomials.