You are on page 1of 6

Mindanao State University

Iligan Institute of Technology

Multivariate Analysis

Laboratory Exercise
Asaad, Al-Ahmadgaid B.
Student

Baguio, Carolina Bancayrin


Instructor

June 13, 2012

I.

Questions
A. Obtain a Data with two and three response variable. I. Data with three response variables Source: Rencher, A. C. (2002), Methods of Multivariate Analysis, 2nd Edition. pg. 56 Table A.1 Calcium in Soil and Turnip Greens Location Number 1 2 3 4 5 6 7 8 9 10 35 35 40 10 6 20 35 35 35 30 3.5 4.9 30 2.8 2.7 2.8 4.6 10.9 8 1.6 2.8 2.7 4.38 3.21 2.73 2.8 2.88 2.9 3.28 3.2

Table A.1 gives partial data from Kramer and Jensen (1969a). Three variables were measured (in milliequivalents per 100 g) at 10 different locations in the South. The variables are y1 = available soil calcium, y2 = exchangeable soil calcium, and y3 = turnip green calcium. II. Data with two response variables Source: Hardle, W., et al. (2007), Multivariate Statistics: Exercises and Solutions. pg. 336 Sales 1 2 3 4 5 6 7 8 9 10 230 181 165 150 97 192 181 189 172 170 Price 125 99 97 115 120 100 80 90 95 125 Advert 200 55 105 85 0 150 85 120 110 130 Ass. Hours 109 107 98 71 82 103 111 93 86 78

This is a data set consisting of 10 measurements of 4 variables. The story: A textile shop manager is studying the sales of classic blue pullovers over 10 periods. He uses three different marketing methods and hopes to understand his sales as a fit of these variables using statistics. The variables measured are : Numbers of sold pullovers, : Price (in

EUR), : Advertisement costs in local newspapers (in EUR), assistant (in hours per period). B. Compute for the mean vectors

: Presence of a sales

To find the mean vector y, we simply calculate the average of each column and obtain the vector For 2 response variable, we have ( ), you can confirm this below using R programming codes

For 3 response variable, we have ( ), you can confirm this below using R programming codes

C. Find the inverse of the covariance matrix. Formulas: The sample variance of the jth variable, , is calculated as

The sample covariance of the jth and kth variables,

, is calculated as

)(

Check the output in the R Codes and the inverse of it. D. Calculate the determinant of the variance-covariance matrix Answer: For 2 Response Variables = 273601.3 - Refer to the R Codes For 3 Response Variables = 459.9555 - Refer to the R Codes

II.

R Codes Section
R Codes for 2 response variable #INPUT Res2Data <- read.table(header = TRUE, text = " Sales Price 230 125 181 99 165 97 150 115 97 120 192 100 181 80 189 90 172 95 170 125") #The mean of the data #INPUT colMeans(Res2Data) #OUTPUT Sales Price 172.7 104.6 #The variance-covariance matrix is #INPUT M <- var(Res2Data) M #OUTPUT Sales Price Sales 1152.45556 -88.91111 Price -88.91111 244.26667 #The generalized inverse of the variance-covariance matrix is #INPUT library(MASS) ginv(M) #OUTPUT [,1] [,2] [1,] 0.0008927833 0.000324966 [2,] 0.0003249660 0.004212171

#Now, computing the correlation #coefficient R we have, #INPUT cor(Res2Data) #OUTPUT Sales Price Sales 1.000000 -0.167576 Price -0.167576 1.000000 #Computing the determinant #INPUT det(M) #OUTPUT 273601.3 R Codes for 3 response variable #INPUT Res3Data <- read.table(header = y1 y2 35 3.5 35 4.9 40 30.0 10 2.8 6 2.7 20 2.8 35 4.6 35 10.9 35 8.0 30 1.6 #The mean of the data #INPUT colMeans(Res3Data) #OUTPUT y1 y2 28.100 7.180

matrix

with

entries

of

correlation

TRUE, text = " y3 2.80 2.70 4.38 3.21 2.73 2.81 2.88 2.90 3.28 3.20")

y3 3.089

#The variance-covariance matrix is #INPUT N <- var(Res3Data) N

#OUTPUT y1 y2 y3 y1 140.544444 49.680000 1.9412222 y2 49.680000 72.248444 3.6760889 y3 1.941222 3.676089 0.2501211

#The generalized inverse of the variance-covariance matrix is #INPUT Library(MASS) ginv(N) #OUTPUT [,1] [,2] [,3] [1,] 0.009907983 -0.01150092 0.09213458 [2,] -0.011500919 0.06823440 -0.91359688 [3,] 0.092134578 -0.91359688 16.71034335 #Now, computing the correlation #coefficient R we have, #INPUT cor(Res3Data) #OUTPUT y1 y2 y3 y1 1.0000000 0.4930154 0.327411 y2 0.4930154 1.0000000 0.864762 y3 0.3274110 0.8647620 1.000000 #Computing the determinant #INPUT det(M) #OUTPUT 459.9555 matrix with entries of correlation

You might also like