Chapter 15 Above: GPS time series from southern California after removing several curve fits to the data.

Slides:



Advertisements
Similar presentations
What Could We Do better? Alternative Statistical Methods Jim Crooks and Xingye Qiao.
Advertisements

Polynomial Approximation PSCI 702 October 05, 2005.
Polynomial Regression and Transformations STA 671 Summer 2008.
Pattern Recognition and Machine Learning
Excel Part III Curve-Fitting, Regression Section 8 Fall 2013 EGR 105 Foundations of Engineering I.
Data mining and statistical learning - lecture 6
CITS2401 Computer Analysis & Visualisation
EARS1160 – Numerical Methods notes by G. Houseman
ES 240: Scientific and Engineering Computation. InterpolationPolynomial  Definition –a function f(x) that can be written as a finite series of power functions.
Section 4.2 Fitting Curves and Surfaces by Least Squares.
Longitudinal Experiments Larry V. Hedges Northwestern University Prepared for the IES Summer Research Training Institute July 28, 2010.
Curve-Fitting Regression
EGR 105 Foundations of Engineering I Fall 2007 – week 7 Excel part 3 - regression.
Part 4 Chapter 13 Linear Regression
Environmental Data Analysis with MatLab Lecture 24: Confidence Limits of Spectra; Bootstraps.
Engineering Computation Curve Fitting 1 Curve Fitting By Least-Squares Regression and Spline Interpolation Part 7.
Part I: Classification and Bayesian Learning
Stat 112: Lecture 9 Notes Homework 3: Due next Thursday
Classification and Prediction: Regression Analysis
So are how the computer determines the size of the intercept and the slope respectively in an OLS regression The OLS equations give a nice, clear intuitive.
1 Chapter 10 Correlation and Regression We deal with two variables, x and y. Main goal: Investigate how x and y are related, or correlated; how much they.
Numerical Operations S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: Polynomial Manipulations.
Physics 114: Lecture 17 Least Squares Fit to Polynomial
Bell Ringer: Find the zeros of each function.
Chapter 13: Inference in Regression
CMPS1371 Introduction to Computing for Engineers NUMERICAL METHODS.
Introduction to MATLAB for Engineers, Third Edition Chapter 6 Model Building and Regression PowerPoint to accompany Copyright © The McGraw-Hill Companies,
Jon Curwin and Roger Slater, QUANTITATIVE METHODS: A SHORT COURSE ISBN © Thomson Learning 2004 Jon Curwin and Roger Slater, QUANTITATIVE.
Scientific Computing Linear and Quadratic Splines.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Curve Fitting.
Linear Functions 2 Sociology 5811 Lecture 18 Copyright © 2004 by Evan Schofer Do not copy or distribute without permission.
Regression analysis Control of built engineering objects, comparing to the plan Surveying observations – position of points Linear regression Regression.
1 Chapter 10 Correlation and Regression 10.2 Correlation 10.3 Regression.
Recap Summary of Chapter 6 Interpolation Linear Interpolation.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Chapter 10 Correlation and Regression
Curve Fitting and Regression EEE 244. Descriptive Statistics in MATLAB MATLAB has several built-in commands to compute and display descriptive statistics.
Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1.
Model Construction: interpolation techniques 1392.
ES 240: Scientific and Engineering Computation. Chapter 13: Linear Regression 13. 1: Statistical Review Uchechukwu Ofoegbu Temple University.
Curve-Fitting Regression
Regression Regression relationship = trend + scatter
Multiple Regression Petter Mostad Review: Simple linear regression We define a model where are independent (normally distributed) with equal.
Scientific Computing General Least Squares. Polynomial Least Squares Polynomial Least Squares: We assume that the class of functions is the class of all.
Stat 112 Notes 9 Today: –Multicollinearity (Chapter 4.6) –Multiple regression and causal inference.
Polynomials, Curve Fitting and Interpolation. In this chapter will study Polynomials – functions of a special form that arise often in science and engineering.
UNIT 2, LESSON 1 POLYNOMIAL FUNCTIONS. WHAT IS A POLYNOMIAL FUNCTION? Coefficients must be real numbers. Exponents must be whole numbers.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Chapter 15 General Least Squares and Non- Linear.
Principles of Extrapolation
Curve Fitting Introduction Least-Squares Regression Linear Regression Polynomial Regression Multiple Linear Regression Today’s class Numerical Methods.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Simple Linear Regression The Coefficients of Correlation and Determination Two Quantitative Variables x variable – independent variable or explanatory.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Chapter 17 and 18 Interpolation.
Standard form of an equation means we write an equation based on its exponents. 1.Arrange the terms so that the largest exponent comes first, then the.
Regression Analysis: A statistical procedure used to find relations among a set of variables B. Klinkenberg G
LECTURE 17: BEYOND LINEARITY PT. 2 March 30, 2016 SDS 293 Machine Learning.
Environmental Data Analysis with MatLab 2 nd Edition Lecture 22: Linear Approximations and Non Linear Least Squares.
Model Selection and the Bias–Variance Tradeoff All models described have a smoothing or complexity parameter that has to be considered: multiplier of the.
Lecture 29: Modeling Data. Data Modeling Interpolate between data points, using either linear or cubic spline models Model a set of data points as a polynomial.
Matlab Training Session 11: Nonlinear Curve Fitting
Piecewise Polynomials and Splines
EEE 244-7: Curve Fitting.
Roots and Zeros 5.7.
Simple Linear Regression
Chapter 12 Curve Fitting : Fitting a Straight Line Gab-Byung Chae
Spline Interpolation Class XVII.
Warm-up: Find the equation of a quadratic function in standard form that has a root of 2 + 3i and passes through the point (2, -27). Answer: f(x) = -3x2.
Warm Up – Look over your notes/examples from last week Any questions??
Simple Linear Regression
Presentation transcript:

Chapter 15 Above: GPS time series from southern California after removing several curve fits to the data

Fitting curves to data is very common in Earth sciences Has applications in virtually all subdiscipline Two things to keep in mind: Data is noisy Data is discrete (non-continuous) Curve fitting can help overcome these issues (to some degree) Empirical Modeling: A type of modeling that involves fitting a curve to data and then using the equation of the curve to predict values From Wells & Coppersmith (1994) Extrapolations of Future Global Warming, IPCC (2007)

MATLAB provides several built-in functions to fit curves Many require the “Curve Fitting Toolbox”, or other toolboxes. We will only use the basic curve fitting functions that are part of standard MATLAB We will focus on polyfit, polyval, corrcoef, roots polyfit Fits data with a polynomial curve of a user-specified degree

Polynomials come in different orders or degrees 0 th order: a single constant value Examples: y = 4 y = 2.75 y = st order: a linear equation (independent var is to 1 st power) Examples: y = 4x y = 3.2x + 7 y = -8.2x – nd order: a quadratic equation Examples: y = 5x 2 y = 2.9x y = -1.8x 2 – 7.4x rd order: a cubic equation Examples: y = 7x 3 y = 4.6x y = 2.4x x x n th order: a polynomial where “n” is the largest exponent Can be represented as a row vector in MATLAB Interpreted by “polyval” as coefficients of a polynomial

Using polyval requires a lot less typing Saves time!

A first order polynomial is a linear equation

Roots of a function: Where function = 0 Useful in sciences because we often want to know where parameters return to zero Also useful for finding min/max of data and equations 1 st order polynomial: 1 root 2 nd order polynomial: 0, 1, or 2 roots 3 rd order polynomial: up to 3 roots n th order polynomial: up to n roots Warning! Some polynomials have no real roots, but do have roots with imaginary numbers Recall, the discriminant b 2 – 4ac

This means that… Discriminant > 0 Polynomial

This means that… Has no real roots! Discriminant < 0 Polynomial

This means that… Has 4 real roots! Polynomial

Polynomials are easy to deal with in MATLAB As the order of the polynomial increases… So does the complexity of the curve Remember the Taylor Series? You can fit any function with an infinite series of polynomials More polynomials = better fit Polyfit is similar except it fits a single polynomial to data

A Simple Test… Fit 5 collinear points with linear equation

Use polyfit to perform a least squares fit of a 1 st order polynomial i.e. a linear fit

While there are better ways to evaluate goodness of fit… It is beyond our scope to cover all methods for goodness of fit Take a Stats course! Correlation coefficient, R, is one commonly used measure R 2 = tells the % of your data’s variance that is explained by a linear fit R 2 = 0.95 means 95% of your data variance is explained by linear fit. What is good enough? Depends on the situation

Make synthetic data with noise See if fit is reasonable

Increasing the order of the polynomial allows for more complex curves to be fit Be careful to not over-fit your data! MATLAB will give a warning if the result is poorly conditioned

What if data is unevenly spaced? How could you estimate an evenly spaced data set? Interpolate it Interpolation: The process of estimating values in between data points What if data is limited in range? How could you estimate data beyond your data range? Extrapolate values Very prone to errors. Should always be done with extreme caution Extrapolation: The process of estimating values beyond the bounds of your data MATLAB provides several ways to interpolate data I will only cover using “interp1” and “polyfit”

You can use a best fit curve to interpolate Make sure the curve fits data well Best fit curves tend to smooth data Will not honor your collected data points! This is why formal interpolation is typically preferred Be careful about extrapolating!

interp1: interpolates 1D data See also interp2 and interp3 for 2D/3D interp1 has several options Read the documentation We will only use linear or spline methods

Linear Interpolation Resultant data is boxy Min/Max will not exceed the original data Interpolation using splines Resultant data has smooth curves Min/Max may exceed the original data Both methods honor y-vals at original data

“interp1” can be used to extrapolate beyond input data limits Use ‘extrap’ option interp1(x,y,’linear’,’extrap’) Use with great caution! Use with great caution! Extrapolation is highly prone to errors Extrapolation should only be a last resort Which method worked best? None! Extrapolation is a bad idea If you have to do it, only go very slightly beyond your data limits

MATLAB offers several built-in functions for curve fitting and resampling data We covered only polyfit and interp1 There is no way to know a priori which method is most appropriate for your data Take statistics classes Always test your curve fits Know what relationship to expect between data (if possible) Polynomial fits are not appropriate for all data sets May want to explore other methods E.g. Fourier Analysis / Spectral Analysis MATLAB has TONS of other curve fitting and resampling options in various toolboxes Don’t use toolbox commands this class, but feel free to explore them in your research