Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

tut4_solution

The document provides solutions to various statistical problems, including finding eigenvalues and eigenvectors, performing singular value decomposition, and conducting chi-squared tests. It includes detailed calculations and results for multiple questions related to matrix operations and statistical analysis. The findings indicate relationships and associations in the data analyzed.

Uploaded by

Chan Hufflepuff
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

tut4_solution

The document provides solutions to various statistical problems, including finding eigenvalues and eigenvectors, performing singular value decomposition, and conducting chi-squared tests. It includes detailed calculations and results for multiple questions related to matrix operations and statistical analysis. The findings indicate relationships and associations in the data analyzed.

Uploaded by

Chan Hufflepuff
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

STAT3613

Tutorial 4 Solution

Q1
5 4 −2
= 4 5 2
−2 2 8

To find eigenvalues
| − |=0
5− 4 −2
4 5− 2 =0
−2 2 8−
(5 − )(5 − )(8 − ) − 16 − 16 − 4(5 − ) − 4(5 − ) − 16(8 − ) = 0
− ( − 9) = 0
= 9,9, 0

Eigenvector for =0
5 4 −2 0
4 5 2 = 0
−2 2 8 0
1 0.8 −0.4 0
1 1.25 0.5 = 0
1 −1 −4 0
1 0.8 −0.4 0
0 0.45 0.9 = 0
0 −1.8 −3.6 0
1 0.8 −0.4 0
0 1 2 = 0
0 1 2 0
1 0 −2 0
0 1 2 = 0
0 0 0 0
−2 0
=
+2 0
Set =1
= 1/2, = −1
1 1 0.6667
= −1 = −0.6667
1 1/2 0.3333
1+1+ 2

1
Eigenvector for =9
5−9 4 −2 0
4 5−9 2 = 0
−2 2 8−9 0
−4 4 −2 0
4 −4 2 = 0
−2 2 −1 0
1 −1 1/2 0
0 0 0 = 0
0 0 0 0
− + =0
2
= − ⁄2
− ⁄2
=

Set = 1, =0
1
= 1
0
Set =1
1− ⁄2
= 1

Since, =0
2− ⁄2 = 0
=4
−1
= 1
4
Normalize,
1 1 0.7071
= 1 = 0.7071
√1 + 1 0 0
1 −1 −0.2357
= 1 = 0.2357
√1 + 1 + 16 4 0.9428

Then we have,
=
0.7071 −0.2357 0.6667 9 0 0
= 0.7071 0.2357 −0.6667 , = 0 9 0
0 0.9428 0.3333 0 0 0

2
> eigen(m)
eigen() decomposition
$values
[1] 9.000000e+00 9.000000e+00 5.329071e-15

$vectors
[,1] [,2] [,3]
[1,] 0.0000000 0.7453560 0.6666667
[2,] 0.4472136 0.5962848 -0.6666667
[3,] 0.8944272 -0.2981424 0.3333333

Eigenvectors are not unique.

3
Q2
2 1
= 1 2
−2 2
5 4 −2
= 4 5 2
−2 2 8
From Q1,
9 0 0
= 0 9 0
0 0 0
0.7071 −0.2357 0.6667
= 0.7071 0.2357 −0.6667
0 0.9428 0.3333
Since for singular value decomposition, we have
=
=
=
(similarly, = )
0.7071 −0.2357
2 1 −2 3 0
0.7071 0.2357 =
1 2 2 0 3
0 0.9428
0.7071 −0.7071
=
0.7071 0.7071
Therefore,
0.7071 −0.2357
3 0 0.7071 −0.7071
= 0.7071 0.2357
0 3 0.7071 0.7071
0 0.9428

> svd(s)
$d
[1] 3 3

$u
[,1] [,2]
[1,] -0.6666667 -0.3333333
[2,] -0.3333333 -0.6666667
[3,] 0.6666667 -0.6666667

$v
[,1] [,2]
[1,] -1 0
[2,] 0 -1

Singular vectors are not unique.

4
Q3
a)
Observed
A B C total
Young 3 3 1 7
Middle 1 3 1 5
Old 1 1 3 5
total 5 7 5 17

Expected
A B C total
Young 5×7 7×7 5×7 7
17 17 17
Middle 5×5 7×5 5×5 5
17 17 17
Old 5×5 7×5 5×5 5
17 17 17
total 5 7 5 17

A B C
Young 2.0588 2.8824 2.0588
Middle 1.4706 2.0588 1.4706
Old 1.4706 2.0588 1.4706

values

=

3 − 2.0588
= = 0.6559
√2.0588
1 − 2.0588
= = −0.7379
√2.0588
A B C
Young 0.6559 0.06930 -0.7379
Middle -0.3881 0.6559 -0.3881
Old -0.3881 -0.7379 1.2612

M
= /√

0.1591 0.0168 −0.1790


= −0.0941 0.1591 −0.0941
−0.0941 −0. ,1790 0.3059

5
Singular value decomposition
=
Q is the square root of the non-zero eigenvalues of
0.4375 0
=
0 0.2090

U is the eigenvector matrix of


−0.4649 0.6100
= −0.2874 −0.7895
0.8374 0.0677
Since =
−0.2874 0.7895
= = −0.4649 −0.6100
0.8374 −0.0677
.
= .
and =
7/17 0 0
= 0 5/17 0
0 0 5/17
5/17 0 0
= 0 7/17 0
0 0 5/17
/ /
= , =
1.5583 0 0 −0.4649 0.6100
0.4375 0
= 0 1.8439 0 −0.2874 −0.7895
0 0.2090
0 0 1.8439 0.8374 0.0677
−0.3170 0.1986
= −0.2318 −0.3042
0.6756 0.0261
1.8439 0 0 −0.2874 0.7895
0.4375 0
= 0 1.5583 0 −0.4649 −0.6100
0 0.2090
0 0 1.8439 0.8374 −0.0677
−0.2318 0.3042
= −0.3170 −0.1986
0.6756 −0.0261

b)
inertia
0.4375 0 0.1914 0
= =
0 0.2090 0 0.04367
.
Dimension 1: . .
= 81.43%
.
Dimension 2: = 18.57%
. .

6
c)
Rows
(−0.3170) 0.1986 0.1005 0.0395
= (−0.2318) (−0.3042) = 0.0537 0.0925
0.6756 0.0261 0.4565 0.0007
0.1399
[ . ] = 0.1463
0.4571
Squared cosine
0.7180 0.2820
/ . = 0.3674 0.6326
0.9985 0.0015
Quality
1
/ . = 1
1

Columns
Quality
1
. /
= 1
1
The maximum number of dimensions are 2 and a 2-dimensional solution is considered.
Therefore, qualities are always 1.

d)
partial contribution of inertia for rows
(−0.4649) 0.6100 0.216 0.372
(−0.2874) (−0.7895) = 0.083 0.623
0.8374 0.06773 0.701 0.005

Partial contribution of inertia for columns


(−0.2874) 0.7895 0.083 0.623
(−0.4649) (−0.6100) = 0.216 0.372
0.8374 (−0.0677) 0.701 0.005

7
Q4
a)
> chisq.test(smoking)
Pearson's Chi-squared test
data: smoking
X-squared = 16.442, df = 12, p-value = 0.1718

There is not significant association between the rows and columns at 5% level of
significance.

b)
The maximum dimension for the CorrA is min(no. of rows-1; no. of columns-1)
= min(4; 3) = 3.

c) The inertia of each dimension is given by


Principal inertias (eigenvalues):

dim value % cum% scree plot


1 0.074759 87.8 87.8 **********************
2 0.010017 11.8 99.5 ***
3 0.000414 0.5 100.0
-------- -----
Total: 0.085190 100.0

d)
99.5% of inertia is explained by the two extracted dimensions.

e)
> cacoord(fit,type="principal",dim=1:2)
$rows
Dim1 Dim2
Senior Managers -0.06576838 -0.19373700
Junior Managers 0.25895842 -0.24330457
Senior Employees -0.38059489 -0.01065991
Junior Employees 0.23295191 0.05774391
Secretaries -0.20108912 0.07891123

$columns
Dim1 Dim2
None -0.39330845 -0.030492071
Light 0.09945592 0.141064289
Medium 0.19632096 0.007359109
Heavy 0.29377599 -0.197765656

8
0.2

Secretaries
0.1 Junior Employees
Senior Employees
Dim2

0.0

-0.1
Senior Managers
-0.2 Junior Managers

-0.6 -0.4 -0.2 0.0 0.2 0.4


Dim1

0.2
Light

0.1

Medium
Dim2

0.0 None

-0.1

Heavy
-0.2
-0.4 -0.2 0.0 0.2
Dim1

Rows:
name mass qlt inr k=1 cor ctr k=2 cor ctr
1 | SnrM | 57 893 31 | -66 92 3 | -194 800 214 |
2 | JnrM | 93 991 139 | 259 526 84 | -243 465 551 |
3 | SnrE | 264 1000 450 | -381 999 512 | -11 1 3 |
4 | JnrE | 456 1000 308 | 233 942 331 | 58 58 152 |
5 | Scrt | 130 999 71 | -201 865 70 | 79 133 81 |

Columns:
name mass qlt inr k=1 cor ctr k=2 cor ctr
1 | None | 316 1000 577 | -393 994 654 | -30 6 29 |
2 | Lght | 233 984 83 | 99 327 31 | 141 657 463 |
3 | Medm | 321 983 148 | 196 982 166 | 7 1 2 |
4 | Hevy | 130 995 192 | 294 684 150 | -198 310 506 |

From the partial contribution of the staff position, perceptual map of the staff position,
the dimension 1 of staff position is explained by the junior and senior employees and
shows the difference between junior staff (+ve) and senior staff (-ve).

9
The dimension 2 is contributed by the junior and senior managers.

On the other hand, from the partial contribution of the smoking habits, dimension 1 of
smoking habits is explained by "None" category. Dimension 1 of its perceptual map
shows the difference between smokers (+ve) and non-smokers (-ve).
Dimension 2 is contributed by "Light" and "Heavy" categories.
Again, together with the results of coordinates plot on the right for dimension 2, this
dimension can distinguish mostly between "Light smoker" (+ve) and "Heavy smoker" (-
ve).

f)
The perceptual map containing all categories for employees and smoking habits is given
below
0.2

Light
0.1

Secretaries
Dimension 2 (11.8%)

Junior Employees

Medium
0.0

Senior Employees
None
-0.1

Senior Managers Heavy


-0.2

Junior Managers
-0.3

-0.4 -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3

Dimension 1 (87.8%)
Since the categories of "Senior Managers", "Junior Managers" and "Heavy" are close to
each other on the perceptual map, most managers are heavy smokers.
Furthermore, the junior employees are light and medium smokers. On the other hands,
the senior employees and secretaries are nonsmokers.
The director should focus on the managers who have heavy smoking habits and the junior
employees who have light and medium smoking habits for the smoking cessation
program due to their close positions on the perceptual map.

g)
The quality values of the staff position and the smoking habits are over 80%, the
extracted dimensions fit well to the row and column categories.

10

You might also like