Starting from:

$30

MAST30025: Linear Statistical Models: Lab 2 Solved

 Show that XTX is a symmetric matrix.
(a) Let 
be a nonsingular 2 × 2 matrix. Show by direct multiplication that

 . 

Find the inverse of 
Is orthogonal? If not, what value of c makes the matrix cX orthogonal?
(a) Find the eigenvalues, and an associated eigenvector for each eigenvalue, of the matrix
 . 

Find an orthogonal matrix P such that PTAP is diagonal.
Write down PTAP for the P given in part (b).
Let

 


Write down the trace of A.
Are the columns of A linearly independent? Justify your answer.
Find the rank of A.
Show that if X is of full rank, then
I − X(XTX)−1XT

is an idempotent matrix.

Prove that a (real) symmetric matrix A is positive semidefinite if and only if all of its eigenvalues are non-negative, and positive definite if and only if all of its eigenvalues are strictly positive. 8. (Not examinable) Prove that for any matrix A
r(A) = r(AT) = r(ATA).

You may use the fact that pre- or post-multiplying by a non-singular matrix does not change the rank.

1

R exercises
The following are taken from Chapter 2 of spuRs (Introduction to Scientific Programming and Simulation Using R).

Give R assignment statements that set the variable z toxab
(xa)b
3x3 + 2x2 + 6x + 1 (try to minimise the number of operations required)
the second-to-last digit of x before the decimal point (hint: use floor(x) and/or %%) (e) z + 1
Give R expressions that return the following matrices and vectors(1,2,3,4,5,6,7,8,7,6,5,4,3,2,1)
(1,2,2,3,3,3,4,4,4,4,5,5,5,5,5)
                       0     1     1 

 1 0 1  1 1 0
                       0     2     3 

 0 5              0 
                           7    0    0

Suppose vec is a strictly positive vector of length 2. Interpreting vec as the coordinates of a point in R2, use R to express it in polar coordinates. You will need (at least one of) the inverse trigonometric functions: acos(x), asin(x), and atan(x).
Use R to produce a vector containing all integers from 1 to 100 that are not divisible by 2, 3, or 7.
Suppose that queue <- c("Steve", "Russell", "Alison", "Liam") and that queue represents a supermarket queue with Steve first in line. Using R expressions update the supermarket queue as successively:Barry arrives;
Steve is served;
Pam talks her way to the front with one item;
Barry gets impatient and leaves;
Alison gets impatient and leaves.
For the last case you should not assume that you know where in the queue Alison is standing.

Finally, using the function which(x), find the position of Russell in the queue.

Note that when assigning a text string to a variable, it needs to be in quotes.

Which of the following assignments will be successful? What will the vectors x, y, and z look like at each stage?
rm(list = ls()) x <- 1 x[3] <- 3 y <- c() y[2] <- 2 y[3] <- y[1] y[2] <- y[4] z[1] <- 0

Build a 10 × 10 identity matrix. Then make all the non-zero elements 5. Do this latter step in at least two different ways.

More products