STAT 510 Homework 6 Solutions Spring 2017

STAT 510
Homework 6 Solutions
Spring 2017
1. (a) In general, we have H0j : (Pj+1 − Pj )Xβ = 0 in ANOVA F test, so cj is any non-zero
row of (Pj+1 − Pj )X.
So, we can obtain using R code below as we did on slides 45 and 46 of slide set 6.
0
c1 = 2, 1, 0, −1, −2
for linear trend
0
c2 = 2, −1, −2, −1, 2
for quadratic trend
0
c3 = 1, −2, 0, 2, −1
for cubic trend
0
c4 = 1, −4, 6, −4, 1
for quartic trend
> d=read.delim("https://dnett.github.io/S510/PlantDensity.txt")
> names(d)=c("x","y")
> n=nrow(d)
> x=(d$x-mean(d$x))/10
> x1=matrix(1,nrow=n,ncol=1)
> x2=cbind(x1,x)
> x3=cbind(x2,x^2)
> x4=cbind(x3,x^3)
> x5=matrix(model.matrix(~0+factor(x)),nrow=n)
> proj <- function(x) {
+
x %*% MASS::ginv(t(x) %*% x) %*% t(x)
+ }
> p1=proj(x1)
> p2=proj(x2)
> p3=proj(x3)
> p4=proj(x4)
> p5=proj(x5)
> ((p2-p1)%*%x5)[1,] *5 ## linear
[1] 2 1 0 -1 -2
> ((p3-p2)%*%x5)[1,] *7 ## quadratic
[1] 2 -1 -2 -1 2
> ((p4-p3)%*%x5)[1,] *10 ## cubic
[1] 1 -2 0 2 -1
> ((p5-p4)%*%x5)[1,] *70 ## quartic
[1] 1 -4 6 -4 1
(b) All c0i β are contrast because c0i 1 = 0 for i = 1, 2, 3, 4.
(c) By slide 3 of set 9, any two estimable linear combinations c0i β and c0j β are orthogonal if
and only if c0i (X 0 X)− cj = 0 for i 6= j. In the plant density example of slide set 6, the
model matrix is


1
3×1


1


3×1




1
X=

3×1




1


3×1
1
3×1



1
3
3
 3

 1



 3 1

0
0
−1




3
XX=
3
 and (X X) = 

1



3 
3
1
3
3
1
Thus in this case, c0i (X 0 X)− cj = c0i cj /3, so that linear combinations c0i β and c0j β are
orthogonal if and only if c0i cj = 0.
In this problem, all c0i β’s are orthogonal because c0i cj = 0 for all pairs {(i, j)|i 6= j}
where i, j = 1, 2, 3, 4.
2. Given H is a symmetric matrix, by spectral decompositon theorem H =
n
P
λi pi p0i , where
i=1
pi ’s are orthonomal eigenvectors of H.
“ =⇒ ” part:
By definition, H is nonnegative definite =⇒ p0i Hpi > 0 for any pi that i = 1, · · · , n.
!
n
X
0
0
0
pi Hpi = pi
λ j pj pj pi
j=1
=
n
X
λj p0i pj p0j pi
p0i pj = 0 for all i 6= j
j=1
= λi p0i pi p0i pi
= λi
p0i pi = 1
Therefore λi > 0 for i = 1, · · · , n.
“⇐=” part: given λi > 0 for i = 1, · · · , n, need to prove y 0 Hy > 0 for any n × 1 vector y.
!
n
X
∀y, y 0 Hy = y 0
λj pj p0j y
by spectral decompositon
j=1
=
=
=
n
X
j=1
n
X
j=1
n
X
λj y 0 pj p0j y
let y 0 pj = xj which is a value and xj = x0j
λj xj x0j
λj x2j > 0
since λi > 0 and x2j > 0 for i = 1, · · · , n
j=1
So, H is nonnegative definite ⇐⇒ all its eigenvalues are nonnegative.
iid
3. yi = µ + |xi |i for i = 1, · · · , n and i ∼ N (0, σ 2 ).
we can write the model as

y = 1 · µ + δ,
n×1

|x1 |1
 |x2 |2 


where δ =  ..  ∼ N (0, σ 2 V )
 . 
|xn |n
V = diag(x21 , x22 , · · · , x2n ) and is positive definite because all xi ’s are nonzero. So this is an
Aitken model with normal errors.
2
µ is obviously estimable, so the BLUE is
−
µ̂ = 10 V −1 1 10 V −1 y
−2
−2
= [x−2
1 , x2 , · · · , xn ]1
n
P
x−2
i yi
i=1
= P
n
x−2
i
−1
−2
−2
[x−2
1 , x2 , · · · , xn ]y
i=1
4. (a) Rewrite these hypotheses in terms of the parameter vector.
H0 : α2 = 0 vs. HA : α2 6= 0
(b) If we want to fit a reduced model corresponding to the null hypothesis, we could use W1 .
(c) Provide a matrix C for testing the main effect of time.
The main effect of time is


µ
11

1
1
1 1
1
1 
µ12 
(µ11 + µ12 ) − (µ21 + µ22 ) =
,
, − , −

µ21 
2
2
2 2
2
2
µ22
1 1
1
1
So one possible matrix C is
,
, − , − .
2 2
2
2
(d) Provide a matrix A so that the rank of B is 4.


1 0 0 0
A = 0 1 0 0
0 0 1 0
(e) Provide a model matrix for a reduced model that corresponds to the null hypothesis of
no time main effect.


1
2×1



1
−1


3×1
W = XB = 

1


4×1
1
1 −1 −2
Therefore the model matrix of the reduced model is the first p − q = 3 columns of W .


1
2×1



1


3×1
W1 = 

1


4×1
1
1 −1
3
(f) Find the error sum of squares for the reduced and full models.
SSReduced = y 0 (I − PW1 )y = 24
SSF ull = y 0 (I − PW )y = 12
(g) Find the degrees of freedom associated with the sums of squares in part (f).
dfReduced = rank(I − PW1 ) = 10 − 3 = 7
dfF ull = rank(I − PW ) = 10 − 4 = 6
(h) Compute the F -statistic for testing the null hypothesis of no time main effect using the
sums of squares and degrees of freedom computed in parts (f) and (g).
From the code and output below,
F =
>
>
>
>
>
+
+
>
>
>
>
>
>
>
(SSEReduced − SSEF ull )/(dfReduced − dfF ull )
=6
SSEF ull /dfF ull
X <- model.matrix(~ 0 + factor(c(1, 1, rep(2, 3), rep(3, 4), 4)))
B <- rbind(cbind(diag(3), 0), .5 * c(1, 1, -1, -1))
W <- X %*% solve(B)
W1 <- W[, -4]
proj <- function(x) {
x %*% MASS::ginv(t(x) %*% x) %*% t(x)
}
Pw <- proj(W)
Pw1 <- proj(W1)
y <- c(3, 5, 11, 13, 15, 5, 6, 6, 7, 16)
I10 <- diag(rep(1, length(y)))
SS.red <- t(y) %*% (I10 - Pw1) %*% y
SS.full <- t(y) %*%(I10 - Pw) %*% y
(SS.red - SS.full) / SS.full * 6
4