I am building a .NET program. One of its functions is to provide a predictive model for a vehicles life-to-date maintenance costs, basically what is the cumulative cost(Y) for a vehicle at specific year(X). I decided to use a 2nd degree polynomial least squares fit and for the most part it does a good job. Sometimes though the curve will peak and start trending downward which doesn't make sense for life-date-cost since its a cumulative value...(X,Y) > (X-1,Y).

This negative trend happens when the difference in cost for say, year 2 to year 3 is less than year 1 to year 2. Some sample data that gives me a negative trend:

(1,328.76) (2,1133.12) (3,1366.07)

My solution for now is to check for a negative trend and if its found use a linear best fit instead but I feel like that's a messy fix. I've thought about implementing some sort of minimum value for the change from year to year...essentially turning the curve into a linear line at a certain X value but that seems complicated to implement. Does anyone see a better way of doing this or a better model to use? I'm not very knowledgeable with statistics so go easy on me :-p


Each vehicle has a varying amount of data depending on how long its been in service, with a soft max at 15 years. So the last data point for each vehicle is for the most recent year(2011 in this case) and we are really only interested in extrapolating 5 years beyond that point. As we use the model year to year, we will get more data for the vehicles which require the model to be altered. Thats why I choose the polynomial least squares fit because its easy to just run the new data back through that function and get a new equation.

  • 1
    $\begingroup$ What software are you using to fit the predictive model? Is it .NET, or are you just implementing the model in .NET that you fit elsewhere? There are strategies pre-programmed in statistical software such as R, SAS, SPSS, etc. that would be hard to do from scratch w/o a good deal of expertise. Also, are you going to need to do extrapolation, or will all future predictions be w/i the interval spanned by your training data? NB extrapolation raises difficult issues; see here: using-a-regression-model-to-make-prediction-when-to-stop. $\endgroup$ Oct 16, 2012 at 13:51
  • $\begingroup$ Hi @gung. Can you give some detail on the strategies you have in mind? That would, I think, be an answer. $\endgroup$
    – Peter Flom
    Oct 16, 2012 at 14:18
  • $\begingroup$ I'm not using any software to find the model...I suppose I should start there. I initially used Excel's trendline function. I'm using .NET to implement whatever model I find. Your link makes a good point. I edited my question with some more details regarding extrapolation. $\endgroup$
    – Jack
    Oct 16, 2012 at 14:29

1 Answer 1


Using a squared term to capture a curvilinear relationship in your data is fine, but it's worth noting that this can only capture one exact shape of curvature. This can be very limiting in practice. What you want typically is to use smoothing splines. I wrote about this here: What are the advantages / disadvantages of using splines, smoothed splines, and Gaussian process emulators?, which may be helpful to read. However, these techniques are somewhat advanced, and I doubt they can be done in Excel. Moreover, extrapolation is very hard to do well (here's a humorous example), and extrapolation is especially likely to go awry when using splines. Most likely, you will need to work with a statistical consultant.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.