Tutorial 4 solutionrevised

.docx
School
University of KwaZulu-Natal - Pietermaritzburg **We aren't endorsed by this school
Course
STAT 301
Subject
Statistics
Date
Jun 25, 2023
Pages
6
Uploaded by Mpilo77 on coursehero.com
Tutorial 4 solutions 1. a) Proc iml ; /* Enter matrices X, L1, L2, L3 and G using the following SAS code*/ X = { 1 1 0 0 , 1 1 0 0 , 1 1 0 0 , 1 0 1 0 , 1 0 1 0 , 1 0 0 1 }; G = { 0 0 0 0 , 0 %sysevalf ( 1 / 3 ) 0 0 , 0 0 %sysevalf ( 1 / 2 ) 0 , 0 0 0 1 }; L1 = { 0 5 - 6 1 , 0 1 0 - 1 }; h = { 0 , 60 }; L2 = { 1 1 0 0 }; L3 = { 0 1 - 1 0 , 0 0 1 - 1 }; /* Enter a column vector y*/ y={ 101 , 105 , 94 , 84 , 88 , 32 }; r= round(trace(ginv(X)*X)); /* rank of matrix X */ k1= round(trace(ginv(L1)*L1)); /* rank of matrix L1 */ k2= round(trace(ginv(L2)*L2)); /* rank of matrix L2 */ k3= round(trace(ginv(L3)*L3)); /* rank of matrix L3 */ B=G*t(X)*y; /* ¿ X' y ^ β =( X ' X ) ¿ */ LL1=L1*G*t(X)*X; /* To verify whether hypothesis "a" is testable or not */ LL2=L2*G*t(X)*X; /* To verify whether hypothesis "b" is testable or not */ LL3=L3*G*t(X)*X; /* To verify whether hypothesis "c" is testable or not */ /* find the SST, SSE, SSH_a, SSH_b, SSH_c*/ SST=t(y)*y; /* SST= y' y */ SSR=t(X*B)*(X*B); /* SSR= ^ y ' ^ y */ SSE=SST-SSR; MSE= SSE/(6-r); /* MSE=SSE/n-r */ SSH_a=t(L1*B-h)*inv(L1*G*t(L1))*(L1*B-h); /* SSH for question a */ SSH_b=t(L2*B)*inv(L2*G*t(L2))*(L2*B); /* SSH for question b */ SSH_c=t(L3*B)*inv(L3*G*t(L3))*(L3*B); /* SSH for question c */ F_a=(SSH_a/k1)/MSE; F_b=(SSH_b/k2)/MSE; F_c=(SSH_c/k3)/MSE; /* F calculated for question a,b and c */ print r, k1, k2,k3, B, SSH_a, SSH_b, SSH_c, SSE, LL1, LL2, LL3,F_a, F_b, F_c; ¿ X ' X = [ 0 5 6 0 0 1 0 1 ] = L 1, the h ypothesisistestable a ¿ Since L 1 ( X ' X ) ¿ ¿ X ' X = [ 1100 ] = L 2, the hypothesisistestable b ¿ Since L 2 ( X ' X ) ¿ c) ¿ X ' X = [ 0 1 1 0 0 0 1 1 ] = L 3 Since L 3 ( X ' X ) ¿ , the hypothesisistestable Step 3: Statistic : F Reject Ho if F > F 1 α ( k ,n r ) = F 0.95 ( 2,3 ) = 9.55 Step 2: α = 0.05 Step 1: H 0 : [ 5 α 1 6 α 2 + α 3 α 1 α 3 ] = [ 0 60 ] vs H 1 : not Ho Step 4: Calculation ( ANOVA table ) SSH_a = 53.33 SSE=SST-SSR=70
b) Source of variations df Sum of square Mean square F treatment 1 30000 30000 1285.7143 Error 3 70 23.33 Total 4 30070 Step 5: Decision: Since F=1285.7143> F 0.95 ( 1,3 ) = 10.128, We conclude that at 5% level of significance that we reject the null hypothesis H 0 . c) Step 5: Decision: Since F=1.14 < F 0.95 ( 2,3 ) = 9.55, We conclude that at 5% level of significance that we do not reject the null hypothesis H 0 . Step 3: Statistic : F Reject Ho if F > F 1 α ( k ,n r ) = F 0.95 ( 1,3 ) = 10.128 Step 2: α = 0.05 Step 1: H 0 : μ + α 1 = 0 vs H 1 : not Ho Step 4: Calculation ( ANOVA table ) SSH_b = 30000 SSE=SST-SSR=70 Step 1: H 0 : [ α 1 α 2 α 2 α 3 ] = [ 0 0 ] vs H 1 : not Ho Step 2: α = 0.05 Step 3: Statistic : F Reject Ho if F > F 1 α ( k ,n r ) = F 0.95 ( 2,3 ) = 9.55 Source of variations df Sum of square Mean square F Treatment 2 53.33 26.665 1.14 Error 3 70 23.33 Total 5 123.33
Step 5: Decision: Since F=74.58> F 0.95 ( 2,3 ) = 9.55, We conclude that at 5% level of significance that we reject the null hypothesis H 0 . 2. Step 4: Calculation ( ANOVA table ) SSH _c = 3480 SSE=SST-SSR=70 Proc iml ; /* Enter matrices X, and L using the following SAS code*/ X = { 1 1.32 1.15 , 1 2.69 3.4 , 1 3.56 4.1 , 1 4.41 8.75 , 1 5.35 14.82 , 1 6.2 15.15 , 1 7.12 15.32 , 1 8.87 18.18 , 1 9.8 35.19 , 1 10.65 40.4 }; L = { 1 -1 0 , 0 1 -1}; /* Enter a column vector y*/ y={ 6.4 , 15.05 , 18.75 , 30.25 , 44.85 , 48.94 , 51.55 , 61.5 , 100.44 , 111.42 }; p= round(trace(ginv(X)*X)); /* rank of matrix X */ k= round(trace(ginv(L)*L)); /* rank of matrix L */ /* find LS solutions of (X'X)B=X'y*/ I_XX=inv(t(X)*X); /* ( X ' X ) 1 */ t_Xy=t(X)*y; /* X ' y */ B=I_XX*t_Xy; /* ^ β =( X ' X ) 1 X ' y */ /* find the SST, SSE, SSH*/ SST=t(y)*y; /* SST=y'y */ SSR=t(X*B)*(X*B); /* SSR= ^ y ' ^ y */ SSE=SST-SSR; MSE= SSE/ (10-p) ; /* MSE=SSE/n-p */ SSH=t(L*B)*inv(L*inv(t(X)*X)*t(L))*(L*B); /* SSH */ F=(SSH/ k )/MSE; print p, k, B, SSH, SSE, MSE, F, I_XX, t_Xy; run ; Source of variations df Sum of square Mean square F treatment 2 3480 1740 74.58 Error 3 70 23.33 Total 5 3550
Page1of 6
Uploaded by Mpilo77 on coursehero.com