62
Using SPSS for Windows Part II Jie Chen Ph.D. Email: [email protected] Phone: 617 287 5241 06/23/22 1

Using SPSS for Windows Part II Jie Chen Ph.D. Email: [email protected]@umb.edu Phone: 617 287 5241 10/6/20151

Embed Size (px)

Citation preview

Page 1: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

Using SPSS for WindowsPart II

Jie Chen Ph.D.Email: [email protected]

Phone: 617 287 5241

04/21/23 1

Page 2: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

Table of Contents• Data management

– Computing new variables– To sort data– Data selection and split files– Merging files

• Statistical procedures– Linear regressions– Regression for aggregated data– Chi-square test for grouped data – Nonparametric tests– Testing Normality

04/21/23 2

Page 3: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 3

Computing New Variables

• Open data sample1.sav• To compute a new variable we can

– Use a standard formula– Use a statistical function to compute

Page 4: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 4

Using a Formula

To compute the average income for the past three years for each person:

• Click Compute in the Transform menu, • Enter the new variable with the name of

“mean” for the target variable Mean = (ptoi92+ptoi93+ptotinc)/3• Click OK to compute the mean

Page 5: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 5

Using a Statistical Function

• Click the Compute in the Transform menu• Click the Reset button to clear the old formula• Enter average as the target variable• Locate Mean on function list and move it to the

Numeric Expression area (using Up arrow )• Enter ptoi92, ptoi93 and ptotinc inside the

parentheses• Click OK to compute the average

Page 6: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

Log transformation

• Click the Compute in the Transform menu• Click the Reset button to clear the old formula• Enter lnincome as the target variable• Click on Arithmetic in Function group: text box• Locate Ln on functions and Special Variables: list

and move it to the Numeric Expression area (using Up arrow )

• Enter ptotinc inside the parentheses• Click OK to compute log of ptotinc.

Page 7: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 7

Sorting Data

Sorting data involves reordering of data using values of one or more variables.

• Sorting data on one variable• Sorting data on more than one variables

Page 8: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 8

Sorting Data on One Variable

• Click Data/Sort Cases in the Data Editor Window

• Click age and move it to the “Sort by:” text box

• Click Ascending radio button• Click OK

Page 9: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 9

Data Sorted by Age

Page 10: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 10

Sorting Data on Two Variables

• Click Data/Sort Cases• Click age and move it to the “Sort by:” text

box• Click educ and move it to the “Sort by:” text

box• Click Ascending radio button• Click OK

Page 11: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 11

Data Sorted by Two Variables

Page 12: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 12

Three Ways of Data Selection

• If condition is satisfied : to select data that meet if conditions

• Random sample of cases:randomly chose a specified percentage of cases

• Based on time or case range: to select data from a specified range

Page 13: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 13

If Condition Is Satisfied

To choose data that meet If conditions:• Click the Select Cases in the Data menu• Click the If condition is satisfied radio button• Click If push button to open the Select Cases:

If dialog box

Page 14: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 14

The If condition

If we are interested in the personal total income for females, we need to select the only observations whose sex is female.

• Type in sex = 1 in the Select Cases: If dialog box, (1 = “female”)

• Click Continue to confirm the rule

Page 15: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 15

Two Choices for Unselected Cases

• If one clicks the Filtered radio button, the unselected cases remain in the Data Editor, but are not used in analyses.

• If one clicks the Deleted radio button the unselected cases are deleted from the Data Editor Window.

Page 16: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 16

Complex If conditions

Suppose we want to select cases meeting two conditions: region = 1 and age >= 30

• Type in “region = 1 & age>=30” in the Select Cases: If window

• Click Continue to confirm the rule

Page 17: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 17

The Case Deletion Choice

• Switch to the Data Editor Window• Click the Select Cases in the Data menu• Click the Deleted radio button in the

Unselected Cases Are: area • Click the OK to delete unselected cases from

Data Editor Window

Page 18: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 18

The Data Editor Window Containing Only Selected Observations

Page 19: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 19

Split File

• The data file is split into separate groups for analysis based on the values of a grouping variable

• The same analysis is applied to separate subgroups simultaneously

• The results for all the subgroups will be presented together

Page 20: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 20

To Split a Data file

• Open sample2.por• Click the Split File in the Data menu• Click the Organize output by groups radio

button• Move sex to the the Groups Based on list box• Click the OK push button to Split File

Page 21: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 21

Descriptive Statistics Based on Split File

• Click Statistics/Summarize/descriptive• Click age in variable list box• Click OK

Page 22: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 22

Presenting results by selecting Compare groups

Page 23: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 23

Turn Off the Split File Processing

• Select Split File in the Data menu• Click Analyze all cases in the Split File dialog

box• click OK to set analyses to all cases (turn off

split file)

Page 24: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 24

Merging Files

Data can be combined in two ways• Merging different cases according to the same

variables (adding observations)• Merging different variables according to

the same cases (adding variables)

Page 25: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 25

Merging Cases In the Data Editor Window

• Open a data file row1.sav• Click Data/Merge Files/Add Cases, the dialog box of

Add cases: Read File is open as shown in the note page

• Select file row2.sav and Click open, then the dialog box of Add Cases from... is open

• Click OK, the observation from row2.sav are placed in Data Editor Window after row1.sav

Page 26: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 26

The Add cases from … dialog box

Page 27: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 27

Merging Variables

• Open file col1.sav• Click Data/Merge Files/Add Variables. The dialog

box Add Variable: Read File shown in the note page will be displayed.

• Select file col2.save and Click open. Then the dialog box of Add Variable from... Will appear

• Click OK.

Page 28: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 28

The Add Variable from … dialog box

Page 29: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 29

The Merged File

Page 30: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 30

Introduction to Regression

• Simple Regression• Multiple Regression• Regression Plots• Regression for aggregated data

Page 31: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 31

Simple Regression

• Click Analyze/Regression/Linear then the Linear Regression dialog box is open

• Use ptotinc (personal total income) as the dependent variable

• Use educ as the independent variable• Click OK

Page 32: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 32

The Dialog Box of Linear Regression

Page 33: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 33

The Output for the Regression

Page 34: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 34

The Estimated Regression Equation

xY 25815.13285

Page 35: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 35

The Fitted Line

Page 36: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 36

Examing the Residual

• Click Dialog Recall Tool • Click Linear Regression• Click plots… in the Linear Regression dialog box • In the Linear Regression: Plots dialog box, chose

ZRESID as the Y and ZPRED as the X variables.• Click Histogram• Click Continue • Click Ok

Page 37: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 37

The Scatterplot of Residuals

Page 38: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 38

Multiple Regression

xy 0

332110 xxxy x

Page 39: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 39

Running a Multiple Regression

Page 40: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 40

The Output of Multiple Regression

Page 41: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 41

The Fitted Model

Y = -13301+ 2672 X1-13106 X2 + 145 X3

Page 42: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 42

Residual Plots

• Click Plots in Linear Regression Dialog Box• Put ZRESID as the Y variable and ZPRED as the

X variable in a scatterplot• Chose Histogram and Normal probability plot

in the Standardized Residual Plots

Page 43: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 43

Histogram

Page 44: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 44

Normal Probability plot

Page 45: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 45

To aggregate data

• Using Current Population Survey 2006 (CPS2006) data

• Click on Data/Aggregate Data– Break Variable(s):– Summaries of Variable(s):

• Mean, Median, and Sum• First, Last, Minimum, and Maximum values

– To save aggregated variables

Page 46: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 46

A random sample from Current Population Survey (CPS2006)

Page 47: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 47

The mean and median wages by years of education

Page 48: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 48

A regression line of average income

Linear Regression

8 12 16 20

edu

20000.00

40000.00

60000.00

80000.00

pw

ages

_mea

n

pwages_mean = -41548.30 + 5888.49 * eduR-Square = 0.95

Page 49: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 49

A regression line of median income

Linear Regression

8 12 16 20

edu

0.00

25000.00

50000.00

75000.00

100000.00

pw

ages

_med

ian

pwages_median = -54975.43 + 6592.25 * eduR-Square = 0.88

Page 50: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 50

An Example taken from 1982 General Social Survey

Death PenaltyGunRegistration Favor OpposeFavor 784 236Oppose 311 66

Page 51: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 51

Death PenaltyGunRegistration Favor OpposeFavor 784 / 76.9% 236 / 23.1%Oppose 311 / 78.4% 66 / 17.5%

Page 52: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 52

Death Penalty Data in SPSS

Page 53: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 53

Crosstabulation with Row Percentage

Page 54: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 54

Comparison of Row Percentages

Cases weighted by COUNT

Death Penalty

FavorOppose

Pe

rce

nt

100

80

60

40

20

0

Gun Registration

Oppose

Favor

Page 55: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 55

Repeated Measures Analysis

Repeated measures analysis of variance involves testing for significant differences in mean when the observation appears in multiple levels of a factor.

Page 56: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 56

Opening the data

• Click File/Open in the Data Editor Window• Click SPSS (*.sav) choice on the File of type

pull-down list• Look in Floppy (A) and click blood in the file

list• Click Open

Page 57: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 57

Opening the Repeated Measures Dialog Box

• Click Analyze/General Linear Model/Repeated Measures

• Replace factor1 with time in the Within-Subject Factor Name text box

• Press Tab key to move to the number of levels text box and type 3

• Click Add push-button and then click Define push-button

Page 58: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 58

• Click and drag from time1 to time3• Click right arrow to move time1 to time3 into

the Within-Subject Variables box• Click gender and move it to the Between-

Subjects Factor box• Click OK push button

Page 59: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 59

Examining the results

Page 60: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 60

Compare the Main Effects

• Click Dialog Recall Tool • Click Define Push-button• Click Options push-button• Move time into the Display Means for list box• Click Compare Main Effects checkbox• Click Continue to process the request• Click Ok

Page 61: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

04/21/23 61

Pairwise Comparisons

Page 62: Using SPSS for Windows Part II Jie Chen Ph.D. Email: jie.chen@umb.edujie.chen@umb.edu Phone: 617 287 5241 10/6/20151

Testing the Normality

• To test if Age variable is normal distributed.• Using file: sam1000.sav• Using both graphs and tests• Click on Analyze/Descriptive Statistics/Explore…

– To chose Age variable in the dependent list– Click on Plots push button.– Check Normality plots with tests.

04/21/23 62