Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 3 Association: Contingency, Correlation, and Regression

Similar presentations


Presentation on theme: "Chapter 3 Association: Contingency, Correlation, and Regression"— Presentation transcript:

1 Chapter 3 Association: Contingency, Correlation, and Regression
Section 3.1 How Can We Explore the Association between Two Categorical Variables?

2 Learning Objectives Identify variable type: Response or Explanatory
Define Association Contingency tables Calculate proportions and conditional proportions

3 二變數的關連 (association between two variables)
Two variables measured on the same individuals are associated if some values of one variable tend to occur more often with some values of the second variable than with other values of that variable.

4 二變數的關連 (association between two variables)
統計上的關連談的是一般性的趨勢而非鐵律: 抽煙的人比較短命,但仍可找到一天抽一包煙的90歲老人。

5 二變數的關連 (association between two variables)
檢視兩變數之間的關連必先回答的問題: 資料的個體(分析單位)為何? 哪些變數?如何測量? 這些變數是數量(quantitative)還是類別(categorical)變數?

6 二變數的關連 (association between two variables)
兩變數的類別: 一個類別與一個數量變數 性別與血壓的關連 兩個類別變數 性別與抽煙的關連 兩個皆為定量變數(quantitative) 體重與血壓的關係

7 Contingency Table 社會統計(上)

8 Contingency Table 複習 兩個變數皆為類別變數

9 解釋變數為類別變數,反應變數為數量變數

10 二變數的關連 (association between two variables)
檢視兩個變數之間的關係還必須加問以下問題? 僅想瞭解兩者之間的單純關連?還是以一個變數來解釋另一個變數? Response variable結果變數或反應變數 Dependent variable 依便項 Explanatory variable解釋變數 Independent variable 自變項

11 Learning Objective 1: Response and Explanatory variables
Response variable (Dependent Variable) the outcome variable on which comparisons are made Explanatory variable (Independent variable) defines the groups to be compared with respect to values on the response variable Example: Response/Explanatory Blood alcohol level/# of beers consumed Grade on test/Amount of study time Yield of corn per bushel/Amount of rainfall

12 Learning Objective 3: Contingency Table
A contingency table: Displays two categorical variables The rows list the categories of one variable The columns list the categories of the other variable Entries in the table are frequencies

13 Learning Objective 3: Contingency Table
What is the response variable? What is the explanatory variable?

14 Learning Objective 4: Calculate proportions and conditional proportions

15 What proportion of organic foods contain pesticides?
Learning Objective 4: Calculate proportions and conditional proportions What proportion of organic foods contain pesticides? What proportion of conventionally grown foods contain pesticides? What proportion of all sampled items contain pesticide residuals?

16 Learning Objective 4: Calculate proportions and conditional proportions
Use side by side bar charts to show conditional proportions Allows for easy comparison of the explanatory variable with respect to the response variable

17 Learning Objective 4: Calculate proportions and conditional proportions
If there was no association between organic and conventional foods, then the proportions for the response variable categories would be the same for each food type

18 Chapter 3 Association: Contingency, Correlation, and Regression
Section 3.2 How Can We Explore the Association between Two Quantitative Variables?

19 二變數的關連 (association between two variables)
政治學者問:阿扁在2000年的各村里得票率是否與2004年的得票率有關? 政治顧問問:可否用2000年的得票率來預測各村里在2004年時會如何投票?

20 Learning Objectives: Constructing scatterplots
Interpreting a scatterplot Correlation Calculating correlation

21 Learning Objective 1: Internet Usage and Gross National Product (GDP) Data Set

22 Learning Objective 1: Scatterplot
Graphical display of relationship between two quantitative variables: Horizontal Axis: Explanatory variable, x Vertical Axis: Response variable, y

23 Learning Objective 2: Example: Did the Butterfly Ballot Cost Al Gore the 2000 Presidential Election?

24 Stochastic Relationships and Scatter Diagrams
觀念 Scatter Plot可以顯示兩連續變數x, y之間的關聯 形式與 強度: 依 變項y 自變項x

25 兩變數之間的關連 解讀scatter plot,首先注意overall pattern 注意是否有極端值? Form Direction
Strength 注意是否有極端值?

26 Form形式: X與Y之間的關係為線性還是非線性?
(b) (a)

27 Strength強度:X與Y之間的關聯強度為何?
(b) (c)

28 negatively associated 負向關連
Direction方向:X與Y之間的關係是正向還是反向? X (d)

29 positively associated 正向關連
Direction方向:X與Y之間的關係是正向還是反向? X (d)

30 我們用簡單圖形可以來瞭解兩變數x與y之間的關係。另一種分析兩變數關係的統計技術為相關分析(correlation analysis)。
Covariance, 共變量 觀念 我們用簡單圖形可以來瞭解兩變數x與y之間的關係。另一種分析兩變數關係的統計技術為相關分析(correlation analysis)。 兩個隨機變數之間的共變關係為何?圖形的表達方式不同,經常會扭曲資料,肉眼的判斷並不準確。

31

32

33

34 當X, Y兩隨機變數不互為獨立時,表示兩者間有關連。其關連的形式有很多種,最常見的關連為線性的共變關係。
Covariance, 共變量 觀念 當X, Y兩隨機變數不互為獨立時,表示兩者間有關連。其關連的形式有很多種,最常見的關連為線性的共變關係。 兩個隨機變數X,Y間的線性關係可用兩個統計量來測量(1) 共變數(covariance) (2) 相關係數 (correlation coefficient)。兩者都能衡量兩變數之間是否有線性關係存在。

35 假設兩變數Y與X之間具有某種關聯,X的平均值為x-bar、Y的平均值為y-bar
Covariance, 共變量 觀念 假設兩變數Y與X之間具有某種關聯,X的平均值為x-bar、Y的平均值為y-bar 樣本變異數

36 測量兩變數之間是否有關連的一個有效指標為共變數(covariance)
觀念 測量兩變數之間是否有關連的一個有效指標為共變數(covariance)

37 例題 求x與y的covariance?

38 I II (14-10)(8-5) =(4)(3) (6-10)(3-5)=(-4)(-2) III IV

39 I II (13-10)(5-8) =(-3)(3) (5-10)(8-5)=(-5)(3) III IV

40 The Population Correlation Coefficient, ρ 母體相關係數
用共變量來衡量兩變數的關係有一個缺點,即sxy的值會受到x與y衡量單位的影響。

41 The Population Correlation Coefficient, ρ 母體相關係數

42 Sample Correlation Coefficient, r 樣本相關係數
因此,我們將covariance分別除上x與y的標準差sx、sy,得到標準化後的指標稱之為相關係數:

43 Sample Correlation Coefficient, r 樣本相關係數
樣本相關係數: 兩變數標準化分數的乘積

44 例題 求x與y的correlation?

45 相關係數的特性 相關係數不區分解釋變項與被解釋變項。 兩變數必須皆為數量變數才能計算相關係數。 相關係數容易受到極端值的影響。 相關係數不受「單位」影響。

46 相關係數不受單位尺度變換的影響

47 相關係數的特性 相關係數衡量兩變數之間是否有線性關係,相關係數愈大,代表兩變數之間的線性關係愈強。相關係數為零,代表兩變數沒有線性關係。 相關係數的值介於正負1之間,正1代表兩者呈完全正相關,負1代表兩者呈現完全負相關。 如果x與y為獨立,則相關係數r = 0。 如果r = 0,x與y不一定為獨立,因為他們可能具有非線性關係。

48 r = 0.8 Y X (a)

49 Y r = .95 X (b)

50 Y r = 0 X (c)

51 Y r = 0 X (a)

52 Y r = -.90 X (d)

53 Y r = -0.5 X (c)

54

55 相關係數的強弱 r =  1 為完全相關 r = 0 為無相關

56 相關係數的特性 證明:若x為y之線性函數y=a+bx,則x與y的相關係數為±1。

57 z 相關係數與因果關係 相關僅代表兩變數間有線性關係,不必然隱含因果關係,下列情況皆有可能
Two variables are said to be spuriously correlated when their correlations is nonzero and there is no reason to believe that the variables are related to one another.

58 控制變項 The relationship between two variables often cannot be fully understood without knowledge of other variables.

59 相關係數與因果關係 商品的價格愈高,需求愈低? 美國職業運動的票價每年都在增長,但需求不減反增。
相關分析僅考慮兩個變數x, y 之間的關係,而忽略其他可能影響y的因素。 人口增加、收入增加、職業運動受歡迎的程度增加等

60 例題 某校MBA畢業生的在學成績(x)與工作起薪(y)的資訊如下: 求r

61 例題

62 The graph of an equation
Y = -3 X + 7 (0,7) (7/3, 0)

63 The graph of an equation

64 The graph of an equation

65 The graph of two equations

66 The graph of an equation

67 The slop of a line

68 Point-slop equation of a line
已知斜率為m且通過(x1, y1)則直線可寫成

69

70

71

72

73 斜率相同的直線為平行線

74 Stochastic Relationships and Scatter Diagrams
觀念 Scatter Plot可以顯示兩連續變數x, y之間的關聯,Correlation告訴我們兩者之間的方向與關聯。迴歸摘要一個解釋變項與一個反應變項之間的關係。 結果變項y 解釋變項x

75 Stochastic Relationships and Scatter Diagrams
觀念 直線上任兩點P1P2,從P1移至P2,x軸座標移動 △x = x2 - x1 y軸座標移動 △y = y2 - y1 依 變項y 自變項x

76 Stochastic Relationships and Scatter Diagrams
觀念 直線上任兩點P1P2,此線的斜率定義為: 依 變項y 自變項x

77 Stochastic Relationships and Scatter Diagrams
觀念 在直線上任意點(P1 或P2)的斜率皆相同,變遷速率為常數 依 變項y 自變項x

78 微分(derivative)簡介 曲線上的斜率為何? 曲線圖形上的各點是否有相同的斜率? (-1, 1) (1, 1)

79 Stochastic Relationships and Scatter Diagrams
如果x與y的關聯分佈圖呈現一近似直線的關係,則我們假設兩者具有以下的線性關係: Slop斜率 X變動ㄧ單位所造成Y相對應的變動 Intercept截距 當X=0時,Y所相對應的值

80 Stochastic Relationships and Scatter Diagrams
截距0

81 Page 136

82

83

84 Deterministic Relationship and Stochastic Relationships
我們的任務在於估計能夠正確描述X與Y關係的截距0與斜率1。 迴歸分析的目的有四: 將x與y的關係以一種量化的方式來表達Quantify a theory。 檢驗有關於X與Y之間關係的理論Test a theory。 測量X與Y之間的關係強度Measuring the strength of relationships。 在已知X值得條件下對Y作預測Forecasting or prediction。

85 Prediction using the regression model
迴歸線可以用來估計在某一特定x值之下,Y的預測值: 我們可以用迴歸線來估計在xi下的”新”觀察值y-hat

86

87 Extrapolation過度延伸預測 使用迴歸線時,不應以以超過解釋變數範疇的數值來從事「預測」。
如以上面的迴歸線來預測20歲成年人的身高:

88 Deterministic Relationship and Stochastic Relationships
在Y=f(X)的函數關係中,若每一個x值僅對應於單一的y值,則X, Y之間的關係為完全決定的函數關係,稱為確定模型(deterministic) Deterministic Relationships 電腦每台$960元,X為電腦台數,Y為總收益

89 Deterministic Relationship and Stochastic Relationships
所有的資料點都剛好落在線上

90 Deterministic Relationship and Stochastic Relationships
Stochastic Relationships: 若X=xi時,Y值不確定,而是依循某一機率分配,則X, Y之的函數關係稱為 機率模型(stochastic)。 令X為每家庭的年收入,Y為每個家庭每年在育樂上的支出。對於某個特定的值X = xi而言,我們無法準確地預測出對應於Y的單一值,因為除了收入外,還有很多其他因素會影響育樂支出。但是知道一個家庭的年收入有助於我們預測育樂支出,第i個家庭的育樂支出可以用下列機率模型表達:


Download ppt "Chapter 3 Association: Contingency, Correlation, and Regression"

Similar presentations


Ads by Google