ieng-212 modeling and optimization

71
IENG-385 Statistical Methods for Engineers SPSS (Statistical package for social science)

Upload: others

Post on 18-Jun-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: IENG-212 Modeling and Optimization

IENG-385

Statistical Methods for Engineers

SPSS (Statistical package for social science)

Page 2: IENG-212 Modeling and Optimization

The basics of managing data files

Opening SPSS: Start → All Programs → SPSS Inc→ PASW

Statistics 18 → PASW Statistics 18

Page 3: IENG-212 Modeling and Optimization

Opening SPSS

The default window will have the data editor

There are two sheets in the window:

1. Data view 2. Variable view

Page 4: IENG-212 Modeling and Optimization

SPSS windows

The Four Windows:

1.Data editor

2. Output viewer

3. Syntax editor

4. Script window

Page 5: IENG-212 Modeling and Optimization

Data Editor

Data Editor:

Spreadsheet-like system for defining, entering,

editing, and displaying data. Extension of the

saved file will be “sav.”

Page 6: IENG-212 Modeling and Optimization

Output Viewer

Output Viewer

Displays output and errors. Extension of the saved

file will be “spv.”

Page 7: IENG-212 Modeling and Optimization

Data view window

The Data View window

This sheet is visible when you first open the Data

Editor and this sheet contains the data

Click on the tab labeled Variable View

Click

Page 8: IENG-212 Modeling and Optimization

Variable view window

This sheet contains information about the data set that is stored with

the dataset

Name

– The first character of the variable name must be alphabetic

– Variable names must be unique, and have to be less than 64

characters.

– Spaces are NOT allowed.

Page 9: IENG-212 Modeling and Optimization

Variable view window: Type

Type

– Click on the „type‟ box. The two basic types of variables

that you will use are numeric and string. This column

enables you to specify the type of variable.

Page 10: IENG-212 Modeling and Optimization

Variable view window: With

Width

– Width allows you to determine the number of characters SPSS will allow to be entered for the variable

Page 11: IENG-212 Modeling and Optimization

Variable view window: Decimals

Decimals

– Number of decimals

– It has to be less than or equal to 16

Page 12: IENG-212 Modeling and Optimization

Variable view window: Label

Label

– You can specify the details of the variable

– You can write characters with spaces up to 256 characters

Page 13: IENG-212 Modeling and Optimization

Variable view window: Values

Values

– This is used to suggest which numbers represent which categories when the variable represents a category

Page 14: IENG-212 Modeling and Optimization

Defining the value labels

Click the cell in the values column as shown below

For the value, and the label, you can put up to 60

characters.

After defining the values click add and then click OK.

Click

Page 15: IENG-212 Modeling and Optimization

Example 1

How would you put the following information into SPSS?

Name Gender Height

JAUNITA 2 5.4

SALLY 2 5.3

DONNA 2 5.6

SABRINA 2 5.7

JOHN 1 5.7

MARK 1 6

ERIC 1 6.4

BRUCE 1 5.9

Value = 1 represents Male and Value = 2 represents Female

Page 16: IENG-212 Modeling and Optimization

Example 1: solution sample

Click

Page 17: IENG-212 Modeling and Optimization

Example 1: solution sample

Click

Page 18: IENG-212 Modeling and Optimization

Saving the data

To save the data file you created simply click „file‟ and click

„save as.‟ You can save the file in different forms by clicking

“Save as type.”

Page 19: IENG-212 Modeling and Optimization

Sorting the data

• Go Data Menu then select Sort Cases, Double Click

„Name of the students.‟ Then click ok.

Click

Click

Page 20: IENG-212 Modeling and Optimization

The basic analysis

The basic analysis of SPSS that will be introduced in this

class

Frequencies

– This analysis produces frequency tables showing frequency counts and percentages of the values of individual variables.

Descriptive

– This analysis shows the maximum, minimum, mean, and standard deviation of the variables

Linear regression analysis

– Linear Regression estimates the coefficients of the linear equation

Page 21: IENG-212 Modeling and Optimization

Enter the sample data

• The diameter of a ball bearing was measured by 50

inspectors. The results are shown in the below table. Draw

histogram for diameter of the ball bearing by using SPSS.

Observation 1 2 3 4 5 6 7 8 9 10 11 12 13

Diameter 33.2 29.1 34.5 32.6 30.7 34.9 30.2 31.8 30.8 33.5 29.4 32.2 33.6

Observation 14 15 16 17 18 19 20 21 22 23 24 25 26

Diameter 30.4 31.9 32.8 26.8 29.2 31.8 27.4 36.5 29.5 27.4 31.8 32.3 27.7

Page 22: IENG-212 Modeling and Optimization

Example

Observation 27 28 29 30 31 32 33 34 35 36 37 38

1Diameter 27.8 28.6 29.1 28.5 38.1 36 30.4 29.8 28.2 28.4 30.5 27.5

Observation 39 40 41 42 43 44 45 46 47 48 49 50

Diameter 26.9 34.8 30 31.5 28.4 34.6 27.5 28.8 28.5 28.5 34.2 30.5

Page 23: IENG-212 Modeling and Optimization

How to use draw a Histogram for this

experiment?

Go to ‘Analyze,’ ‘Descriptive statistics,’ then click

‘Frequencies’

Page 24: IENG-212 Modeling and Optimization

How to use draw a Histogram for this

experiment?

Choose the name of the variable (diameter) that

you create and put it in the variable box. Then click

charts and then select Histogram and then click

continue.

Click

Click

Page 25: IENG-212 Modeling and Optimization

Result

Page 26: IENG-212 Modeling and Optimization

TASK

• TASK 1: Find Mean, Skewness, Variance for

these data?

Consider that: Skewness and kurtosis are statistics that describe the

shape and symmetry of the distribution. These statistics are displayed

with their standard errors

Page 27: IENG-212 Modeling and Optimization

Task 1: Answer

Answer

– Go to analyze, Descriptive statistics and click

‘Descriptive’ then choose the name of the variable

(diameter) that you create and put it in the variable

box then click options. In the new opened window tick

the mean, variance and skewness then click continue.

Page 28: IENG-212 Modeling and Optimization

Click

Click

Page 29: IENG-212 Modeling and Optimization

Result of Task

Page 30: IENG-212 Modeling and Optimization

Opening the sample data

• Open „Employee data.sav‟ from the SPSS – Go to “File,” “Open,” and Click Data

Page 31: IENG-212 Modeling and Optimization

Opening the sample data

• Go to Program Files in C,” “SPSSInc,” “SPSS16‟‟, „‟English‟‟and “Samples” folder.

• Open “Employee Data.sav” file

Page 32: IENG-212 Modeling and Optimization

Frequencies

• Click „Analyze,‟ „Descriptive statistics,‟ then click „Frequencies‟

Page 33: IENG-212 Modeling and Optimization

Frequencies

• Click gender and put it into the variable box.

• Click „Charts.‟

• Then click „Bar charts‟ and click „Continue.‟

Click Click

Page 34: IENG-212 Modeling and Optimization

Frequencies

• Finally Click OK in the Frequencies box.

Click

Page 35: IENG-212 Modeling and Optimization
Page 36: IENG-212 Modeling and Optimization

Sample t-test

Page 37: IENG-212 Modeling and Optimization

T-test purpose • Z test requires that you know from

pop

• Use a t-test when you don’t know the population standard deviation.

• One sample t-test: – Compare a sample mean to a

population with a known mean but an unknown variance

– Use Sy (sample std dev) to estimate (pop std dev)

Page 38: IENG-212 Modeling and Optimization

T formula

• Procedure:

– Compute t obtained from sample data

– Determine cutoff point (not a z, but now a critical

t) based on

– Reject the null hypothesis if your observed t value falls in critical region (|t observed| > |t critical|)

Page 39: IENG-212 Modeling and Optimization

T distribution

• Can’t use unit normal table to find critical value – must use t table to find critical t – Based on degrees of freedom (df):

# scores free to vary in t obtained

– Start w/sample size N, but lose 1 df due to having to estimate pop std dev

– Df = N-1

– Find t critical based on df and alpha level you choose

Page 40: IENG-212 Modeling and Optimization

(cont.)

• To use the t table, decide what alpha level to use & whether you have a 1- or 2-tailed test gives column

• Then find your row using df.

• For = .05, 2 tailed, df=40, t critical = 2.021

– Means there is only a 5% chance of finding a t>=2.021 if null hyp is true, so we should reject Ho if t obtained > 2.021

Page 41: IENG-212 Modeling and Optimization

Note

• Note that only positive values given in t table, so…

• If 1-tailed test,

– Use + t critical value for upper-tail test (1.813)

– Use – t critical value for lower-tail test (you have to remember to switch the sign, - 1.813)

• If 2-tailed test,

– Use + and – signs to get 2 t critical values, one for each tail (1.813 and –1.813)

Page 42: IENG-212 Modeling and Optimization

Example

• Is EMT response time under the new system (ybar =28 min) less than old system ( = 30 min)? Sy = 3.78 and N=10 – Ha: new < old ( < 30)

– Ho: no difference ( = 30)

– Use .05 signif., 1-tailed test (see Ha)

– T obtained = (28-30) / (3.78 / sqrt10) = (28-30) / 1.20 = - 1.67

Page 43: IENG-212 Modeling and Optimization

(cont.)

• Cutoff score for .05, 1-tail, 9 df = 1.833

– Remember, we’re interested in lower tail (less response time), so critical t is –1.833

• T obtained is not in critical region (not > | -1.833 |), so fail to reject null

• No difference in response time now compared to old system

Page 44: IENG-212 Modeling and Optimization

1-sample t test in SPSS

• Use menus for: Analyze Compare Means One sample t Gives pop-up menu…need 2 things: – select variable to be tested/compared to

population mean

– Notice “test value” window at bottom. Enter the population/comparison mean here (use given to you)

– Hit OK, get output and find sample mean, observed t, df, “sig value” (p value)

– Won’t get t critical, but SPSS does the comparison for you…(if sig value < , reject null)

Page 45: IENG-212 Modeling and Optimization

Example

To test whether the average weight of student population is different from 140 lb. A random sample of 22 students’ weights from student population. use the following data.

(Alfa=0.05)

135 119 106 135 180 108 128 160 143 175 170

205 195 185 182 150 175 190 180 195 220 235

Page 46: IENG-212 Modeling and Optimization

Manual Solution

Page 47: IENG-212 Modeling and Optimization

Check Normality

Since the test is for studying samples from normally distributed populations, the first thing to do, after the data is ready, is to check for normality. That is, click through the following menu selections:

Analyze Descriptive Statistics Explore.

as shown in the following picture. The Explore dialog box will appear on the screen.

Page 48: IENG-212 Modeling and Optimization

Check Normality

Page 49: IENG-212 Modeling and Optimization

Check Normality

In the Explore dialog box, select “weight” into the Dependent as in the following picture.

For normality test, click the Plots button.

The Explore Plots dialog box will appear on the screen.

Check the Normality plot with tests box and click Continue in the Explore Plots dialog box and then click OK in the Explore dialog box.

Page 50: IENG-212 Modeling and Optimization

Check Normality

Page 51: IENG-212 Modeling and Optimization

Check Normality

Page 52: IENG-212 Modeling and Optimization

Check Normality

The normality test result as shown in the following table will appear in the SPSS Output window. The p- values .200 and .674 from Shapiro-Wilk test of normality are both greater than 0.05 which imply that it is acceptable to assume that the weight distribution is normal (or bell-shaped).

Page 53: IENG-212 Modeling and Optimization

One Sample T test

Click through the menu selections:

Analyze Compare Means One Sample T Test.

as in the following picture, and the One-Sample T Test dialog box will appear on the screen.

Page 54: IENG-212 Modeling and Optimization

One Sample T test

Page 55: IENG-212 Modeling and Optimization

One Sample T test

Select the variable “weight” to be analyzed into the Test Variable box, and enter the Test Value which the average value to be tested with (the mean value specified in the null hypothesis, that is 140 in this example). Click Continue and click OK for performing the test and estimation. The results will be displayed in the SPSS Output window.

Page 56: IENG-212 Modeling and Optimization

One Sample T test

Page 57: IENG-212 Modeling and Optimization

One Sample T test

Interpret SPSS Output: The statistics for the test are in the following table. The one sample t-test statistic is 3.582 and the p-value from this statistic is .002 and that is less than 0.05 (the level of significance usually used for the test) Such a p-value indicates that the average weight of the sampled population is statistically significantly different from 140 lb. The 95% confidence interval estimate for the difference between the population mean weight and 140 lb is (11.27, 42.46).

Page 58: IENG-212 Modeling and Optimization

Paired-Samples t Test

Page 59: IENG-212 Modeling and Optimization

Example

In a study conducted in the Forestry and Wildlife Department at Virginia Tech, J. A. Wesson examined the influence of the drug succinylcholine on the circulation levels of androgens in the blood. Blood samples were taken from wild, free-ranging deer immediately after they had received an intramuscular injection of succinylcholine administered using darts and a capture gun. A second blood sample was obtained from each deer 30 minutes after the first sample, after which the deer was released. The levels of androgens at time of capture and 30 minutes later, measured in Nano grams per milliliter (ng/mL), for 15 deer are given in the table. Assuming that the populations of androgen levels at time of injection and 30 minutes later are normally distributed, test at the 0.05 level of significance whether the androgen concentrations are altered after 30 minutes.

Page 60: IENG-212 Modeling and Optimization

Data of Example

Page 61: IENG-212 Modeling and Optimization

Manual Solution

Page 62: IENG-212 Modeling and Optimization

Input Data

Page 63: IENG-212 Modeling and Optimization

Paired Sample T test

Page 64: IENG-212 Modeling and Optimization

Paired Sample T test

Page 65: IENG-212 Modeling and Optimization

Result

Page 66: IENG-212 Modeling and Optimization

Example

A new fitness program is devised for obese people. Each participant's weight was measured before and after the program to see if the fitness program is effective in reducing their weights.

In this example, our null hypothesis is that the program is not effective, i.e., there is no difference between the weight measured before and after the program. The alternative hypothesis is that the program is effective and the weight measured after is less than the weight measured before the program.

In the data, the first column is the weight measured before the program and the second column is the weight after.

Before 145 116 120 133 130 119 133 125 126 140

After 143 120 117 130 125 119 134 128 123 141

Page 67: IENG-212 Modeling and Optimization

Input Data

Page 68: IENG-212 Modeling and Optimization

Paired Sample T Test

Select "Analyze -> Compare Means -> Paired-Samples T Test".

Page 69: IENG-212 Modeling and Optimization

Paired Sample T Test

A new window pops out. Drag the variable "Before" and "After" from the list on the left to the pair 1 variable 1 and variable 2 respectively, as shown next slide.

Click on Option to change the confidence interval level.

Then click "OK".

Page 70: IENG-212 Modeling and Optimization

Paired Sample T Test

Page 71: IENG-212 Modeling and Optimization

Paired Sample T Test

The results now pop out in the "Output" window.

Since the p-value is 0.472, we can not reject the alternative hypothesis and conclude that the fitness program is not effective at 5% significant level.