Matrix A matrix is a rectangular array of elements arranged in rows and columns Dimension of a matrix is r x c  r = c  square matrix  r = 1  (row)

Slides:



Advertisements
Similar presentations
 Population multiple regression model  Data for multiple regression  Multiple linear regression model  Confidence intervals and significance tests.
Advertisements

Matrices A matrix is a rectangular array of quantities (numbers, expressions or function), arranged in m rows and n columns x 3y.
CS Example: General Linear Test (cs2.sas)
Matrix Algebra Matrix algebra is a means of expressing large numbers of calculations made upon ordered sets of numbers. Often referred to as Linear Algebra.
Topic 3: Simple Linear Regression. Outline Simple linear regression model –Model parameters –Distribution of error terms Estimation of regression parameters.
3_3 An Useful Overview of Matrix Algebra
MF-852 Financial Econometrics
Maths for Computer Graphics
Multiple regression analysis
Review of Matrix Algebra
Example: Price Analysis for Diamond Rings in Singapore Variables Response Variable: Price in Singapore dollars (Y) Explanatory Variable: Weight of diamond.
Part 3 Chapter 8 Linear Algebraic Equations and Matrices PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The.
Linear regression models in matrix terms. The regression function in matrix terms.
Special Topic: Matrix Algebra and the ANOVA Matrix properties Types of matrices Matrix operations Matrix algebra in Excel Regression using matrices ANOVA.
Matrix Approach to Simple Linear Regression KNNL – Chapter 5.
Intro to Matrices Don’t be scared….
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
CE 311 K - Introduction to Computer Methods Daene C. McKinney
8.4 Matrix Operations Day 1 Thurs May 7 Do Now Solve X – 2y = -6 3x + 4y = 7.
1 Statistical Analysis Professor Lynne Stokes Department of Statistical Science Lecture 5QF Introduction to Vector and Matrix Operations Needed for the.
UnB - Financial Econometrics I Otavio Medeiros 1 The Matrix Otavio R. de Medeiros UnB Programa de Pós-Graduação em Administração Programa Multiinstitucional.
Topic 16: Multicollinearity and Polynomial Regression.
ECON 1150 Matrix Operations Special Matrices
BIOL 582 Lecture Set 19 Matrices, Matrix calculations, Linear models using linear algebra.
THU, JAN 8, 2015 Create a “Big Book of Matrices” flip book using 4 pages. Do not make your tabs big! BIG BOOK OF MATRICES What is a Matrix? Adding & Subtracting.
Topic 2: An Example. Leaning Tower of Pisa Construction began in 1173 and by 1178 (2 nd floor), it began to sink Construction resumed in To compensate.
Topic 7: Analysis of Variance. Outline Partitioning sums of squares Breakdown degrees of freedom Expected mean squares (EMS) F test ANOVA table General.
Topic 14: Inference in Multiple Regression. Outline Review multiple linear regression Inference of regression coefficients –Application to book example.
6-3 Multiple Regression Estimation of Parameters in Multiple Regression.
4.1 Matrix Operations What you should learn: Goal1 Goal2 Add and subtract matrices, multiply a matrix by a scalar, and solve the matrix equations. Use.
Statistics and Linear Algebra (the real thing). Vector A vector is a rectangular arrangement of number in several rows and one column. A vector is denoted.
Regression For the purposes of this class: –Does Y depend on X? –Does a change in X cause a change in Y? –Can Y be predicted from X? Y= mX + b Predicted.
Multiple regression - Inference for multiple regression - A case study IPS chapters 11.1 and 11.2 © 2006 W.H. Freeman and Company.
Matrices Addition & Subtraction Scalar Multiplication & Multiplication Determinants Inverses Solving Systems – 2x2 & 3x3 Cramer’s Rule.
Unit 3: Matrices.
Matrix Algebra and Regression a matrix is a rectangular array of elements m=#rows, n=#columns  m x n a single value is called a ‘scalar’ a single row.
Chapter 4 – Matrix CSNB 143 Discrete Mathematical Structures.
Multivariate Statistics Matrix Algebra I W. M. van der Veld University of Amsterdam.
BIOL 582 Supplemental Material Matrices, Matrix calculations, GLM using matrix algebra.
MBP1010H – Lecture 4: March 26, Multiple regression 2.Survival analysis Reading: Introduction to the Practice of Statistics: Chapters 2, 10 and 11.
Topic 17: Interaction Models. Interaction Models With several explanatory variables, we need to consider the possibility that the effect of one variable.
6-1 Introduction To Empirical Models Based on the scatter diagram, it is probably reasonable to assume that the mean of the random variable Y is.
SAS Interactive Matrix Language Computing for Research I Spring 2012 Ramesh.
Linear algebra: matrix Eigen-value Problems Eng. Hassan S. Migdadi Part 1.
Topic 13: Multiple Linear Regression Example. Outline Description of example Descriptive summaries Investigation of various models Conclusions.
Introduction to Matrices and Matrix Approach to Simple Linear Regression.
ANOVA: Graphical. Cereal Example: nknw677.sas Y = number of cases of cereal sold (CASES) X = design of the cereal package (PKGDES) r = 4 (there were 4.
Slide Copyright © 2009 Pearson Education, Inc. 7.3 Matrices.
Special Topic: Matrix Algebra and the ANOVA Matrix properties Types of matrices Matrix operations Matrix algebra in Excel Regression using matrices ANOVA.
MATRICES MATRIX OPERATIONS. About Matrices  A matrix is a rectangular arrangement of numbers in rows and columns. Rows run horizontally and columns run.
Sec 4.1 Matrices.
Unit 3 Matrix Arithmetic IT Disicipline ITD 1111 Discrete Mathematics & Statistics STDTLP 1 Unit 3 Matrix Arithmetic.
Algebra Matrix Operations. Definition Matrix-A rectangular arrangement of numbers in rows and columns Dimensions- number of rows then columns Entries-
Matrices and Determinants
Matrices and Matrix Operations. Matrices An m×n matrix A is a rectangular array of mn real numbers arranged in m horizontal rows and n vertical columns.
Anareg Week 10 Multicollinearity Interesting special cases Polynomial regression.
Linear System of Simultaneous Equations Warm UP First precinct: 6 arrests last week equally divided between felonies and misdemeanors. Second precinct:
Unit 3: Matrices. Matrix: A rectangular arrangement of data into rows and columns, identified by capital letters. Matrix Dimensions: Number of rows, m,
Precalculus Section 14.1 Add and subtract matrices Often a set of data is arranged in a table form A matrix is a rectangular.
Matrix Algebra Basics Chapter 3 Section 5. Algebra.
Matrices. Variety of engineering problems lead to the need to solve systems of linear equations matrixcolumn vectors.
1 Experimental Statistics - week 11 Chapter 11: Linear Regression and Correlation.
Linear Algebraic Equations and Matrices
Linear Algebraic Equations and Matrices
7.3 Matrices.
Matrices Definition: A matrix is a rectangular array of numbers or symbolic elements In many applications, the rows of a matrix will represent individuals.
MATRICES MATRIX OPERATIONS.
Unit 3: Matrices
MATRICES MATRIX OPERATIONS.
MATRICES MATRIX OPERATIONS.
Presentation transcript:

Matrix A matrix is a rectangular array of elements arranged in rows and columns Dimension of a matrix is r x c  r = c  square matrix  r = 1  (row) vector  c = 1  column vector

Matrix (cont) elements are either numbers or symbols each element is designated by the row and column that it is in, a ij  rows are indicated by an i subscript  columns are indicated by a j subscript

Matrix Equality two matrices are said to be equal if they have the same dimensions and all of the corresponding elements are equal

Equality: Example Are the following matrices equal? a) b)

Matrix Operations - Transpose A transposition is performed by switching the rows and columns, indicated by a ‘  A’ = B if a ij = b ji Note: if A is r x c then B will be c x r  The transpose of a column vector is a row vector.

Matrix Operations – Addition/Subtraction To add or subtract two matrices, they must have the same dimensions The addition or subtraction is done on an element by element bases

Matrix Operations - Multiplication by a scalar (number)  every element of the matrix is multiplied by that number  In addition, a matrix can be factored  if A = [a ij ], k is a number then kA = Ak = [ka ij ]

Matrix Operations - Multiplication by another matrix – C = A B columns of A must equal rows of B Resulting matrix has dimension rows of A x columns of B

Special Types of Matrices: Symmetric if A = A’, then A is said to be symmetric  a symmetric matrix has to be a square matrix

Special Types of Matrices: Diagonal Square matrix with off-diagonal elements equal to 0.

Special Types of Matrices: Diagonal (cont) Identity  also called the unit matrix, designated by I  a diagonal matrix where the diagonal elements are 1  It is called the identity matrix because for any matrix A AI = IA = A

Linear Dependence Think of the columns of a matrix as column vectors if it can be found that not all of k 1 to k c are 0 in the following equation then the c columns are linearly dependent. k 1 C 1 + k 2 C 2 +  + k c C c = 0  In the example -2C 1 + 0C 2 + 1C 3 = 0  if they all 0, then they are linearly independent.

Rank of a Matrix The rank of a matrix is the maximum number of linearly independent columns.  This is a unique number for every matrix  rank of the matrix cannot exceed min(r,c)  Full Rank – all columns are linearly independent  Example: Rank = 2

Inverse of a Matrix Inverse in algebra: – reciprocal – Inverse for a matrix – A A -1 = A -1 A = I – A must be square and full rank

Inverse of a Matrix: Calculation Diagonal Matrix

Inverse of a Matrix: Calculation (cont) 2 x 2 Matrix 1.Calculate the Determinant: D = ad – bc If D = 0, then the matrix doesn’t have full rank (singular) and does not have an inverse. 2.A -1 : switch a and d, make b and c negative, divide by D. 3 x 3 Matrix: in the book

Inverse of a Matrix: Uses In algebra, we use the inverse to solve algebraic equations. In matrix algebra, we use the inverse of a matrix to solve matrix algebraic equations: A X = C A -1 A X = A -1 C X = A -1 C

Basic Matrix Operations A + B = B + A (A + B) + C = A + (B + C) k(A + B) = k A + kB (A’)’ = A (A + B)’ = A’ + B’ (AB)’ = B’ A’ (ABC)’ = C’B’ A’ (AB)C = A(BC) C(A + B) = C A + CB (A -1 ) -1 = A (A’) -1 = (A -1 )’ (AB) -1 = B -1 A -1 (ABC) -1 = C -1 B -1 A -1

Matrix parameters

Matrix parameters (cont)

Fitted Values

Response Vector: additive (Surface.sas) Ŷ i = X i, X i,2

SAS code: MLR proc reg data = a1; model y = x1 x2 x3; run;

Response Vector: polynomial (Surface.sas) Ŷ i = X i,1 – 4.02 X 2 i, X i, X 2 i,2

Response Vector: Interaction(Surface.sas) Ŷ i = X i, X i,2 – 1.24 X i,1 X i,2

SAS code: MLR data a2; set a1; xsq = x*x; x12 = x1*x2; proc reg data=a2; model y = x xsq x1 x2 x12; run;

CS Example: all predictors (output ) Analysis of Variance SourceDFSum of Squares Mean Square F ValuePr > F Model <.0001 Error Corrected Total Root MSE R-Square Dependent Mean Adj R-Sq Coeff Var Parameter Estimates VariableDFParameter Estimate Standard Error t ValuePr > |t| Intercept hsm hss hse satm satv

ANOVA table for MLR SourcedfSSMSFp Model (Regression) p – 1Σ(Ŷ i - Y̅) 2 p Errorn – pΣ(Y i - Ŷ i ) 2 Totaln - 1Σ(Y i - Y̅) 2

CS Example: all predictors (output ) Analysis of Variance SourceDFSum of Squares Mean Square F ValuePr > F Model <.0001 Error Corrected Total Root MSE R-Square Dependent Mean Adj R-Sq Coeff Var Parameter Estimates VariableDFParameter Estimate Standard Error t ValuePr > |t| Intercept hsm hss hse satm satv

CS Example: (cs.sas) Y i : GPA after 3 semesters X 1 : High school math grades (HSM) X 2 : High school science grades (HSS) X 3 : High school English grades (HSE) X 4 : SAT Math (SATM) X 5 : SAT Verbal (SATV) Gender: (1 = male, 2 = female) n = 224

CS Example: Input (cs.sas) data cs; infile 'I:\My Documents\Stat 512\csdata.dat'; input id gpa hsm hss hse satm satv genderm1; proc print data=cs; run;

CS Example: all predictors (input) proc reg data=cs; model gpa=hsm hss hse satm satv; run;

CS Example: all predictors (output ) Analysis of Variance SourceDFSum of Squares Mean Square F ValuePr > F Model <.0001 Error Corrected Total Root MSE R-Square Dependent Mean Adj R-Sq Coeff Var Parameter Estimates VariableDFParameter Estimate Standard Error t ValuePr > |t| Intercept hsm hss hse satm satv

CS Example: HS grades proc reg data=cs; model gpa=hsm hss hse; run; Root MSE R-Square Dependent Mean Adj R-Sq Parameter Estimates VariableDFParameter Estimate Standard Error t ValuePr > |t| Intercept hsm <.0001 hss hse

CS Example: hsm, hse proc reg data=cs; model gpa=hsm hse; run; Root MSE R-Square Dependent Mean Adj R-Sq Parameter Estimates VariableDFParameter Estimate Standard Error t ValuePr > |t| Intercept hsm <.0001 hse

CS Example: hsm proc reg data=cs; model gpa=hsm; run; Root MSE R-Square Dependent Mean Adj R-Sq Parameter Estimates VariableDFParameter Estimate Standard Error t ValuePr > |t| Intercept hsm <.0001

CS Example: SAT proc reg data=cs; model gpa=satm satv; run; Root MSE R-Square Dependent Mean Adj R-Sq Parameter Estimates VariableDFParameter Estimate Standard Error t ValuePr > |t| Intercept satm satv

CS Example: satm proc reg data=cs; model gpa=satm; run; Root MSE R-Square Dependent Mean Adj R-Sq Parameter Estimates VariableDFParameter Estimate Standard Error t ValuePr > |t| Intercept satm

CS Example: hsm, satm proc reg data=cs; model gpa=hsm satm/clb; run; Root MSE R-Square Dependent Mean Adj R-Sq Parameter Estimates VariableDFParameter Estimate Standard Error t ValuePr > |t|95% Confidence Limits Intercept hsm < satm

Studio Example: (nknw241.sas) Y: Sales X 1 : Number of people younger than 16 (young) X 2 : disposable personal income (income) n = 21

Studio Example: input (nknw241.sas) data a1; infile 'I:/My Documents/Stat 512/CH06FI05.DAT'; input young income sales; proc print data=a1; run; Obsyoungincomesales

Studio Example: Regression, CI proc reg data=a1; model sales=young income/clb; run;

Studio Example: Regression, CI Analysis of Variance SourceDFSum of Squares Mean Square F ValuePr > F Model <.0001 Error Corrected Total Root MSE R-Square Dependent Mean Adj R-Sq Coeff Var Parameter Estimates VariableDFParameter Estimate Standard Error t ValuePr > |t|95% Confidence Limits Intercept young < income

Studio Example: CI for the mean proc reg data=a1; model sales=young income/clm; id young income; run; Output Statistics ObsyoungincomeDependent Variable Predicted Value Std Error Mean Predict 95% CL MeanResidual « The MEANS Procedure

Studio Example: CI for predicted values proc reg data=a1; model sales=young income/cli; id young income; run; Output Statistics ObsyoungincomeDependent Variable Predicted Value Std Error Mean Predict 95% CL PredictResidual «

CS Example: Descriptive Statistics (cs.sas) proc means proc means data=cs maxdec=2; var gpa hsm hss hse satm satv; run; VariableNMeanStd DevMinimumMaximum gpa hsm hss hse satm satv

CS Example: Descriptive Statistics proc univariate proc univariate data=cs noprint; var gpa hsm hss hse satm satv; histogram gpa hsm hss hse satm satv /normal kernel; run;

CS Example: Descriptive Statistics (cont) proc univariate gpahsm hsshse

CS Example: Descriptive Statistics (cont) proc univariate satmsatv

Interactive Data Analysis 1.Read in the data set as usual. 2.Solutions --> analysis --> interactive data analysis 3.To read in the correct data set a.Open library work b.Click on data set CS c.Click on open 4.Select the variables that you want, use to select more than one a.Go to the menu analyze b.Choose option Scatter Plot (Y X)

CS Example: Interactive Scatterplot

CS Example: Scatterplot proc sgscatter data=cs; matrix gpa satm satv; run;

CS Example: Correlation proc corr data=cs; var hsm hss hse; Pearson Correlation Coefficients, N = 224 Prob > |r| under H0: Rho=0 hsmhsshse hsm <.0001 hss <.0001 hse <.0001

CS Example: Correlation (cont) proc corr data=cs noprob; var satm satv; Pearson Correlation Coefficients, N = 224 satmsatv satm satv

CS Example: Correlation (cont) proc corr data=cs noprob; var hsm hss hse; with satm satv; Pearson Correlation Coefficients, N = 224 hsmhsshse satm satv

CS Example: Correlation (cont) proc corr data=cs noprob; var hsm hss hse satm satv; with gpa; Pearson Correlation Coefficients, N = 224 hsmhsshsesatmsatv gpa

CS Example: Scatter plots (cs1.sas)

CS Example: residuals vs. Ŷ

CS Example: Residuals vs X i ’s

CS Example: Normality of Residuals