1 using the syntax window aka learning a new language!

32
1 Using the Syntax window AKA Learning a new language!

Upload: kelley-spencer-bruce

Post on 25-Dec-2015

220 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 Using the Syntax window AKA Learning a new language!

1

Using the Syntax window AKA Learning a new language!

Page 2: 1 Using the Syntax window AKA Learning a new language!

2

Why use syntax?

• To keep a record of computations & analyses – They can get to be too many to recall (esp.. if you

are doing ‘exploratory’ analyses)– One may end of redoing analyses them OR– Do analyses differently when redoing them which

can cause different & confusing results

Page 3: 1 Using the Syntax window AKA Learning a new language!

3

What is a syntax window?

• Allows you to type in the modifications of the variables you have

• Allows you to type/paste in the analyses you like to conduct

Page 4: 1 Using the Syntax window AKA Learning a new language!

4

Syntax in EXCEL

Syntax in SPSS

Compute lifesat =mean(item1, item2, item3).

Page 5: 1 Using the Syntax window AKA Learning a new language!

5

What we did so far…what’s next

• What is syntax

• Why do syntax

• How is syntax done in SPSS vs EXCEL

Page 6: 1 Using the Syntax window AKA Learning a new language!

6

Example of Syntax in EXCEL

Example of Syntax in SPSS

Compute lifesat =mean(item1, item2, item3).

Page 7: 1 Using the Syntax window AKA Learning a new language!

7

Features of Syntax in Excel

• In EXCEL you type/paste syntax in the function box

Page 8: 1 Using the Syntax window AKA Learning a new language!

8

Features of a syntax window in SPSS

•In SPSS you type/paste functions in a separate window/file which takes the extension .sps (cf. .doc, .ppt)

•See next slide for example of the window

Page 9: 1 Using the Syntax window AKA Learning a new language!

9

The syntax window in SPSS

Page 10: 1 Using the Syntax window AKA Learning a new language!

10

Syntax in SPSS vs EXCEL

• Done in the same ‘location’ in EXCEL (i.e., in function box) above the data

• Can also be done in the same location in SPSS, But SPSS provides a “shortcut” for some types of syntax…

• Analyses syntax

• Computations syntax

Page 11: 1 Using the Syntax window AKA Learning a new language!

11

What are Analyses & Computations

• Computations – e.g., recoding variables; or creating new variables

means of items

• Analyses – e.g., correlations, reliabilities, frequencies, means

etc. YOU ALREADY KNOW THIS!• Note means of items are different from means in the

sample…more later…

Page 12: 1 Using the Syntax window AKA Learning a new language!

12

Generate syntax for analyses in SPSS

• Download & open the student satisfaction survey data

• Go to the correlational analyses window, pick the two variables you want to correlate

• Then click on ‘paste’ when in correlational analysis menu

• Go to the syntax window – Click under window on top right

Page 13: 1 Using the Syntax window AKA Learning a new language!

13

• Students work on their own & do correlational analyses for any two variables in the and generate syntax

Page 14: 1 Using the Syntax window AKA Learning a new language!

14

Screen you should be at when you successfully paste the correlational

Analyses from the Data Window into the Syntax window

Page 15: 1 Using the Syntax window AKA Learning a new language!

15

Students continue working in syntax window…

•Select the analyses pasted in the syntax window•Click on RUN button on top right

Page 16: 1 Using the Syntax window AKA Learning a new language!

16

What we did so far…what’s next

• What is syntax

• Why do syntax

• How is syntax done in SPSS vs EXCEL– Syntax in SPSS is different for

• Analyses vs.

• Computations

– Syntax in EXCEL is same for analyses & computations

Page 17: 1 Using the Syntax window AKA Learning a new language!

17

Syntax for computations in SPSS vs EXCEL

• In SPSS, you need to open a separate syntax window

• In EXCEL you can directly start typing your computations in the function window

Page 18: 1 Using the Syntax window AKA Learning a new language!

18

How to open a syntax window

Page 19: 1 Using the Syntax window AKA Learning a new language!

19

Close look at Syntax in EXCEL

• In the example above– “STDEV” is the type of the function

•Can be substituted w/mean, sum

– “A2: A16” in parenetheses are cell values on which the function is to be performed •e.g., the values in cells A2 to A16 should

be used to compute the std dev

Page 20: 1 Using the Syntax window AKA Learning a new language!

20

How the Syntax in SPSS differs & is similar to that in EXCEL

Compute lifesat =mean(item1, item2, item3).

• Differences from EXCEL– Comma in between items vs. colon– Period at the end of the statement

• Similarities w/Excel– Can use ‘sum’ and other operands similarly– Items enclosed in parens after the ‘function’

Page 21: 1 Using the Syntax window AKA Learning a new language!

21

More ‘Rules’ of Syntax in SPSS

Compute lifesat =mean(item1, item2, item3).– Lifesat is now new variable you computed in your

data – Features of the variable name (e.g., lifesat)

• is 8 characters or fewer

• Cannot be the same as the name of another variable already in data set

• It cannot start with a numeric value

Page 22: 1 Using the Syntax window AKA Learning a new language!

22

What we did so far…what’s next

• What is syntax

• Why do syntax

• How is syntax done in SPSS vs EXCEL– Syntax in SPSS is different for

• Analyses vs.

• Computations

– Syntax in EXCEL is same for analyses & computations

Page 23: 1 Using the Syntax window AKA Learning a new language!

23

Why use syntax?

• To keep a record of computations & analyses – They can get to be too many to recall (esp.. if you are

doing ‘exploratory’ analyses)– One may end of redoing analyses them OR– Doing analyses differently when redoing them

which can cause different & confusing results– Check the accuracy of your analyses

Page 24: 1 Using the Syntax window AKA Learning a new language!

24

Checking the accuracy of your analyses and keeping them consistent across

iterations with syntax files

• e.g., *reverse scoring negatively worded LS items.

• “*” at beginning and “.” at end enables you to use English to make notes about nature of analyses/computations in syntax files

– E.g.,*wage is related to education after controlling for SAT scores.

– E.g., *tests hypo that wage is related to education after controlling for GPA -- not supported.

Page 25: 1 Using the Syntax window AKA Learning a new language!

25

Taking advantage of SPSS syntax

• Being accurate

• Being consistent

• Rechecking analyses

• Keeping records

• Utilizing multi-item scales

Page 26: 1 Using the Syntax window AKA Learning a new language!

26

Computing multi-item scale scores in SPSS using Syntax Window

• What is a multi-item scale?

• Why use a scale score rather than an individual item?

Page 27: 1 Using the Syntax window AKA Learning a new language!

27

Before computing scale scores, first reverse score differently worded items

• Recode item1 (5=1) (4=2) (2=4) (1=5).

• Additional things you can do– Can recode multiple items

• Recode item1 item5 (5=1) (4=2) (2=4) (1=5).

– Can use ‘to’ statement for multiple items • Recode item1 to item10 (5=1) (4=2) (2=4) (1=5).

– If items to be reverse scored are lined up in the data file in that order

Page 28: 1 Using the Syntax window AKA Learning a new language!

28

After reverse scoring, then compute means of items

• Compute ls =mean(item1, item2, item3).

– How is this different from the results you get in “descriptives” analyses and you get the mean of item1?

• Students do the analyses and orally explain

Page 29: 1 Using the Syntax window AKA Learning a new language!

29

Students Compute scale scores for Global Life Satisfaction (LS)

• Recode Negatively worded Life Satisfaction items– How can you check you did it correctly?

• Compute a life Satisfaction scores by taking the mean of all items– Can only do after reverse scoring– Why not take the sum of all items? Advantages

vs. disadvantages– What types of things can/should you take sums

of?

Page 30: 1 Using the Syntax window AKA Learning a new language!

30

Generalizing what you learned about computations & applying it

to statistical analyses

Page 31: 1 Using the Syntax window AKA Learning a new language!

31

Students correlate LS with specific types of satisfaction & stressors

• Compute reliabilities for each specific type of satisfaction & each type of stress

• Compute scale scores for each – Ensure you recode appropriately

• Correlate lifesat with each type of sat & each type of stress

Page 32: 1 Using the Syntax window AKA Learning a new language!

32

• Does a stressor in relationship, work, school affect the relevant type of satisfaction which in turn affects life satisfaction?– Do Mediator regression analyses

• Which type of specific satisfaction best predicts overall life satisfaction– Do Stepwise regression

LS, specific types of satisfaction, Stress