Presentation is loading. Please wait.

Presentation is loading. Please wait.

Stochastic Relationships and Scatter Diagrams

Similar presentations


Presentation on theme: "Stochastic Relationships and Scatter Diagrams"— Presentation transcript:

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

2 Stochastic Relationships and Scatter Diagrams
截距0 ©蘇國賢2007

3 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。 ©蘇國賢2007

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

5 Deterministic Relationship and Stochastic Relationships
所有的資料點都剛好落在線上 ©蘇國賢2007

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

7 Deterministic Relationship and Stochastic Relationships
其中ei為一個隨機變數,使育樂支出高於或低於( xi)。 也就是說,對於某個特定的xi值而言,其相對應的可能Y值具有某種機率分配。 ei代表除了家庭收入外,所有其他因素對育樂支出造成的影響。 ©蘇國賢2007

8 Deterministic Relationship and Stochastic Relationships
ei的來源: 行為的隨機性(human indeterminacy) 測量的誤差(measurement error) 其他無法觀察到影響Y的因素(omission of the influence of innumerable chance events) ©蘇國賢2007

9 每一個特定的x值所相對應的y值不會剛好落於斜線上

10 我們假設在任何一X值下,Y有相同的分配,且其期望值E(Y|X)剛好落在一直線上。
ei為隨機變數且具有一定的機率或抽樣分配 迴歸的預測值 (相同收入水準家庭其育樂支出的平均值) 觀察到的樣本值

11 Population regression line
我們假設在母體中,對於每一個xi值而言,其相對應的yi值遵循某種機率分配,且期望值為 F(Y|X) Y 我們假設這些分配有相同的變異數σ2 與x相對應的一組y,其平均值剛好落在一條直線上 X

12 F(Y|X) Y E(y1) E(y2) E(y3) x1 x2 x3

13 隨機誤差項εi為隨機變數Yi與X= xi時Yi的期望值之間的差距。
Random Error Term 隨機誤差項εi為隨機變數Yi與X= xi時Yi的期望值之間的差距。 F(Y) Y X

14 εi反映除了家庭收入外,影響育樂支出的其他因素如小孩人數、家庭成員年齡等。
每一個家庭的育樂支出可以拆解成兩部分: (1) 系統部份~在某一收入水準下平均的育樂支出(β0 +β1xi) (2) εi~與系統部份偏離的程度

15 εi 假設E(εi) = 0

16 Population regression line
由於母體參數β0,β1為未知數,因此母體迴歸線必須透過觀察到的樣本(xi, yi)來推估 F(Y) 從樣本中可以推估出β0,β1的估計值,也可以建構出樣本迴歸線 Y 由於觀察到樣本點(xi, yi)不會剛好落在母體迴歸線上,因此yi與E(Yi|X=xi)會有所差距。 X

17 Sample Regression Line
給定n個觀察到的樣本(xi, yi), i=1, 2, 3,…n 我們可以估計出樣本迴歸線 殘差值愈小表示樣本迴歸線與每一觀察點愈接近迴歸線

18 簡單迴歸模型的基本假設

19 Method of Least Squares
如何找出一條最具有代表性的回歸線? 每一個人用肉眼判斷,得到的結果都不會一樣,因此需要一個較精準的方法。 ©蘇國賢2007

20 有無限多種可能 ©蘇國賢2007

21 Method of Least Squares
尋求迴歸係數的估計式有許多種方法,最常用的為 普通最小平方法(ordinary least squares method)及最大概似法(Maximum likelihood method) ©蘇國賢2007

22 Method of Least Squares
由於母體參數β0,β1為未知數,因此母體迴歸線必須透過觀察到的樣本(xi, yi)來推估 尋求迴歸係數的估計式有許多種方法,最常用的為 普通最小平方法(ordinary least squares method)及最大概似法(Maximum likelihood method) ©蘇國賢2007

23 Method of Least Squares
找出最適合樣本資料的一條直線,使預測值與觀察值的差異最小。 ©蘇國賢2007

24 Method of Least Squares
©蘇國賢2007

25 Residual Sum of Squares
由於殘差值有正有負,無法正確測量出兩者的距離,因此將殘差值加以平方。 我們的目標是要找出一條線,使每一個觀察值與預測值的距離的平方和最小: ©蘇國賢2007

26 Residual Sum of Squares
當b0=? b1 =? 時SSE會是最小值? ©蘇國賢2007

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

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

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

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

31 微分(derivative)簡介 在(-1, 1)點上,x值增加,y值下降 在(1, 1)點,x值增加,Y直也增加
簡單的說,微分就是找出變遷的速率( a rate of change) 在(-1, 1)點上,x值增加,y值下降 在(1, 1)點,x值增加,Y直也增加 (-1, 1) (1, 1) ©蘇國賢2007

32 微分(derivative)簡介 曲線在任一點的斜率為與該點相切的切線之斜率 Tangent line切線 (1, 1) (-1, 1)
©蘇國賢2007

33 微分(derivative)簡介 任一點上的斜率為何? 利用:給定任意兩點,可以求直線的斜率。 Tangent line切線 (1, 1)
(-1, 1) ©蘇國賢2007

34 微分(derivative)簡介 Secant line 割線 ©蘇國賢2007

35 微分(derivative)簡介 Secant line 割線 ©蘇國賢2007

36 微分(derivative)簡介 Secant line 割線 ©蘇國賢2007

37 微分(derivative)簡介 Tangent line 切線 ©蘇國賢2007

38 Slope of the Tangent Line
©蘇國賢2007

39 Slope of the Tangent Line
©蘇國賢2007

40 Slope of the Tangent Line
©蘇國賢2007

41 Slope of the Tangent Line
©蘇國賢2007

42 Slope of the Tangent Line
m = -4 m = 2 ©蘇國賢2007

43 Derivative The derivative of function f with respect to x is the function f ' defined by ©蘇國賢2007

44 Notation for the derivative
f ' (x) 讀做 "f prime of x" y ' 讀做 "y prime" "the derivative of y with respect to x" "dee y dee x" "the derivative of f(x) with respect to x" "dee f(x) dee x" ©蘇國賢2007

45 Let f(x) = x3, Find the derivative
©蘇國賢2007

46 Let f(x) = x2-5x+1, Find the derivative
©蘇國賢2007

47 Basic Rules for Differentiation
Rule 1: the derivative of a constant is zero ©蘇國賢2007

48 Basic Rules for Differentiation
Rule 2: the derivative of a linear function ©蘇國賢2007

49 Basic Rules for Differentiation
Rule3: the derivative of a power function ©蘇國賢2007

50 以微分(derivative)找極大及極小值
Tangent line 切線 f(x)的極小值出現在切線斜率等於零的時候 ©蘇國賢2007

51 Residual Sum of Squares
當b0=? b1 =? 時SSE會是最小值? ©蘇國賢2007

52 Residual Sum of Squares
SSE會有最小值 ©蘇國賢2007

53 Residual Sum of Squares
©蘇國賢2007

54 Residual Sum of Squares
Normal Equation 將(1)式兩邊除以n ©蘇國賢2007

55 Residual Sum of Squares
將(1)式乘以Σxi 將(2)式乘以n ©蘇國賢2007

56 Residual Sum of Squares
將(5)-(4) ©蘇國賢2007

57 Residual Sum of Squares
上下同除n ©蘇國賢2007

58 Residual Sum of Squares
©蘇國賢2007

59 Residual Sum of Squares
©蘇國賢2007

60 Sample Correlation Coefficient, r 樣本相關係數
樣本相關係數: ©蘇國賢2007

61 相關係數與斜率 簡單迴歸的斜率: 分子分母除以n-1: r與b1的正負號相同 r=0 if and only if b1=0
©蘇國賢2007

62

63

64 STATA ©蘇國賢2007

65 例題 求x與y的correlation? ©蘇國賢2007

66 例題 求x與y的簡單迴歸線斜率b1?

67 例題 由於股票的價格與其獲利能力有很大的關聯,因此股價通常為股利的線性函數,任取十種股票來估計簡單迴歸線並預測股利為x=13元時股價
©蘇國賢2007

68

69

70

71 迴歸方程式的解釋力 當我們計算出迴歸線後,我們想進一步知道迴歸曲線與資料間的適合度(goodness of fit)。
母體迴歸線告訴我們x與y有下列線性關係 上式告訴我們有兩個因素會影響Y值的變異: Y值會隨著xi值的改變而變:這一部份的變異為被迴歸線解釋的變異。 Y值會隨著ei值而變:這一部份為迴歸線無法解釋的變異。 ©蘇國賢2007

72 簡單迴歸模型 未被解釋的變異 總變異量 被解釋的變異 ©蘇國賢2007

73 變異數的分解 未被解釋的變異稱為殘差值residual,第i個觀察值的殘差值定義為: ©蘇國賢2007

74 變異數的分解 ©蘇國賢2007

75 變異數的分解 總變異量 Sum of Square Total 解釋變異量 Regression Sum of Square
未解釋變異量 Sum of Square Error ©蘇國賢2007

76 變異數的分解 兩邊除SST 判定係數為可解釋變異量佔總變異量的比例,表示X對Y的變異之解釋能力。 R2愈大,表示X對Y的解釋能力愈強
©蘇國賢2007

77 變異數的分解 以樣本變異數來計算 ©蘇國賢2007

78 變異數的分解 ©蘇國賢2007

79 變異數的分解 ©蘇國賢2007

80 求R2?

81

82 ©蘇國賢2007

83 r= r2=0.989 ©蘇國賢2007

84 r= r2=0.849 ©蘇國賢2007

85 Page 136 ©蘇國賢2007

86 r2 Variance of value y = 5.30091 Variance of predicted y= 5.24135
©蘇國賢2007

87 ©蘇國賢2007


Download ppt "Stochastic Relationships and Scatter Diagrams"

Similar presentations


Ads by Google