Docsity

STAT 243 Assignment 3: Cholesky Decomp., ANOVA, Orthogonalization & Regression - Prof. P. , Assignments of Statistics

Toggle sidebar
bg1
STAT 243 ASSIGNMENT 3 FALL, 2009
due Dec 2, 2009
1. Cholesky Decomposition
Write and test a function for the Cholesky decomposition of a symmetric positive definite matrix. Test
it on an arbitrary symmetric positive definite matrix, and verify that it works through multiplication
or using R or matlab.
2. Simulation
In a one-way ANOVA, we test the null hypothesis that the means of several different groups are all
equal to each other. Let xij represent the jth observation in the ith group, with i= 1, . . . , k and
j= 1, . . . , ni. Then a suitable test statistic for the null hypothesis is:
F=Pk
i=1 ni( ¯xi−¯x)2/(k−1)
Pk
i=1 Pni
j=1(xij −¯xi)2/(N−k)
where
¯xi= (1/ni)
ni
X
j=1
xij,¯x= (1/N )
k
X
i=1
ni
X
j=1
xij,and N=
k
X
i=1
ni
Under the null hypothesis of the means being equal for all k groups, the statistic Ffollows the F-
distribution with k−1 and N−kdegrees of freedom.
(a) Generate 5 groups of data, each with 6 uncorrelated observations from a normal distribution
with mean 0 and variance 1. (This means that in the formulas above, k= 5, and ni= 6 for
i= 1,...,5 .) Use your programs from assignment 2 to generate the random numbers. Test to see
if the F-statistic described above follows an F-distribution by comparing the upper 90th, 95th and
99th percentiles of your observed F-statistics with their theoretical values found either in tables
or from the appropriate dcdflib routine. (You’ll need to sort your data to find the percentiles;
either use routines from a subroutine library such as the GNU Scientific Library (libgsl), or
“borrow” the function in sort.c from the s243 class account – i.e. - ~s243/samples/sort.c)
(b) Repeat part a), but instead of using 6 uncorrelated observations in each of the 5 groups, generate
6 correlated variables with corr(xi,xj) = .7|i−j|. What does this tell you about the b ehavior of
the F-statistic in a one-way ANOVA when the data is correlated?
3. Gram-Schmidt orthogonalization
Write and test a function for the Gram-Schmidt orthogonalization of an arbitrary n×pmatrix. Test it
on a matrix of your choice, and verify that it works either through multiplication or using R or matlab.
4. Regression using Gram-Schmidt orthogonalization
Write a program which takes as input a matrix of Xand yvalues and then performs a regression using
the function for Gram-Schmidt orthogonalization that you wrote in part 3. The output of the program
should include the parameter estimates, the standard errors of the parameters, the estimated value of
σ2and the residual value for each observation.
Hints: Let Xb e n×pand ybe n×1. If you use the augmented matrix X:yinstead of just X,
and orthogonalize only the first p columns, then the last column of the orthogonalized matrix will be
the residuals. To get the standard errors of the parameter estimates, you may need to invert an upper
triangular matrix. You can use the following algorithm. Let T be a p×pupper triangular matrix, and
let U be it’s inverse.
for j=pto 1 by −1
ujj = 1/tjj
for k=j−1 to 1 by −1
ukj =−(Pj
i=k+1 tkiuij )/tkk
end
end

Partial preview of the text

Download STAT 243 Assignment 3: Cholesky Decomp., ANOVA, Orthogonalization & Regression - Prof. P. and more Assignments Statistics in PDF only on Docsity!

STAT 243 ASSIGNMENT 3 FALL, 2009

due Dec 2, 2009

1. Cholesky Decomposition

Write and test a function for the Cholesky decomposition of a symmetric positive definite matrix. Test it on an arbitrary symmetric positive definite matrix, and verify that it works through multiplication or using R or matlab.

2. Simulation

In a one-way ANOVA, we test the null hypothesis that the means of several different groups are all equal to each other. Let xij represent the jth observation in the ith group, with i = 1,... , k and j = 1,... , ni. Then a suitable test statistic for the null hypothesis is:

F =

∑k i=1 ni( ¯xi^ −^ x¯) (^2) /(k − 1) ∑k i=

∑ni j=1(xij^ −^ x¯i) (^2) /(N − k)

where

x¯i = (1/ni)

∑^ ni

j=

xij , x¯ = (1/N )

∑^ k

i=

∑^ ni

j=

xij , and N =

∑^ k

i=

ni

Under the null hypothesis of the means being equal for all k groups, the statistic F follows the F- distribution with k − 1 and N − k degrees of freedom.

(a) Generate 5 groups of data, each with 6 uncorrelated observations from a normal distribution with mean 0 and variance 1. (This means that in the formulas above, k = 5, and ni = 6 for i = 1,... , 5 .) Use your programs from assignment 2 to generate the random numbers. Test to see if the F-statistic described above follows an F-distribution by comparing the upper 90th, 95th and 99th percentiles of your observed F-statistics with their theoretical values found either in tables or from the appropriate dcdflib routine. (You’ll need to sort your data to find the percentiles; either use routines from a subroutine library such as the GNU Scientific Library (libgsl), or “borrow” the function in sort.c from the s243 class account – i.e. - ~s243/samples/sort.c) (b) Repeat part a), but instead of using 6 uncorrelated observations in each of the 5 groups, generate 6 correlated variables with corr(xi, xj ) =. 7 |i−j|. What does this tell you about the behavior of the F-statistic in a one-way ANOVA when the data is correlated?

3. Gram-Schmidt orthogonalization

Write and test a function for the Gram-Schmidt orthogonalization of an arbitrary n × p matrix. Test it on a matrix of your choice, and verify that it works either through multiplication or using R or matlab.

4. Regression using Gram-Schmidt orthogonalization

Write a program which takes as input a matrix of X and y values and then performs a regression using the function for Gram-Schmidt orthogonalization that you wrote in part 3. The output of the program should include the parameter estimates, the standard errors of the parameters, the estimated value of σ^2 and the residual value for each observation. Hints: Let X be n × p and y be n × 1. If you use the augmented matrix X : y instead of just X, and orthogonalize only the first p columns, then the last column of the orthogonalized matrix will be the residuals. To get the standard errors of the parameter estimates, you may need to invert an upper triangular matrix. You can use the following algorithm. Let T be a p × p upper triangular matrix, and let U be it’s inverse.

for j = p to 1 by − 1 ujj = 1/tjj for k = j − 1 to 1 by − 1 ukj = −(

∑j i=k+1 tkiuij^ )/tkk end end