You are on page 1of 2

Lab 3: Multiple regression Analysis/Multivariate Normal Variates

By Omari C.O
1. Determine the output from the following R code. (6 marks)
A <- matrix(c(0, 5, 7, -2, 7, 7, -1, 1, 4), nrow=3)
eigen(A)

2. Given the data in the table below:

y 5 20 27 38 53 57 62 66
x1 3 5 6 7 9 10 12 12
x2 0 -1 0 1 -1 0 -1 2

(i) Write down the predictor matrix X and the response vector y. (2 marks)
(ii) Compute XT X, (XT X)1 and XT y. (7 marks)
(iii) Determine the least-square estimates of 0 , 1 and 2 using the matrix notations and
write the fitted equation, assuming that

E{Y } = 0 + 1 x1 + 2 x2 .

(2 marks)
(iv) Estimate E{Y } at x1 = x2 = 2. (1 mark)

3. Given the model yi = 0 + 1 x1i + 2 x2i + i and the following data:

y 10 25 32 43 58 62 67 71
x1 1 3 4 5 7 8 10 10
x2 0 -1 0 1 -1 0 -1 2

Estimate 0 , 1 and 2 by OLS using the matrix approach method.

4. The data in the accompanying table relate grams plant dry weight Y to percent soil organic
matter X1 , and Kilograms of supplemental soil nitrogen added per 1000 square meters X2 :

Y X1 X2
78.5 7 2.6
74.3 1 2.9
104.3 11 5.6
87.6 11 3.1
95.9 7 5.2
109.2 11 5.5
102.7 3 7.1
Sums: 652.5 51 32.0
Means: 93.21 7.29 4.57

(a) Define Y, X, , and  for a model involving both independent variables and an intercept.
(b) Compute X0 X and X0 Y.
Statistical programming II

(c) (X0 X)1 for this problem is



1.7995972 .0685472 .2531648
(X0 X)1 = .0685472 .0100774 .0010661
.2531648 .0010661 .0570789
Verify that this is the inverse of (X0 X)1 . Compute and write the regression equation.
Interpret each regression coefficient. What are the units of measure attached to each
regression coefficient?
(d) Compute Y and e.
(e) Use the data in the previous question. Center each independent variable by subtracting
the column mean from each observation in the column. Compute X0 X, X0 Y, and using
the centered data. Were the computations simplified by using centered data? Show that
the regression equation obtained using centered data is equivalent to that obtained with
the original uncentered data.

5. (a) Generate a 1000 2 matrix N of iid standard Normal rvs; denote its columns by X and
Y.
(b) Create a 1000 3 matrix C with columns
C1 = X + Y
C2 = X Y
C3 = 2X + 3Y
Find the generalized variance of C; discuss
(c) Find the lineally dependent columns using the spectral decomposition approach.
6. (a) Generate 1000 multivariate Normal rvs with zero mean and variance covariance matrix
 
12 4
=
4 5
(b) Find the linear combination that transforms your rv to a standard 2-D Normal rv.
7. Generate 500 multivariate Normal rvs with zero mean and variance-covariance matrix

10 4 1
= 4 5 4
1 4 10
Check the data multi-normality using the 2 test based on statistical distances.
8. Generate 200 random variates from a multivariate normal distribution with mean vector,
= (1 2 )0 = (50 30)0 and positive-definite matrix,
 2   
1 12 50 30 1
= =
21 22 30 100
You will need a storage bin for each vector of variates. Write a function to find the correlation
of these 200 bivariate pairs using the built in R function cor(). Your input will have two
arguments that will each take on a vector of numbers. Return the value of the correlation.
1
To generate random bivariate normal variates in R use the mvrnorm(x, mu=, sigma=) in the MASS library. Just
note that mu is a vector and sigma is a matrix.

STA 2311 Page 2 of 2

You might also like