inferential statistics & regression

36
Statistical Inference and Linear Regression Reference: Paulsen, Kurt. (2005). Planning Methods. Temple University.

Upload: thana-chirapiwat

Post on 26-Jan-2017

315 views

Category:

Education


3 download

TRANSCRIPT

Page 1: Inferential Statistics & Regression

Statistical Inferenceand

Linear Regression

Reference: Paulsen, Kurt. (2005). Planning Methods. Temple University.

Page 2: Inferential Statistics & Regression

Overview• INFERENTIAL statistics is the branch of statistics that allow us

to draw conclusions about the data or to test hypothesizes. “Statistical inference is the act of reaching conclusions about the world based on a set of data, and then evaluating the reliability of those conclusions.”

! ! สถิติอางอิงเปนวิธีการในการแกปญหาท่ีจะพยายาม อาง (infer) คุณสมบัติของกลุมขอมูลจากกลุมตัวอยางไปยังประชากร

! ! จุดหมายของสถิติอางอิงมีจุดหมายเพื่อทำนายหรือประมาณลักษณะของประชากรจากขอมูลลักษณะของกลุมตัวอยาง และประเมินความนาเชื่อถือของผล

Page 3: Inferential Statistics & Regression

กระบวนการทางสถิติ

คาพารามีเตอร

(μ , σ2 , ρ , ฯลฯ)

กลุมประชากร กลุมตัวอยาง

คาสถิติ( X , S2 , r , ฯลฯ)การประมาณคา

การทดสอบสมติฐาน

สถิติอางอิง

สถิติเชิงบรรยาย

Page 4: Inferential Statistics & Regression

Z - test

T – test

F – test

χ2 test

rxy

ทดสอบคาเฉลี่ยของกลุมตัวอยางเปรียบเทียบกับกลุมประชากรเม่ือกลุมตัวอยางมีขนาดเกิน 30เปรียบเทียบคาเฉลี่ยของกลุมตัวอยาง 2 กลุม เม่ือกลุมตัวอยางมีขนาดไมเกิน 30

เปรียบเทียบคาเฉลี่ยของกลุมตัวอยาง 3 กลุมขึ้นไป

ทดสอบความเปนอิสระตอกัน ระหวางคุณลักษณะของขอมูลท่ีเปนจำนวนหรือความถี่

ทดสอบความสัมพันธระหวางคุณลักษณะของขอมูลท่ีเปนระดับชวงหรือสัดสวน

สถิติอางอิงท่ีท่ีใชในการหาขอสรุปจากกลุมตัวอยาง

Page 5: Inferential Statistics & Regression

Confidence Intervals• Central Limit Theorem:

• หมายถึง กลุมตัวอยางจะกระจายตัวอยูจาก sample mean ในรูปของโคงปกติ Normal curve ("N") ที่มีคา mean เทากับคา true mean (mu)

และ standard deviation เทากับ “standard error” (sigma หารดวย square root of n, โดย n เปนจำนวนกลุมตัวอยาง (sample size)) ดังนั้น standard deviation ของการกระจายตัวของกลุมตัวอยางเปนตัวแปรจาก sample size.

Page 6: Inferential Statistics & Regression

• เราสามารถใชสูตรคำนวณการกระจายตัวของกลุมตัวอยางเพ่ือแสดงการกระจายตัวของกลุมตัวอยางใดๆ ไดดวย คาที่เรียกวา STANDARD NORMAL:

• คานี้มักเรียกกันวา "z-test statistic" (หรือบางครั้งก็เรียก "z-score") คา z-test

statistic มีคุณลักษณะที่มีการกระจายตัวแบบ STANDARD NORMAL CURVE.

“Standardizing” or z-scores

Page 7: Inferential Statistics & Regression

“Z-values”• คา “z-value” หรือ “คามาตรฐาน” เปนคะแนนที่แปลงรูปมาจากคะแนนดิบ

เพ่ือใหมีความหมายชัดเจนย่ิงขึ้น โดยทั่วไปการแปลงคะแนนดิบใหเปนคะแนนมาตรฐาน

• เปนการแปลงคะแนนดิบใหเปนคะแนน มาตรฐานโดยอาศัยวิธีการทางสถิติและรักษาโคงการแจกแจงเดิมไวไมเปลี่ยนแปลง

• การคานวณหาคะแนนมาตรฐาน Z อาศัยคะแนนเฉลี่ยละคาเบี่ยงเบนมาตรฐานของ คะแนนแตละชุด โดยใชสูตรดังนี้สูตร

(X-X)/SD

• เมื่อ Z แทน คะแนนมาตรฐานของแตละคน

• X แทนคะแนนดิบของแตละคน

• X แทน คะแนนเฉลี่ยของขอมูลในแตละชั้น

• SD แทน ความเบี่ยงเบนมาตรฐานของคะแนนชุดนั้น

Page 8: Inferential Statistics & Regression
Page 9: Inferential Statistics & Regression

การคำนวณคา “Critical Values”• By definition: α = 1 - p or p = 1 - α• Thus if we want to find the central 95 percent of a standard normal curve,

we define p = 0.95 and α = 0.05

• If we define p = 0.95 and hence α = 0.05, we want 95 percent of the probability to be within our area, and 5 percent to be outside.

• Since a normal curve is symmetrical, having 5 percent of the value in the tails means having 2.5 percent of the value in each tale. That is, we just take the value of alpha and divided by 2 for each of the value points.

• จำกัดความโดย: α = 1 - p or p = 1 - α• ดังนั้นถาเราตองการหาพ้ืนที่ 95 เปอรเซ็นต ตรงกลางของ standard normal curve เรา

กำหนดคา p = 0.95 และ α = 0.05• ถากำหนด p = 0.95 จะไดคา α = 0.05 เมื่อเราตองการหาความเปนไปไดที่ 95

เปอรเซ็นตของประชากรที่อยูตรงกลาง โดยมี 5 เปอรเซ็นตอยูนอกขอบเขต. • จาก normal curve ที่สมมาตร 5 เปอรเซ็นตของประชากรที่อยูนอกขอบเขต จะได 2.5

เปอรเซ็นตที่อยูที่หางของ normal curve แตละดาน.

Page 10: Inferential Statistics & Regression

Confidence Intervals• เมื่อพิจารณาหางของโคงปกติสองหาง “two-sided” เปนการพิจารณา

percent ของการกระจายตัวระหวางคา 2 คา นั่นเปนการกำหนด CONFIDENCE INTERVAL.

• ดังนั้นถาเราสนใจคา CONFIDENCE INTERVAL จากคา true mean (μ)

เราสามารถอธิบายดวยสมการดังนี้:

The Probability

that the mean

is between these 2 valuesis 1-alpha

Page 11: Inferential Statistics & Regression

Sample Sizes and Confidence Intervals

• KEY POINT: As the sample size increases, the interval (in which we are p percent “confident” that the true sample mean lies) gets thinner and thinner. CONFIDENCE INTERVALS ARE SAMPLE SIZE DEPENDENT!

Page 12: Inferential Statistics & Regression

Confidence Intervals

• ชวงความมั่นใจ (confidence interval) 95 percent หมายถึงอะไร?

หมายถึงถาเราคำนวณคาเฉลี่ยของกลุมตัวอยาง sample average

เปนการประมาณการคา true population mean จำนวน100 ครั้ง เรามีความมั่นใจวา 95 ครั้งจาก 100 ครั้ง เราจะสามารถไดคาเดียวกับ true value of μ (“true” population mean)

• เราใชความรูทางสถิตินี้ในการแสดงความมั่นใจวาเราประมาณคาของประชากรไดอยางมีความแมนยำ โดยไมตองทำการทดสอบกลุมตัวอยาง 100 ครั้ง!

Page 13: Inferential Statistics & Regression

Confidence Intervals• เพ่ือทำใหสมการเรียบงายขึ้น จึงแทนคาสัญลักษณ α ดวยคาที่เราเห็นได ดังนี้

ดวความมั่นใจ 95 percent จึงมี p = 0.95 และ α = 0.05

Page 14: Inferential Statistics & Regression

Confidence Intervals• และ z-values ที่คาความมั่นใจ 95 percent คือ -1.96 และ 1.96 เราก็จะได

สมการดัวนี้:

Page 15: Inferential Statistics & Regression

Z-Score Table

Page 16: Inferential Statistics & Regression
Page 17: Inferential Statistics & Regression

Normal Distribution• โคงระฆังคว่ำ หรือที่เรียกวา Normal Curve หรือ Gaussian

Curve (ตามชื่อของนักวิทยาศาสตรชาวเยอรมัน Karl Friedrick Gauss, 1777-1855)

Page 18: Inferential Statistics & Regression

Standard Normal Distribution• การกระจายตัวแบบ Normal มีคาเรียกวา Z value

• เปนการกระจายตัวจากคาเฉลี่ยกลาง ที่

โดยหางจากคากลางตามคา Standard Deviation

เชน คา Z = 1.5 หมายถึง จุดที่หางจากคากลาง 1.5 หนวยของ Standard Deviation

• Each Z value is the number of standard deviations away from the mean.

!

µ = 0

!

σ =1

Page 19: Inferential Statistics & Regression

Z Value• หากเราตองการคำนวณความนาจะเปนสำหรับคา Z value คา

หนึ่ง เชน Z = 1.5 ทำไดโดยคำนวณพื้นที่ใตกราฟ

จากตารางคา Z จะได Pr(Z > 1.5) คือ 0.0668

Page 20: Inferential Statistics & Regression

a. Pr(Z>1.64)

Examples

Page 21: Inferential Statistics & Regression

b. Pr(Z<-1.64)

Examples

Page 22: Inferential Statistics & Regression

c. Pr(1.0<Z<1.5)

Examples

= 0.1587-0.0668= 0.0919 = 9%

Page 23: Inferential Statistics & Regression

d. Pr(-1<Z<2)

Examples

= 1-0.1587-0.0228= 0.818 = 82%

Page 24: Inferential Statistics & Regression

e. Pr(-2<Z<2)

Examples

= 1-0.0228-0.0228= 0.954 = 95%

Page 25: Inferential Statistics & Regression

• The critical value X = 74 differs from its mean = 69 and = 3.

Z Value

!

Z =X − µσ

!

µ!

σ

!

Z =74 − 693

=53

=1.67

• Pr(Z>1.67) = 0.47 = 5%

Page 26: Inferential Statistics & Regression

Example• Suppose the yearling trout in a lake have

lengths that are approximately normally distributed, about a mean = 9.5” with a standard deviation = 1.4”. What proportion of them:

a. Exceeding 12” (the length for keeping a catch)?

b. Exceeding 10” (the newly proposed legal length)?

!

µ

!

σ

Page 27: Inferential Statistics & Regression

!

Z =X − µσ

!

Z =12.0 − 9.51.4

=2.51.4

=1.79

ThusPr(X>12) = Pr(Z>1.79)

= 0.037 = 4%

a.

Page 28: Inferential Statistics & Regression

!

Z =X − µσ

ThusPr(X>10) = Pr(Z>0.36)

= 0.359 = 36%

b.

!

Z =10.0 − 9.51.4

=0.51.4

= 0.36

Z=0.36

Page 29: Inferential Statistics & Regression

Regression

Page 30: Inferential Statistics & Regression

CORRELATION and REGRESSION.

• Correlation: correlation measures the strength of the relationship between variables or the degree to which two variables are correlated (co-related). Another way to think of it is that is a measure of the extent to which two variables "move together" – as one changes, how does the other one change? The correlation measure is a "dimensonless" number, and can therefore be used to compare "apples" and "oranges" or variables measured in different units.

Page 31: Inferential Statistics & Regression

CORRELATION and REGRESSION.

• Pearson's Correlation Coefficient วัดความสัมพันธเชิงเสนตรงระหวาง 2 ตัวแปร ซึ่งใชไมไดในกรณีที่ตัวแปรมีความสัมพันธกันเปนเสนโคง หรือมีจำนวน Outliers มากเปนพิเศษ

• คำสั่งในการหา Pearson's correlation ใน Microsoft Excel คือ "=CORREL"

Page 32: Inferential Statistics & Regression

CORRELATION and REGRESSION.

• ถา | r | มีคามาก หมายถึง x และ y มีความสัมพันธกันมาก

• r = 0 หมายถึง x และ y ไมมีความสัมพันธกัน

• r > 0 หมายถึง x มีคาเพ่ิมขึ้น แลว y จะมีคาเพ่ิมขึ้น หรือ ถา x มีคาลดลงแลว y จะมีคาลดลง

• r < 0 หมายถึง x มีคาเพ่ิมขึ้น แลว y จะมีคาลดลง หรือ ถา x มีคาลดลงแลว y จะมีคาเพ่ิมขึ้น

• คา b และ r จะมีเครื่องหมายเหมือนกัน

Page 33: Inferential Statistics & Regression

REGRESSION.

• What is a regression? Informally, it is a line fitted between two variables to estimate the (linear) relationship between the two variables. In the case where we have more than one "predictor" variable, it is multi-dimensional plane describing the relationship between the variables.

• One way to think about regression is that it is a way to test the statistical effect of one variable on another variable, holding all other variables constant.

• เปนการหาความสัมพันธเชิงเสนตรงระหวางตัวแปรสองตัว ในกรณีที่มีตัวแปรตนมากกวา 1 ตัวแปร ความสัมพันธจะเปนระนาบหลายมิติ

• ความสัมพันธเชิงเสนบอกอิทธิพลเฉพาะของตัวแปรตนตอตัวแปรตาม เพียงคูเดียว โดยไมคำนึงถึงตัวแปรอื่น (ถือวาคงที่)

Page 34: Inferential Statistics & Regression

เดือน 1 2 3 4 5 6 7 8 9 10 11 12

อุณหภูมิ 18 24 33 37 34 28 32 27 28 27 21 19

ผูชุมนุม 43 38 32 37 5 0 0 0 0 8 23 49

ใชอธิบายความสัมพันธระหวางขอมูล 2 ชุดท่ีมีอิทธิพลตอกัน (regression) และขอมูล 2 ชุดท่ีมีความเก่ียวพันกัน (correlation)

ใช สมการ y = a + bx

โดย Y y = เสนการถดถอย คำนวณไดจากทุกคาของ x ที่กำหนดให Y Y a = จุดตัดบนแกน y (Intercept)Y b = ความชันบนเสนกราฟ หรือสัมประสิทธการถดถอย (Regression Coefficient)

ตัวอยางขอมูล

x = ตัวแปรอิสระ (Independent Variable)y = ตัวแปรตาม (Dependent Variable)

CORRELATION and REGRESSION.

Page 35: Inferential Statistics & Regression

CORRELATION and REGRESSION.

X Variable 1 Line Fit Plot

0

10

20

30

40

50

60

0 10 20 30 40X Variable 1

Y

YPredicted Y

Page 36: Inferential Statistics & Regression

CORRELATION and REGRESSION.

rxyทดสอบความสัมพันธระหวางคุณลักษณะของขอมูลที่เปนระดับชวงหรือสัดสวน โดยคาที่ไดจะบอกไดวาปจจัยที่นำมาเปรียบเทียบกันนั้น มีการเปลี่ยนแปลงไปดวยกันหรือไม มีทิศทางเดียวกันหรือตรงกันขาม

คาสัมประสิทธิ์สหสัมพันธ (rxy)

เดือน 1 2 3 4 5 6 7 8 9 10 11 12

ผูชุมนุม 43 38 32 37 5 0 0 0 0 8 23 49

อุณหภูมิ 18 24 33 37 34 28 32 27 28 27 21 19

r = -0.40แสดงวาขอมูลจำนวนผูชุมนุมท่ีสำรวจมีความสัมพันธกับอุณหภูมิคอนขางนอย และมีทิศทางตรงขามกัน