Вы находитесь на странице: 1из 5

STAT328/STAT726/STAT826

MARKET RESEARCH AND FORECASTING


WEEK 2 PRACTICAL

Please bring your Week 1 Homework for Week 2 SGTA solutions.

Question 1
Work through An Introduction to SPSS which is available from Week 2 Practicals/SGTAs
on iLearn. The data set used in An Introduction to SPSS is also available from here.

Question 2
Enter the following data into SPSS spreadsheet:

X1 X2 X3
2 1 2
4 3 1
6 7 5
7 6 3
5 4 7
8 9 6
9 8 7
7 10 9
10 11 11
8 9 8
12 11 10
9 13 14

First open SPSS and click on the option Cancel in the dialog box that appears.

An empty SPSS Statistics Data Editor appears – it operates quite like an Excel spreadsheet.
Note there are two sheets Data View and Variable View. If the Variable View is not already
active, then click on the tab Variable View and it will become active. Under Name, type x1
in row 1, x2 in row 2 and x3 in row 3.

Now, in the bottom left corner, click on the Data View tab. You will find the first three
columns already have the variable names in place. Type the data above into the appropriate

1
cells in the Data View spreadsheet. Now create a new variable called case in the 4th column
and enter the numbers 1,2,3,4, … , 12 – the point of adding this variable is just to label the 12
points in a scatterplot.

Examine the data to see whether there is scope for the use of principal components, for
example, whether the data lie in a two-dimensional space (i.e. on a plane) or whether they are
fully three dimensional. SPSS has a beautiful feature for forming a 3-dimensional plot and
allowing you to rotate the axes about the origin.
In SPSS go to the menu bar at the top and do the following:
Graphs > Legacy Dialogs > Scatterplot/Dot… and then select 3-D Scatter. Click on
Define. You should see the following screen (or something similar)

Click and drag x1 from the left window area to one of the three boxes on the right hand
window. Drag x2 to one of the remaining two and finally, drag x3 to the last box. Drag Case
into the bottom box Label Cases By:. Now click OK.

You should now find 3-D scatter plot with the cases labelled in the SPSS Output window.
Bring the cursor to the middle of the scatter plot and double click. You should see the
following (after making the Chart Editor active by double clicking on the plot):

2
Click on this then hold down left
button on cursor and move
around

This allows you to rotate the image in whatever direction suits you. The numbers give the
degrees of rotation. Does the resulting plot appear to have all points lying in the one plane or
nearly in the one plane? If so you will expect to find one of the eigen-values will be very near
zero.

Carry out the PCA on (a) the original data, (b) on the mean-corrected data and (c) on the
standardized data. Note, you can produce the standardized variables in SPSS using Analyse >
Descriptives > Descriptives…. (Hint: SPSS doesn’t care whether the data are mean-
corrected or not, and to run the standardized case, remember this is equivalent to choosing to
analyse the CORRELATION matrix rather than the COVARIANCE matrix).

3
Week 1 Homework for Week 2 SGTA
Question 1
The following table provides six observations on variables x1 and x 2 :

Observation 1 2 3 4 5 6
x1 1 5 4 1 2 4
x2 1 4 3 2 1 5

Use Excel to do this question. More detailed instructions on how to use Excel to this question
are given below.

(a) Compute the variance of each variable. What percentage of the total variance is
accounted for by x1 and x 2 respectively?

(b) Let X 1* be any axis in a two-dimensional space making an angle of  with X 1 (the
axis through the centre of gravity of the points – i.e. the axes used to represent the
mean-centred data). Projection of the observations on X 1* give the coordinates x1* of
the observations with respect to X1*. Express x1* as a function of , x1 and x 2 .

(c) Using trial and error or otherwise, for what value of  does x1* have the maximum
variance? What percentage of the total variance is accounted for by x1* . In Excel to
use the Sine or Cosine function the angle needs to be in radian measure. Remember 
radians = 180 degrees,  = 3.141592654. In effect then you are to reproduce for the
data above, the entries in table 4.3 in Chapter 4 of Sharma’s book, a copy of which
was issued at the lecture.

(d) Analyse the data in SPSS and compare the output with the Excel analysis (i.e. make
sure that the eigenvectors and eigenvalues are the same).

Excel instructions for doing this question.


a) Set up the 6 x1 observations in cells A1-A6.
b) Set up the 6 x 2 observations in cells B1-B6.
c) In cell C1 write
= A1 – AVERAGE(A$1:A$6)
d) Click on the bottom right hand corner of cell C1 (the cursor should become a + and
not an open cross. Drag this down to C6.
e) Again click on C1, and again on the bottom right-hand corner but this time drag the
cell into D1. Then drag from D1 to D6.
f) Highlight cells C1:D6 and copy to clip-board.
g) Move to cell C7 and click the RIGHT button on the mouse, select Paste Special, then
click on Values.
h) Highlight cells C7:D12 and click the RIGHT button and click Copy.
i) Now move down to C13 and click RIGHT button and click Paste (NOT Paste
Special).
j) Repeat this last step at C19, C25, C31, C37, C43, C49.
k) Now you should have 9 copies (including the original) of the mean-centred
observations in A1:B6. These are in C1:D54. You are to enter into E1 the first value

4
of the angle you wish to consider. Use 10 degrees. Using the bottom right hand corner
of E1, drag it down to cell E6. You should find the first 6 cells have 10 in them. Now
write in E7, 20, and copy it in to cells E8 to E12, etc carry on increasing the no. of
degrees by 10 each time until you reach E49 which should have 90 in it and copy to
E54.
l) To use the Excel function Sin or Cosine you need to have the degrees in radian
measure. So in F1 write =E1/180*3.141592….. (i.e. the value of pi as given in the
question).
m) In G1 type
= cos(F1)*C1+ sin(F1)*D1
and then drag down after clicking on the bottom right hand corner of G1,
n) and in H1 write
= -sin(F1)*C1+ cos(F1)*D1 and then click and drag down
o) In I1 write = G1*G1 and in J1 write = H1*H1
and then click and drag down.
p) Go to column C, right up the very top, above C1, click on that cell and the entire
column should be selected. Now press “Ctrl + “ (use the “+” on the number pad) to
insert a column.
q) Now click on the cell at the very left of A1, you should find the entire first row is
highlighted. Insert a row by pressing “Ctrl +”.
r) Give appropriate names to each of the columns in D1 to K1.
s) Now go to the Data menu and select subtotals, make the subtotals form for every
change in column F (the Angle  - note it is now in column F as we have inserted a
column). In the Add Subtotal to: dialogue box, check the names corresponding to
columns J and K. One of the sums of squares will be maximised whilst the other will
be minimised. Consider the one that is maximised. The subtotals should now be the
sums of squares for the various angles. Pick the angle where the max sum of squares
appears. Note max. is between 40 and 50.
Note, the sums are now the sums of squares and if we divided them by 5 (= n – 1 = 6 – 1) we
would have the sample variances for each variable. Note also that the total of the two sums of
squares (e.g. write in L1 “= J1+K1” and drag down to form this sum for all entries – but you
need to do this before using subtotals) is constant.
Note, p)-r) are necessary for subtotals to work.

Make sure you understand what you are doing at each step of the Excel work.

Вам также может понравиться