ENGR-25_Plot_Model-4.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Registered Electrical.

Slides:



Advertisements
Similar presentations
AP Statistics Section 3.2 C Coefficient of Determination
Advertisements

Lesson 10: Linear Regression and Correlation
E ENGR-25_Chp2_AirCraft_Separation_.pptx 1 Bruce Mayer, PE Engineering-25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Curve Fitting ~ Least Squares Regression Chapter.
ENGR-25_Lec-29_MS_Excel-2.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical.
Linear regression and correlation
Probabilistic & Statistical Techniques Eng. Tamer Eshtawi First Semester Eng. Tamer Eshtawi First Semester
1 Simple Linear Regression and Correlation The Model Estimating the Coefficients EXAMPLE 1: USED CAR SALES Assessing the model –T-tests –R-square.
ENGR-25_Chp6_Tutorial_PolyFit_J_S_rsq.pptx 1 Bruce Mayer, PE Engineering-25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer.
ENGR-25_Plot_Model-4.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Registered Electrical.
MTH15_Lec-03_sec_1-3_Lines_LinearFcns_.pptx 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical &
MTH16_Lec-07a_sec_7-4.pptx 1 Bruce Mayer, PE Mathematics-16: Applied Calculus II Bruce Mayer, PE Licensed Electrical & Mechanical Engineer
7/2/ Lecture 51 STATS 330: Lecture 5. 7/2/ Lecture 52 Tutorials  These will cover computing details  Held in basement floor tutorial lab,
Introduction to Linear Regression.  You have seen how to find the equation of a line that connects two points.
Regression, Residuals, and Coefficient of Determination Section 3.2.
Correlation and Regression
Correlation and Linear Regression
McGraw-Hill/Irwin Copyright © 2010 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 13 Linear Regression and Correlation.
Linear Regression and Correlation
1 Doing Statistics for Business Doing Statistics for Business Data, Inference, and Decision Making Marilyn K. Pelosi Theresa M. Sandifer Chapter 11 Regression.
ENGR-25_Linear_Equations-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical.
MTH55_Lec-06_sec_1-3_Graph_Functions.ppt.ppt 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Curve Fitting ~ Least Squares Regression Chapter.
Linear Regression and Correlation
MTH55_Lec-07_sec_2-3a_Lines_by_Intercepts.ppt 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical.
ENGR-25_Arrays-2.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical.
ENGR-25_MATLAB_OverView-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical.
Licensed Electrical & Mechanical Engineer
ENGR-25_Linear_Equations-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Engr/Math/Physics 25 Chp8.
Chapter 13 Statistics © 2008 Pearson Addison-Wesley. All rights reserved.
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical.
Chapter 6 & 7 Linear Regression & Correlation
MTH55_Lec-09_sec_2-4_Pt-Slp_Line-Eqn.ppt 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical & Mechanical.
MTH55_Lec-36_sec_6-8_Model_by_Variation.ppt 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical &
ENGR-36_Lec-22_Wedge-n-Belt_Friction.pptx 1 Bruce Mayer, PE Engineering-36: Engineering Mechanics - Statics Bruce Mayer, PE Licensed.
AP STATISTICS LESSON 3 – 3 LEAST – SQUARES REGRESSION.
1 Chapter 10 Correlation and Regression 10.2 Correlation 10.3 Regression.
MTH55_Lec-10_sec_3-1_2Var_LinSys_ppt 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical & Mechanical.
MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Chapter 3 Section 3.1 Examining Relationships. Continue to ask the preliminary questions familiar from Chapter 1 and 2 What individuals do the data describe?
Chapter 10 Correlation and Regression
ENGR-25_MATLAB_OverView-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical.
Multiple Linear Regression. Purpose To analyze the relationship between a single dependent variable and several independent variables.
ENGR-25_Programming-3.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical.
MTH55_Lec-28_sec_Jb_Graph_Rational_Functions.ppt 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical.
Regression Regression relationship = trend + scatter
Lecture 10 2D plotting & curve fitting Subplots Other 2-D Plots Other 2-D Plots Curve fitting © 2007 Daniel Valentine. All rights reserved. Published by.
ENGR-25_Linear_Regression_Tutorial.ppt 1 Bruce Mayer, PE Engineering-25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer.
Relationships If we are doing a study which involves more than one variable, how can we tell if there is a relationship between two (or more) of the.
Correlation – Recap Correlation provides an estimate of how well change in ‘ x ’ causes change in ‘ y ’. The relationship has a magnitude (the r value)
Polynomials, Curve Fitting and Interpolation. In this chapter will study Polynomials – functions of a special form that arise often in science and engineering.
Copyright © 2013, 2009, and 2007, Pearson Education, Inc. Chapter 3 Association: Contingency, Correlation, and Regression Section 3.3 Predicting the Outcome.
Section Copyright © 2014, 2012, 2010 Pearson Education, Inc. Chapter 10 Correlation and Regression 10-2 Correlation 10-3 Regression.
ENGR-44_Lec-06-2_Inductors.ppt 1 Bruce Mayer, PE Engineering-43: Engineering Circuit Analysis Bruce Mayer, PE Licensed Electrical.
ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical.
Simple Linear Regression The Coefficients of Correlation and Determination Two Quantitative Variables x variable – independent variable or explanatory.
ENGR-25_Programming-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Registered Electrical.
Linear Regression Models Andy Wang CIS Computer Systems Performance Analysis.
MTH55_Lec-51_sec_8-3a_Quadratic_Fcn_Graphs.ppt 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical.
26134 Business Statistics Week 4 Tutorial Simple Linear Regression Key concepts in this tutorial are listed below 1. Detecting.
Chapter 13 Linear Regression and Correlation. Our Objectives  Draw a scatter diagram.  Understand and interpret the terms dependent and independent.
Plotting in Excel KY San Jose State University Engineering 10.
The simple linear regression model and parameter estimation
Part 5 - Chapter
Basic Estimation Techniques
Licensed Electrical & Mechanical Engineer
^ y = a + bx Stats Chapter 5 - Least Squares Regression
Discrete Least Squares Approximation
Licensed Electrical & Mechanical Engineer
Presentation transcript:

ENGR-25_Plot_Model-4.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Registered Electrical & Mechanical Engineer Engr/Math/Physics 25 Chp6 MATLAB Regression

ENGR-25_Plot_Model-4.ppt 2 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Learning Goals cont

ENGR-25_Plot_Model-4.ppt 3 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Learning Goals cont  Build Math Models for Physical Data using “n th ” Degree Polynomials  Use MATLAB’s “Basic Fitting” Utility to find Math models for Plotted Data

ENGR-25_Plot_Model-4.ppt 4 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Scatter on Plots in XY-Plane  A scatter plot usually shows how an EXPLANATORY, or independent, variable affects a RESPONSE, or Dependent Variable  Sometimes the SHAPE of the scatter reveals a relationship  Shown Below is a Conceptual Scatter plot that could Relate the RESPONSE to some EXCITITATION

ENGR-25_Plot_Model-4.ppt 5 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Linear Fit by Guessing  The previous plot looks sort of Linear  We could use a Ruler to draw a y = mx+b line thru the data  But which Line is BETTER? and WHY?

ENGR-25_Plot_Model-4.ppt 6 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Least Squares Curve Fitting  In a Previous Example polyfit(x,y,1) returned the Values of m & b How does PolyFit Make these Calcs? How Good is the fitted Line Compared to the Data?  polyfit, as do most other curve fitters, uses the “Least Squares” Criterion

ENGR-25_Plot_Model-4.ppt 7 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Least Squares  To make a Good Fit, MINIMIZE the |GUESS − data| distance by one of data Best Guess-y Best Guess-x

ENGR-25_Plot_Model-4.ppt 8 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Least Squares cont  MATLAB polyfit Minimizes the VERTICAL distances; i.e.:  Note that The Function J contains two Variables; m & b  Recall from MTH1 that to MINIMIZE a Function set the 1 st (partial) Derivative(s) equal to Zero

ENGR-25_Plot_Model-4.ppt 9 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Least Squares cont  To Minimize J, take  The Two Partials yield Two LINEAR Eqns in m & b  The two eqns can be solved EXACTLY for m & b  the Book on pg 271 gives a good example  Remember, at this point m & b are UNKNOWN xy

ENGR-25_Plot_Model-4.ppt 10 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Least Squares cont  In This Case  Solving these Eqns for m & b yields m = 9/10 b = 11/6  This produces the best fit Line  Taking ∂J/∂m = 0, and ∂J/∂b = 0 yields xy

ENGR-25_Plot_Model-4.ppt 11 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Goodness of Fit  The Distance from The Best-Fit Line to the Actual Data Point is called the RESIDUAL  For the Vertical Distance the Residual is just δy  If the Sum of the Residuals were ZERO, then the Line would Fit Perfectly  Thus J, after finding m & b, is an Indication of the Goodness of Fit

ENGR-25_Plot_Model-4.ppt 12 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Goodness of Fit cont  Now J is an indication of Fit, but we Might want to SCALE it relative to the MAGNITUDE of the Data For example consider –DataSet1 with x&y values in the MILLIONS –DataSet2 with x&y values in the single digits In this case we would expect J1 >> J2  To remove the affect of Absolute Magnitude, Scale J against the Data Set mean; e.g mean1 = mean2 = 4.91

ENGR-25_Plot_Model-4.ppt 13 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Goodness of Fit cont  The Mean-Scaling Quantity is the Actual-Data Relative to the Actual-Mean  Finally the Scaled Fit-Metric, “r-squared’  As before the Squaring Ensures that all Terms in the sum are POSITIVE

ENGR-25_Plot_Model-4.ppt 14 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods r 2 = Coeff of Determination  The r 2 Value is Also Called the COEFFICIENT OF DETERMINATION J  Sum of Residual (errors) –May be Zero or Positive S  Data-to-Mean Scaling Factor –Always Positive if >1 Data-Pt and data not “perfectly Horizontal”  If J = 0, then there is NO Distance Between the calculated Line and Data  Thus if J = 0, then r 2 = 1; so r 2 = 1 (or 100%) indicates a PERFECT FIT

ENGR-25_Plot_Model-4.ppt 15 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Meaning of r 2  The COEFFICIENT OF DETERMINATION  Has This Meaning The coefficient of determination tells you what proportion of the variation between the data points is explained or accounted for by the best line fitted to the points. It indicates how close the points are to the line.

ENGR-25_Plot_Model-4.ppt 16 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Norm of Residuals  MATLAB uses the Norm of Residuals as a Measure of Goodness of Fit  The Norm of Residuals, N R, is simply the SqRt of J:  Thus r 2 in Terms of N R :  As a Measure of Goodness of Fit as the FIT Approaches Perfection J→0 so:

ENGR-25_Plot_Model-4.ppt 17 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods N R vs r 2 →  Notice that r 2 is a RELATIVE Measure → it’s NORMALIZED to the WORST CASE Value of J which is S Thus r 2 can be expressed at PERCENTAGE withOUT Units  N R is an ABSOLUTE measure that Technically Requires that it be stated with SAME UNITS as the dependent variable, y

ENGR-25_Plot_Model-4.ppt 18 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Data Scaling  Data-Scaling is a SubTopic of DIMENSIONAL ANALYIS (DA) DA is Covered in 3 rd Yr ME/CE Courses –I Learned it in a Fluid Mechanics Course  For Our Purposes we will cover only SCALING  Sometimes we Collect Data with a SMALL Variation Relative to the Magnitude of the MEAN Leads to a SENSITIVE Analysis; e.g. This Data is Noisy During Analysis xy

ENGR-25_Plot_Model-4.ppt 19 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Data Scaling - Normalization  The Significance of ANY Data Set Can be Improved by Normalizing  Normalize  Scale Data such that the Values run: 0 →1 0% → 100%  Steps to Normalization 1.Find the MAX & MIN values in the Data Set; e.g., z max & z min 2.Calculate the Data Range, R D R D = (z max – z min ) 3.Calc the Individual Data Differences Relative to the MIN Δz k = z k - z min

ENGR-25_Plot_Model-4.ppt 20 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Data Scaling – Normailzation cont 4.Finally, Scale the Δz k relative to R D Ψ k = Δz k /R D 5.Scale the corresponding “y” values in the Same Manner to produce say, Φ k 6.Plot Φ k vs Ψ k on x & y scales that Run from 0→1  Example – Do Frogs Croak More on WARM Nites? Temperature (ºF) Croaks/Hr

ENGR-25_Plot_Model-4.ppt 21 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Normalization Example  Normalize T → Θ CPH → Ω  Now Compare Plots CPH vs T Ω vs Θ

ENGR-25_Plot_Model-4.ppt 22 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Plots Compared  T-CPH Plot  Ω-Θ Plot The Θ-Ω Plot Fully Utilizes Both Axes

ENGR-25_Plot_Model-4.ppt 23 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Basic Fitting  Use MATLAB’s AutoMatic Fitting Utility to Find The Best Line for the the Frog Croaking Data SEE: Demo_Frog_Croak_BasicFit_1110.m

ENGR-25_Plot_Model-4.ppt 24 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods All Done for Today Croaking Frog

ENGR-25_Plot_Model-4.ppt 25 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer Engr/Math/Physics 25 Appendix

ENGR-25_Plot_Model-4.ppt 26 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Linear Regression Tutorial  Minimize Height Error δy  See File ENGR- 25_Linear_Regressi on_Tutorial_1309.pp tx

ENGR-25_Plot_Model-4.ppt 27 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

ENGR-25_Plot_Model-4.ppt 28 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Altitude of Right Triangle  The Area of RIGHT Triangle  The Area of an ARBITRARY Triangle  By Pythagoras for Rt-Triangle

ENGR-25_Plot_Model-4.ppt 29 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Altitude of Right Triangle cont  Solving for h  Equating the A=½·Base·Hgt noting that

ENGR-25_Plot_Model-4.ppt 30 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Normalized Plot >> T = [69.4, 69.7, 71.6, 75.2, 76.3, 78.6, 80.6, 80.6, 82, 82.6, 83.3, 83.5, 84.3, 88.6, 93.3]; >> CPH = [15.4, 14.7, 16, 15.5, 14.1, 15, 17.1, 16, 17.1, 17.2, 16.2, 17, 18.4, 20, 19.8]; >> Tmax = max(T); >> Tmin = min(T); >> CPHmax = max(CPH); >> CPHmin = min(CPH); >> Rtemp = Tmax - Tmin; >> Rcroak = CPHmax - CPHmin; >> DelT = T - Tmin; >> DelCPH = CPH - CPHmin; >> Theta = DelT/Rtemp;DelCPH = CPH - CPHmin; >> Omega = DelCPH/Rcroak; >> plot(T, CPH,), grid >> plot(Theta,Omega), grid

ENGR-25_Plot_Model-4.ppt 31 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Start Basic Fitting Interface 1  FIRST → Plot the DATA

ENGR-25_Plot_Model-4.ppt 32 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Start Basic Fitting Interface 2 Expand Dialog Box Goodness of Fit; smaller is Better

ENGR-25_Plot_Model-4.ppt 33 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Start Basic Fitting Interface 3  Result  Chk by polyfit >> p = polyfit(Theta,Ome ga,1) p = 

ENGR-25_Plot_Model-4.ppt 34 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Caveat

ENGR-25_Plot_Model-4.ppt 35 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Greek Letters in Plots

ENGR-25_Plot_Model-4.ppt 36 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Plot “Discoverables”

ENGR-25_Plot_Model-4.ppt 37 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods % "Discoverable" Functions Displayed % Bruce Mayer, PE ENGR25 15Jul09 % x = linspace(-5, 5); ye = exp(x); ypp = x.^2; ypm = x.^(-2); % plot all 3 on a single graphe plot(x,ye, x,ypp, x,ypm),grid,legend('ye', 'ypp', 'ypm') disp('Showing MultiGraph Plot - Hit ANY KEY to continue') pause % % PLot Side-by-Side subplot(1,3,1) plot(x,ye), grid subplot(1,3,2) plot(x,ypp), grid subplot(1,3,3) plot(x,ypm), grid