Linear Regression 1Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression Daniel Baur ETH Zurich, Institut für Chemie- und Bioingenieurwissenschaften.

Slides:



Advertisements
Similar presentations
11-1 Empirical Models Many problems in engineering and science involve exploring the relationships between two or more variables. Regression analysis.
Advertisements

Fixed point iterations and solution of non-linear functions
Kin 304 Regression Linear Regression Least Sum of Squares
11 Simple Linear Regression and Correlation CHAPTER OUTLINE
Simple Linear Regression. Start by exploring the data Construct a scatterplot  Does a linear relationship between variables exist?  Is the relationship.
Linear regression models
Ch11 Curve Fitting Dr. Deshi Ye
Systems of Linear Equations
Class 16: Thursday, Nov. 4 Note: I will you some info on the final project this weekend and will discuss in class on Tuesday.
Response Surface Method Principle Component Analysis
2DS00 Statistics 1 for Chemical Engineering Lecture 3.
Chapter 12 Simple Regression
BA 555 Practical Business Analysis
1 Chapter 3 Multiple Linear Regression Ray-Bing Chen Institute of Statistics National University of Kaohsiung.
Lecture 25 Regression diagnostics for the multiple linear regression model Dealing with influential observations for multiple linear regression Interaction.
Lecture 19: Tues., Nov. 11th R-squared (8.6.1) Review
The Simple Regression Model
Response Surfaces max(S(  )) Marco Lattuada Swiss Federal Institute of Technology - ETH Institut für Chemie und Bioingenieurwissenschaften ETH Hönggerberg/
Lecture 24: Thurs. Dec. 4 Extra sum of squares F-tests (10.3) R-squared statistic (10.4.1) Residual plots (11.2) Influential observations (11.3,
Lecture 24: Thurs., April 8th
Probability & Statistics for Engineers & Scientists, by Walpole, Myers, Myers & Ye ~ Chapter 11 Notes Class notes for ISE 201 San Jose State University.
Simple Linear Regression Analysis
Non Linear Regression Y i = f(  x i ) +  i Marco Lattuada Swiss Federal Institute of Technology - ETH Institut für Chemie und Bioingenieurwissenschaften.
Regression Diagnostics Checking Assumptions and Data.
Analysis of Individual Variables Descriptive – –Measures of Central Tendency Mean – Average score of distribution (1 st moment) Median – Middle score (50.
Linear Regression Y i =  0 +  1 x i +  i Marco Lattuada Swiss Federal Institute of Technology - ETH Institut für Chemie und Bioingenieurwissenschaften.
11-1 Empirical Models Many problems in engineering and science involve exploring the relationships between two or more variables. Regression analysis.
1 BA 555 Practical Business Analysis Review of Statistics Confidence Interval Estimation Hypothesis Testing Linear Regression Analysis Introduction Case.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Review for Final Exam Some important themes from Chapters 9-11 Final exam covers these chapters, but implicitly tests the entire course, because we use.
Forecasting Revenue: An Example of Regression Model Building Setting: Possibly a large set of predictor variables used to predict future quarterly revenues.
Correlation & Regression
Regression Analysis Regression analysis is a statistical technique that is very useful for exploring the relationships between two or more variables (one.
1 MULTI VARIATE VARIABLE n-th OBJECT m-th VARIABLE.
CPE 619 Simple Linear Regression Models Aleksandar Milenković The LaCASA Laboratory Electrical and Computer Engineering Department The University of Alabama.
Simple Linear Regression Models
© 2004 Prentice-Hall, Inc.Chap 15-1 Basic Business Statistics (9 th Edition) Chapter 15 Multiple Regression Model Building.
© 2002 Prentice-Hall, Inc.Chap 14-1 Introduction to Multiple Regression Model.
Chapter 8: Regression Analysis PowerPoint Slides Prepared By: Alan Olinsky Bryant University Management Science: The Art of Modeling with Spreadsheets,
Topic 14: Inference in Multiple Regression. Outline Review multiple linear regression Inference of regression coefficients –Application to book example.
Basic Probability (Chapter 2, W.J.Decoursey, 2003) Objectives: -Define probability and its relationship to relative frequency of an event. -Learn the basic.
Chap 12-1 A Course In Business Statistics, 4th © 2006 Prentice-Hall, Inc. A Course In Business Statistics 4 th Edition Chapter 12 Introduction to Linear.
Boundary Value Problems and Least Squares Minimization
1 Chapter 12 Simple Linear Regression. 2 Chapter Outline  Simple Linear Regression Model  Least Squares Method  Coefficient of Determination  Model.
Chapter 5: Regression Analysis Part 1: Simple Linear Regression.
Byron Gangnes Econ 427 lecture 3 slides. Byron Gangnes A scatterplot.
Regression Analysis Week 8 DIAGNOSTIC AND REMEDIAL MEASURES Residuals The main purpose examining residuals Diagnostic for Residuals Test involving residuals.
Lesson Multiple Regression Models. Objectives Obtain the correlation matrix Use technology to find a multiple regression equation Interpret the.
Multiple Regression Petter Mostad Review: Simple linear regression We define a model where are independent (normally distributed) with equal.
Stat 112 Notes 16 Today: –Outliers and influential points in multiple regression (Chapter 6.7)
Maths Study Centre CB Open 11am – 5pm Semester Weekdays
© Copyright McGraw-Hill Correlation and Regression CHAPTER 10.
Class 4 Ordinary Least Squares CERAM February-March-April 2008 Lionel Nesta Observatoire Français des Conjonctures Economiques
Solution of Nonlinear Functions
28. Multiple regression The Practice of Statistics in the Life Sciences Second Edition.
Statistical Data Analysis 2010/2011 M. de Gunst Lecture 10.
Principal Component Analysis (PCA)
Basic Business Statistics, 10e © 2006 Prentice-Hall, Inc. Chap 15-1 Chapter 15 Multiple Regression Model Building Basic Business Statistics 10 th Edition.
Linear Regression 1Michael Sokolov / Numerical Methods for Chemical Engineers / Linear Regression Michael Sokolov ETH Zurich, Institut für Chemie- und.
Stat 112 Notes 14 Assessing the assumptions of the multiple regression model and remedies when assumptions are not met (Chapter 6).
732G21/732G28/732A35 Lecture 3. Properties of the model errors ε 4. ε are assumed to be normally distributed
The “Big Picture” (from Heath 1995). Simple Linear Regression.
Nonlinear Regression 1Michael Sokolov / Numerical Methods for Chemical Engineers / Nonlinear Regression Michael Sokolov ETH Zurich, Institut für Chemie-
The simple linear regression model and parameter estimation
Chapter 14 Inference on the Least-Squares Regression Model and Multiple Regression.
Regression Analysis AGEC 784.
11-1 Empirical Models Many problems in engineering and science involve exploring the relationships between two or more variables. Regression analysis.
Stats Club Marnie Brennan
Multiple Regression Models
Presentation transcript:

Linear Regression 1Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression Daniel Baur ETH Zurich, Institut für Chemie- und Bioingenieurwissenschaften ETH Hönggerberg / HCI F128 – Zürich

Linear regression model  As inputs for our model we use two vectors x and Y, where  x i is the i-th observation  Y i is the i-th response  The model reads:  At this point, we make a fundamental assumption:  As outputs from our regression we get estimated values for the regression parameters: 2Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression The errors are mutually independent and normally distributed with mean zero and variance σ 2 : A regression is called linear if it is linear in the parameters!

The errors ε 3Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression  Since the errors are assumed to be normally distributed, the following is true for the expectation values and variance of the model responses

Example: Boiling Temperature and Pressure 4Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Parameter estimation 5Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression  = confidence interval

Residuals 6Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression Outlier

Removing the Outlier 7Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Goodness of fit measures  Coefficient of determination  Total sum of squares  Sum of squares due to regression  Sum of squares due to error 8Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression R 2 = 1   i = 0 R 2 = 0  regression does not explain variation of Y

The LinearModel and dataset classes  Matlab 2012 features two classes that are designed specifically for statistical analysis and linear regression  dataset  creates an object that holds data and meta-data like variable names, options for inclusion / exclusion of data points, etc.  LinearModel  is constructed from datasets or X, Y pairs (as with the regress function) and a model description  automatically does linear regression and holds all important regression outputs like parameter estimates, residuals, confidence intervals etc.  includes several useful functions like plots, residual analysis, exclusion of parameters etc. 9Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Classes in Matlab  Classes define a set of properties (variables) and methods (functions) which operate on those properties  This is useful for bundling information together with ways of treating and modifying this information mdl = LinearModel.fit(X,Y);  When a class is instantiated, an object of this class is created which can be used with the methods of the class, e.g. mdl = LinearModel.fit(X,Y); mdl.Coefficients  Properties can be accessed with the dot operator, like with structs (e.g. mdl.Coefficients ) plot(mdl)mdl.plot()  Methods can be called either with the dot operator, or by having an object of the class as first input argument (e.g. plot(mdl) or mdl.plot() ) 10Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Working with LinearModel and dataset  First, we define our observed and measured variables, giving them appropriate names, since these names will be used by the dataset and the LinearModel as meta-data 11Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Working with LinearModel and dataset  Next, we construct the dataset from our variables 12Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Working with LinearModel and dataset  After defining the relationship between our data (a model), we can use the dataset and the model to construct a LinearModel object  This will automatically fit the data, perform residual analysis and much more 13Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

LinearModel: Plot  Now that we have the model, we have many analysis and plotting tools at our disposal 14Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Linear Model: Tukey-Anscombe Plot  Plot residuals vs. fitted values; These should be randomly distributed around 0 15Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression Outlier?

LinearModel: Cook’s Distance  The Cook’s distance measures the effect of removing one measurement from the data 16Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Linear Model: Removing the Outlier  After identifying an outlier, it can be easily removed 17Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Multiple linear regression  Approximate model  Residuals  Least squares 18Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Exercise  The data file asphalt.dat (online), contains data from a degradation experiment for different concrete mixtures [1]  The rutting (erosion) in inches per million cars (RUT) is measured as a function of  viscosity (VISC)  percentage of asphalt in the surface course (ASPH)  percentage of asphalt in the base course (BASE)  an operating mode 0 or 1 (RUN)  percentage (*10) of fines in the surface course (FINES)  percentage of voids in the surface course (VOIDS) 19Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression [1] R.V. Hogg and J. Ledolter, Applied Statistics for Engineers and Physical Scientists, Maxwell Macmillan International Editions, 1992, p.393.

Assignment  The LinearModel class only exists in Matlab 2012 or newer  There are two versions of the assignment, one for Matlab 2012 and one for older versions, do one of the two 20Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Matlab 2012 and newer only Assignment (Matlab 2012 and newer only) 1.Find online the file readVars.m that will read the data file and assign the variables RUT, VISC, ASPH, BASE, RUN, FINES and VOIDS; You can copy and paste this script into your own file. 2.Create a dataset using the variables from 1. 3.Set the RUN variable to be a discrete variable ds.RUN = nominal(ds.RUN);  Assuming your dataset is called ds, use ds.RUN = nominal(ds.RUN); 4.Create a modelspec string  To include multiple variables in the modelspec, use the plus sign LinearModel.fit 5.Fit your model using LinearModel.fit, display the model output and plot the model. 21Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Assignment (Continued) 6.Which variables most likely have the largest influence? 7.Generate the Tukey-Anscombe plot. Is there any indication of nonlinearity, non-constant variance or of a skewed distribution of residuals? plotAllResponses 8.Plot the adjusted responses for each variable, using the plotAllResponses function you can find online 9.The variables seem to show a rather random response, except for VISC which seems to mostly lie on one of the axes. Try and transform the system by defining  logRUT = log10(RUT); logVISC = log10(VISC); 10.Define a new dataset and modelspec using the transformed variables. 22Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Assignment (Continued) 11.Fit a new model with the transformed variables and repeat the analysis from before. step 12.With the new model, try to remove variables that have a small influence. To do this systematically, use the function step, which will remove and/or add variables one at a time:  reduced_model = step(mdl2, 'nsteps', 20);  Which variables have been removed and which of the remaining ones most likely have the largest influence? 23Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Assignment (older versions than Matlab 2012) 1.Find online the file readVars.m that will read the data file and assign the variables RUT, VISC, ASPH, BASE, RUN, FINES and VOIDS; You can copy and paste this script into your own file. 2.Create the matrix X using the variables from 1 except RUT and a column of ones. 3.Create the vector Y using RUT 4.Fit your model using regress and and alpha = Display the estimated values of beta and the confidence intervals 6.Are any of the values not significantly different from 0, i.e. does 0 lie inside the confidence interval? 24Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression

Assignment (Continued) 7.Generate the Tukey-Anscombe plot. Is there any indication of nonlinearity, non-constant variance or of a skewed distribution of residuals? plotmatrix(aspData(:,1:6), RUT) 8.Plot the response of all the variables using plotmatrix(aspData(:,1:6), RUT). The variables seem to show a rather random response, except for VISC. Try and transform the system by defining  logRUT = log10(RUT); logVISC = log10(VISC); 9.Define a new X matrix and a new Y vector and regress again 10.Comment again on the estimates and their significance 11.Reproduce the Tukey-Anscombe plot. Did anything change? 25Daniel Baur / Numerical Methods for Chemical Engineers / Linear Regression