0

I want to generate a continuous curve based on some data, but the curve needs to satisfy some constraints:

  1. All values of the curve are on the interval [0,1]. Values outside this interval aren't interpretable.
  2. I want to specify the exact start and end values: f(1) = 1 and f(last) = 0
  3. derivative of f(x) is always negative or 0.

The data points also follow these rules.

Right now, I'm using smooth.monotone from the fda package to fit a bspline basis created with create.bspline.basis. This works great for preserving monotonicity between knots but the resulting curve seems to venture above 1 and below 0.

Is there a way to specify points that the curve fit must go through, or an interval that the curve cannot leave?

heyitsbmo
  • 1,715
  • 1
  • 14
  • 29

1 Answers1

2

Transform your 0-1 variable so that it is asymptotically -Inf to +Inf, then do an unconstrained smooth, then invert the transformation.

Logit, or probit or something should help. Apologies for incompleteness, but you didn't supply a reproducible example and I've got things to do.

Spacedman
  • 92,590
  • 12
  • 140
  • 224
  • Inquiring minds want to know: what's on that "to do list"? :-) . Meanwhile, I'd offer to BenMorris that you can't really simultaneously smooth data and limit its extent. Or, you can, but you'll probably have an over-damped result and won't like it. – Carl Witthoft Nov 10 '12 at 20:22
  • Just joining the dots will work here. That's a spline smoother in a sense. Each consecutive data point `(x_i,y_i) -> (x_i+1, y_i+1)` define the corners of a rectangle in which the line must be constrained... Not sure if that's helpful... – Spacedman Nov 10 '12 at 23:44