John Mount has a new package available in R:
In the above we have an input (or independent variable)
x
and an observed outcome (or dependent variable)y_observed
(portrayed as points).y_observed
is the unobserved idea valuey_ideal
(portrayed by the dashed curve) plus independent noise. The modeling goal is to get close they_ideal
curve using they_observed
observations. Obviously this can be done with a smoothing spline, but let’s useRcppDynProg
to find a piecewise linear fit.
To encode this as a dynamic programming problem we need to build a cost matrix that for every consecutive interval ofx
-values we have estimated the out-of sample quality of fit. This is supplied by the functionRcppDynProg::lin_costs()
(using the PRESS statistic), but lets take a quick look at the idea.
It’s an interesting package whose purpose is to turn an input data stream into a set of linear functions which approximate the stream. I’m not sure I’ll ever have a chance to use it, but it’s good to know that it’s there if I do ever need it.