## Confidence Interval For Polynomial Fitting

### Remember to vote up questions/answers you find interesting or helpful (requires 15 reputation points)

I'm programming an n-dimensional polynomial fitting function. It uses the basic concept of least squares and a design matrix.

For example, a quadratic fit on 2d data:

This is a row in the design Matrix:

$X={({1, x, x^2})}$

And this is the matrix formula I'm using:

$(X^T*X)^{-1}(X^T*Y)=Ax^2+Bx+C$

This is nothing special or complicated.

I'm at the point however where I'd like to introduce confidence intervals. How do I compute the confidence intervals from this regression technique?

-

Normal equations, huh? If you're going to stick with that approach, please please hook up a condition estimator as a sanity check; this is the approach most sensitive to roundoff error. QR decomposition is often a better choice. As an aside, the variances of the parameters are usually obtained from the diagonal entries of the variance-covariance matrix `$\left(\mathbf{X}^T\mathbf{X}\right)^{-1}$` ; I would suppose any expression for the CIs would involve these as well. – J. M. Sep 7 2010 at 9:11

## 1 Answer

A simple place to start: Look at the residues when you subtract out your putative function from your data set. A perfect fit (for a very small dataset, or a very perfectly quadratic dataset) will have residues of zero and a correlation coefficient that you can calculate. A bad but "middling" best-fit will have residues equally distributed in the positive and negative $y$-axis. A bad quadratic fit will skew positive on one side and negative on the other side, or positive in the middle and negative on the ends or vice versa. A better fit will have smaller residues.

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 3, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.8905931711196899, "perplexity_flag": "middle"}