Work Cata
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    ## **【Statistics 基礎統計 : 統計相關性、迴歸分析】** :::info - 共變異數(Covariance)和相關係數(Correlation Coefficient) - 共變數(Covariance): 共變數衡量兩個隨機變數的變化趨勢,即當一個變數增加時,另一個變數是否傾向於增加或減少 - 相關係數(Pearson Correlation Coefficient): 相關係數是共變數的標準化版本,它衡量兩個連續變數之間的線性相關程度,並且縮放在-1到1的範圍內 - 迴歸分析 - 迴歸分析 : 用於建立一個模型來預測一個變數如何依賴於其他變數。一個或多個自變數(解釋變數),與因變數(反應變數)之間的關係,通常用 X 表示自變數,可以自己改變,Y 表示因變數,改變取決於自變數的值 - 截距 (Y-Intercept),定自變量、定因變量,產生的y截距。算出來的結果為自變量為零時的預測因變量值 * excel: =intercept(C2:C100,B2:B100) - 變化敏感度 (Slope),斜率函數,返回同一回歸的斜率或係數。算出來的結果?為自變量每增加一個單位時,因變量平均會增加?個單位 * excel: =slope(C2:C100,B2:B100) - 預測函數 (Predictions),給予x作為預測值,樣本的y索引值,給予預測 * excel: =forecast(原本數值,C2:C100,B2:B100)) - 最小平方法(Least Squares Method):是一種透過最小化觀測資料中實際值與模型預測值之間的差異來估計模型參數的方法 - 決定係數或R平方 (R-Squared),R平方越高,準確性越高,假設判定係數不是很高,可以試著移除離群值再重算一次迴歸 - 狀態標準誤差 (Standard Error) * excel: =STEYX(known_ys,known_xs) - 均方誤差 MSE (Mean Squared Error) - 平均絕對誤差(Mean Absolute Error,MAE) - 均方根誤差(Root Mean Squared Error,RMSE) - 迴歸與相關係數比較 - 練習 - 同方差 (Homoskedasticity): 隨著自變數的變化,因變數的變異數保持恆定。換句話說,各個自變數的觀測值圍繞迴歸線分佈的變異數是相等的,代表資料的離散程度相對穩定,不隨自變數的變化而改變 - 異方差 (Heteroskedasticity): 說明誤差項的變異數是恆定的,使模型的估計更為準確。如果出現Heteroskedasticity,則可能會導致對模型的估計出現偏差。 因此在進行迴歸分析時,檢定資料是否符合 Homoskedasticity 假設很重要 - ANOVA 顯著性檢定(Analysis of Variance): 通過檢查變異數的差異,來判斷兩個或多個組別之間的平均值是否有統計學上的差異 - 單因子ANOVA變異數分析(One-Way ANOVA): 比較一個因子下的三個或三個以上群體的平均值是否相等 - 雙因子ANOVA變異數分析(Two-Way ANOVA): 比較兩個因子對於結果的影響,同時考慮這兩個因子的主效應和交互作用效應 - 無交互 - 有交互 - 卡方檢驗(Chi-square test): 無母數分析,檢驗兩個或多個"分類變數"之間是否存在相依性 *excel =CHITEST(A1:B3) 獨立性 excel =CHITEST(A1:A3, B1:B3) 擬合度 - 多元迴歸: 一個因變數如何受到兩個或更多自變數的影響。xi 自變數間的相關性越低越好,若 > 0.8,通常只取一個; xi與yi相關性越高越好。若xi為0,對yi預測力最大,並可避免多元共線性問題 - 迴歸分析的假設(Assumption regression analysis) - 線性關係假設:自變數與因變數之間存在**線性關係 ** - 獨立性假設:模型和觀測值之間**相互獨立**,即一個觀測值的殘差不受其他觀測值的影響 - 常數變異數假設:無論自變數的取值如何,因變數的變異性都應該保持相對穩定,也稱為**同方差性假設** - 常態性假設:**殘差(預測值與實際值之差)是常態分佈**的,這有助於進行統計推論 - 無共線性假設:自變數之間**不存在**完美共線性,即自變數不是嚴格相關的,共線性可能導致參數估計不準確 - 迴歸分析的誤差、細微差別(Subtleties of regression analysis) : - 線性假設:大多數迴歸模型都基於線性假設,在某些情況下,這個假設可能不成立,需要考慮**非線性模型** - 多重共線性:當自變數之間存在高度相關性時,迴歸模型可能受到**多重共線性**的影響,使得參數估計不準確,可以透過**特徵選擇**或**正則化方法**來解決 - 變數選擇:選擇哪些**自變數**包含在模型中是一個重要的問題,需要考慮領域知識和特徵的重要性 - 異常值:異常值(Outliers)可能對迴歸模型產生顯著影響,在分析前需要檢測和**處理異常值** ::: :::warning - 課程、網頁: - 中華科大 CUSTCourses [【統計學-李柏堅】](https://www.youtube.com/watch?v=sXMOx9Pbpe4&list=PLP1Ynr8cs97tPCMS0jOEYFNJoz7CelIJ5) - 交大 OCW 公開課程[【統計學(一)(基礎統計) - 工業工程與管理學系 唐麗英老師】](https://www.youtube.com/watch?v=3okbnliWIlU&t=2s) - Udemy [【Statistics for Data Science and Business Analysis】](https://www.udemy.com/course/statistics-for-data-science-and-business-analysis/?utm_source=adwords&utm_medium=udemyads&utm_campaign=DSA_Catchall_la.EN_cc.ROW&utm_content=deal4584&utm_term=_._ag_88010211481_._ad_535397282061_._kw__._de_c_._dm__._pl__._ti_dsa-41250778272_._li_9040379_._pd__._&matchtype=&gclid=CjwKCAjwsKqoBhBPEiwALrrqiMy7g9P6ZjPz6g4QXJXkRJhSUlR3kmZe9yeE5s2V5_QoLJyyjvObHxoC_HEQAvD_BwE) ::: ### :+1:共變異數(Covariance)和相關係數(Pearson Correlation Coefficient) - 共變數(Covariance): 共變數衡量兩個隨機變數的變化趨勢,即當一個變數增加時,另一個變數是否傾向於增加或減少 正共變異數: 當X 上升時,Y 也上升,共變異數為正 負共變異數: 當X 上升時,Y 下降,共變異數為負 零共變異數: 無法推斷兩者的變動是否存在直線相關性 ![螢幕擷取畫面 2023-12-05 025310](https://hackmd.io/_uploads/r1N7xoir6.png) ![螢幕擷取畫面 2023-12-02 131223](https://hackmd.io/_uploads/Hy2a34uST.png) ![螢幕擷取畫面 2023-12-02 131228](https://hackmd.io/_uploads/BJk0hNdrp.png) ![螢幕擷取畫面 2023-12-02 131921](https://hackmd.io/_uploads/r1uw0EOra.png) <br/> - 相關係數(Correlation Coefficient): 相關係數是共變數的標準化版本,它衡量兩個連續變數之間的線性相關程度,並且縮放在-1到1的範圍內 *excel: =correl(B2:B100, C2:C100) 低度相關: |r| < 0.4 中度相關: 0.4 < |r| < 0.7 高度相關: 0.7 < |r| < 1 ![螢幕擷取畫面 2023-12-05 025350](https://hackmd.io/_uploads/Syk8gsor6.png) ![螢幕擷取畫面 2023-11-20 141516](https://hackmd.io/_uploads/BJDYtOuN6.png) ![螢幕擷取畫面 2023-11-20 141521](https://hackmd.io/_uploads/rksFFu_Na.png) ![](https://hackmd.io/_uploads/rJoxCD31p.png) ![](https://hackmd.io/_uploads/HJRg0whJa.png) ![](https://hackmd.io/_uploads/rJAOCwnka.png) ![](https://hackmd.io/_uploads/B1MF0Pnk6.png) 練習一 ![螢幕擷取畫面 2023-12-05 025527](https://hackmd.io/_uploads/BkhjljiBp.png) 練習二 ![螢幕擷取畫面 2023-12-05 030050](https://hackmd.io/_uploads/BkMgGosBa.png) 練習三 (數理統計才會有) ![螢幕擷取畫面 2023-12-05 030223](https://hackmd.io/_uploads/SJTBGijH6.png) 練習四 ![螢幕擷取畫面 2023-12-02 144401](https://hackmd.io/_uploads/ByhSMU_rp.png) ```= import numpy as np # 生成示例數據 X = np.array([1, 2, 3, 4, 5]) Y = np.array([5, 4, 3, 2, 1]) # 計算共變數 covariance = np.cov(X, Y, ddof=0) # 使用ddof=0表示計算樣本共變數,ddof=1表示計算樣本共變數修正 print("共變數矩陣:") print(covariance) # 計算相關係數 correlation = np.corrcoef(X, Y) print("相關係數矩陣:") print(correlation) ``` 練習五 *excel: =PEARSON(B2:B100,C2:C100) ```= import numpy as np import scipy.stats as stats # 假設有兩組數據 data1 = [1, 2, 3, 4, 5] data2 = [5, 4, 3, 2, 1] # 計算皮爾森相關係數 correlation_coefficient, p_value = stats.pearsonr(data1, data2) print(f"皮爾森相關係數:{correlation_coefficient:.2f}") print(f"p-value:{p_value:.4f}") if p_value < 0.05: print("相關性具有統計顯著性") else: print("相關性不具有統計顯著性") ``` ```= # 數學公式寫法 import numpy as np # 假設有兩組數據 data1 = [1, 2, 3, 4, 5] data2 = [5, 4, 3, 2, 1] # 計算兩組數據的平均值 mean_data1 = np.mean(data1) mean_data2 = np.mean(data2) # 計算相關性的分子部分 numerator = sum((x - mean_data1) * (y - mean_data2) for x, y in zip(data1, data2)) # 計算相關性的分母部分 denominator_data1 = np.sqrt(sum((x - mean_data1) ** 2 for x in data1)) denominator_data2 = np.sqrt(sum((y - mean_data2) ** 2 for y in data2)) # 計算皮爾森相關係數 correlation_coefficient = numerator / (denominator_data1 * denominator_data2) print(f"皮爾森相關係數:{correlation_coefficient:.2f}") ``` <br/> ### :+1:迴歸分析 - 迴歸分析 : 用於建立一個模型來預測一個變數如何依賴於其他變數。一個或多個自變數(解釋變數),與因變數(反應變數)之間的關係,通常用 X 表示自變數,可以自己改變,Y 表示因變數,改變取決於自變數的值 一旦建立了模型,我們需要評估它的性能,通常使用各種統計指標進行評估,包括均方誤差(Mean Squared Error)、決定係數(Coefficient of Determination,R-squared)、殘差分析等,最後使用模型進行預測 ![螢幕擷取畫面 2023-12-04 195834](https://hackmd.io/_uploads/Hy8ekrsST.png) ![螢幕擷取畫面 2023-12-04 195904](https://hackmd.io/_uploads/HJFGJrorp.png) ```= import numpy as np import matplotlib.pyplot as plt from scipy import stats # 假設有一組自變量和因變量數據 x = np.array([1, 2, 3, 4, 5]) y = np.array([2, 3, 4, 3, 5]) # 進行簡單線性回歸分析 slope, intercept, r_value, p_value, std_err = stats.linregress(x, y) # 使用回歸模型進行預測 predicted_y = slope * x + intercept # 繪製原始數據和回歸線 plt.scatter(x, y, label='原始數據') plt.plot(x, predicted_y, color='red', label='線性迴歸線') plt.xlabel('自變量') plt.ylabel('因變數') plt.legend() plt.title('簡單線性回歸分析') plt.show() print(f"斜率:{slope:.2f}") print(f"截距:{intercept:.2f}") print(f"相關係數:{r_value:.2f}") print(f"p-value:{p_value:.4f}") print(f"標準誤差:{std_err:.2f}") ``` ```= # 數學公式寫法 import numpy as np import matplotlib.pyplot as plt # 假設有一組自變數和因變數數據 x = np.array([1, 2, 3, 4, 5]) y = np.array([2, 3, 4, 3, 5]) # 計算自變數和因變數的平均值 mean_x = np.mean(x) mean_y = np.mean(y) # 計算斜率和截距 numerator = sum((xi - mean_x) * (yi - mean_y) for xi, yi in zip(x, y)) denominator = sum((xi - mean_x) ** 2 for xi in x) slope = numerator / denominator intercept = mean_y - slope * mean_x # 使用回歸模型進行預測 predicted_y = [slope * xi + intercept for xi in x] # 繪製原始數據和回歸線 plt.scatter(x, y, label='原始數據') plt.plot(x, predicted_y, color='red', label='線性回歸線') plt.xlabel('自變數') plt.ylabel('因變數') plt.legend() plt.title('簡單線性回歸分析') plt.show() print(f"斜率:{slope:.2f}") print(f"截距:{intercept:.2f}") ``` - 截距 (Y-Intercept) : 當所有自變數為零時,因變數的預期值。定自變量、定因變量,產生的y截距 * excel: =intercept(C2:C100,B2:B100) - 變化敏感度 (Slope) : ,表示因變數對於自變數的變化的敏感程度。斜率函數,返回同一回歸的斜率或係數。算出來的結果?為自變量每增加一個單位時,因變量平均會增加?個單位 * excel: =slope(C2:C100,B2:B100) - 預測函數 (Predictions),給予x作為預測值,樣本的y索引值,給予預測 * excel: =forecast(原本數值,C2:C100,B2:B100)) > PS 原數值x * Slope * Y-Intercept = 預測值x > 算出來會跟forcast函數差不多 <br/> - 最小平方法(Least Squares Method):是一種透過最小化觀測資料中實際值與模型預測值之間的差異來估計模型參數的方法 ![螢幕擷取畫面 2023-12-04 234551](https://hackmd.io/_uploads/HyAEVOirT.png) ![螢幕擷取畫面 2023-12-04 235222](https://hackmd.io/_uploads/BJBTrusH6.png) 練習一 ![螢幕擷取畫面 2023-12-04 235259](https://hackmd.io/_uploads/BkAyLdjS6.png) ![螢幕擷取畫面 2023-12-05 014730](https://hackmd.io/_uploads/H1gpe5oST.png) <br/> - 決定係數或R平方 (R-Squared),R平方越高,準確性越高,假設判定係數不是很高,可以試著移除離群值再重算一次迴歸 ![螢幕擷取畫面 2023-12-05 015037](https://hackmd.io/_uploads/H1o_WqiHa.png) ![螢幕擷取畫面 2023-12-05 015111](https://hackmd.io/_uploads/S1yjb9jH6.png) ![螢幕擷取畫面 2023-12-05 015138](https://hackmd.io/_uploads/rJw2Z9oSa.png) ![螢幕擷取畫面 2023-12-05 015213](https://hackmd.io/_uploads/ByTCZ5oHp.png) 練習一 適配程度高 0.967 ![螢幕擷取畫面 2023-12-05 015329](https://hackmd.io/_uploads/rkPLG9sH6.png) 練習二 ![螢幕擷取畫面 2023-12-05 025038](https://hackmd.io/_uploads/BynK1oorp.png) R平方 = 1-((SSE 值與迴歸線的距離/平方總和)/ SST 值與平均線的距離) SSE = SUMSQ(C2:C100-FORECAST.LINEAR(B2:B100,C2:C100,B2:B100)) SST = SUMSQ(C2:C100-AVERAGE(C2:C100)) >PS 可以直接用公式 excel: =RSQ(C2:C100,B2:B100) - 狀態標準誤差(Standard Error): 對因變數測量誤差的估計。表示模型預測值與實際觀測值之間的平均差異 *excel: =STEYX(known_ys,known_xs) - 均方誤差 MSE (Mean Squared Error): MSE越低,模型擬合效果越好,處理大誤差更加敏感,因為對大誤差進行了平方。殘差平方和除以自由度的平均值 *excel: MSE = SSE/(COUNTA(known_xs)-1-1) ![螢幕擷取畫面 2023-12-10 141237](https://hackmd.io/_uploads/BJrkwRMIp.png) ![螢幕擷取畫面 2023-12-05 020248](https://hackmd.io/_uploads/H15UV9iB6.png) ![螢幕擷取畫面 2023-12-05 020438](https://hackmd.io/_uploads/rJU64qsS6.png) 練習一 ![螢幕擷取畫面 2023-12-05 020407](https://hackmd.io/_uploads/HkaiN5orT.png) 練習二 ![螢幕擷取畫面 2023-12-05 020610](https://hackmd.io/_uploads/S1sXSqorp.png) 練習三 ![螢幕擷取畫面 2023-12-05 024811](https://hackmd.io/_uploads/ByQWyosHa.png) <br/> - 平均絕對誤差(Mean Absolute Error,MAE): 與MSE相似,但對所有誤差都是線性的 ![螢幕擷取畫面 2023-12-10 141613](https://hackmd.io/_uploads/BJJ6vRG8p.png) <br/> - 均方根誤差(Root Mean Squared Error,RMSE): 是均方誤差(MSE)的平方根,更廣泛運用,比起MSE(原始資料單位的平方)、MAE(原始資料的絕對值),RMSE 與原始資料的單位相同 ![螢幕擷取畫面 2023-12-10 142053](https://hackmd.io/_uploads/SJlyKRzUa.png) <br/> - 迴歸與相關係數比較 ![螢幕擷取畫面 2023-12-05 030359](https://hackmd.io/_uploads/Hk9e7iiS6.png) <br/> - 練習 有一欄在校英文成績、一欄原始多益成績before、一欄上過加強班後的多益成績after、一欄after-before的分數差距 我要知道是不是與在校成績呈現迴歸,也想知道如果有位同學在校80, 上過加強班後,會進步幾分? **相關係數** =CORREL(before,after-before) =CORREL(D2:D100,G2:G100) = 0.094接近1,代表呈現迴歸 **截距** =INTERCEPT(after-before,在校英文成績) =INTERCEPT(G2:G100,B2:B100) = -223.42 **變化敏感度** =SLOPE(after-before,在校英文成績) =SLOPE(G2:G100,B2:B100) =3.6394 帶入有位同學在校80 80*slope+intercept = 預測進步幾分 = 67.7 **決定係數或 R 平方** SSE =SUMSQ(G6:G100-FORECAST.LINEAR(B6:B100,G6:G100,B6:B100)) = 11848.73769 SST =SUMSQ(G6:G100-AVERAGE(G6:G100)) = 82665.43158 1- SSE/SST = 0.86 **決定係數或 R 平方 (與上方相同)** =RSQ(G2:G100,B2:B100) = 0.86 代表86%的因變數的變異性可以由自變數的變化來解釋 **狀態標準誤差** =STEYX(G2:G100,B2:B100) =11.28741696 標準誤差偏低,,說明迴歸模型對資料的擬合準確 **均方誤差(Mean Square Error, MSE)** =SSE/(COUNTA(known_xs)-1-1) =11848.73769/(COUNTA(B2:B100)-1-1) =127.41 **推論** 相關係數接近1,顯示在校成績與多益成績改善之間可能存在線性迴歸關係 截距是-223.42,表示在校英文成績與多益成績改善之間有一定的負相關關係,代表在校英文成績為0的情況下,預測的多益成績改善值為-223.42 變化敏感度是斜率,代表在校英文成績每單位的變化對多益成績改善的影響 透過預測方程式,可以估計有位學生在校80分,在上完加強班後可以提高約67.7分 決定係數或R平方約為0.86,顯示86%的因變數變異可以由自變數的變化解釋 狀態標準誤差約為11.29,MSE約為127.41,可以推測68%的學生在多益成績上平均會有一個標準差的進步 - 同方差 (Homoskedasticity): 隨著自變數的變化,因變數的變異數保持恆定。換句話說,各個自變數的觀測值圍繞迴歸線分佈的變異數是相等的,代表資料的離散程度相對穩定,不隨自變數的變化而改變 **F = 均方迴歸(Mean Square Regression, MSR)/ 均方誤差(Mean Square Error, MSE)** MSR 是由模型解釋的方差,而 MSE 是模型未解釋的方差,透過比較 MSR 和 MSE,可以判斷模型的預測是否比只使用平均值更好 當 F 值較大時,表示模型中解釋變數對於因變數的解釋能力較強 **MSR = (SSE - SST )/ q** MSR 是由 SSE(殘差平方和)和 SST(總平方和)的差除以 q 得出的。 它表示在迴歸模型中解釋的平均變異數。 通常,透過計算 MSR 和 MSE(均方誤差),可以計算 F 統計量,從而進行迴歸模型的顯著性檢定 **同上方題目** MSR = (SST-SSE)/1 = (82665.43158 - 11848.73769)/1 = 70816.69389 F = MSR/MSE = 70816.69389/127.4057816 = 0.001799092 P-VALUE =F.DIST.RT(F,1,COUNT(G2:G100)-1-1) =F.DIST.RT(0.001799092,1,COUNT(G2:G100)-1-1) =0.966258238 **推論** F 值很小,而 p 值接近 1,代表迴歸模型並沒有顯著解釋因變數變化的能力 - 異方差 (Heteroskedasticity): 說明誤差項的變異數是恆定的,使模型的估計更為準確。如果出現Heteroskedasticity,則可能會導致對模型的估計出現偏差。 因此在進行迴歸分析時,檢定資料是否符合 Homoskedasticity 假設很重要 <br/> ### 卡方檢驗(Chi-square test): 無母數分析,檢驗兩個或多個"分類變數"之間是否存在相依性 *excel =CHITEST(A1:B3) 獨立性 excel =CHITEST(A1:A3, B1:B3) 擬合度 [卡方分配表](https://www.cnblogs.com/brisk/p/16290198.html) 卡方值小 = 不顯著 觀察頻數(O)和期望頻數(E) - 獨立性 (Oij表示第i行第j列) ![螢幕擷取畫面 2023-12-05 023829](https://hackmd.io/_uploads/ryXT25sSa.png) - 擬合度 ![螢幕擷取畫面 2023-12-05 023838](https://hackmd.io/_uploads/HkDph9jrp.png) 練習一 ![螢幕擷取畫面 2023-12-05 031345](https://hackmd.io/_uploads/r1vlrsora.png) 練習二 (適合度) 不顯著,1.7 < 11.07,無法拒絕H0 ![螢幕擷取畫面 2023-12-05 134704](https://hackmd.io/_uploads/ryOctN2BT.png) 練習三(適合度) 不顯著,2.806 < 3.84,無法拒絕H0 ![螢幕擷取畫面 2023-12-05 134907](https://hackmd.io/_uploads/Sy0-9Vnra.png) ![螢幕擷取畫面 2023-12-05 134930](https://hackmd.io/_uploads/ByrfcNhB6.png) 練習四 (獨立性,搭配二因子列表) 顯著,8.556 < 5.99,拒絕H0,拒絕最初的論述 ![螢幕擷取畫面 2023-12-05 135058](https://hackmd.io/_uploads/S1k8q4hHp.png) ![螢幕擷取畫面 2023-12-05 135338](https://hackmd.io/_uploads/B1JeoE2ST.png) ![螢幕擷取畫面 2023-12-05 135645](https://hackmd.io/_uploads/S13jsEhHa.png) 練習五 (齊一性) 顯著,4.56 < 3.84,拒絕H0,拒絕最初的論述 ![螢幕擷取畫面 2023-12-05 151402](https://hackmd.io/_uploads/rytCTH2BT.png) ![螢幕擷取畫面 2023-12-05 151420](https://hackmd.io/_uploads/S13CpS3HT.png) <br/> ### :+1:ANOVA 顯著性檢定(Analysis of Variance): 通過檢查變異數的差異,來判斷兩個或多個組別之間的平均值是否有統計學上的差異 - 顯著性檢定 ![螢幕擷取畫面 2023-12-05 021207](https://hackmd.io/_uploads/rkBYLqiHa.png) ![螢幕擷取畫面 2023-12-05 021310](https://hackmd.io/_uploads/ry4TU9oB6.png) 查詢f表 *excel =F.INV() ![螢幕擷取畫面 2023-12-05 021405](https://hackmd.io/_uploads/H1TlwciB6.png) 練習一 ![螢幕擷取畫面 2023-12-05 022039](https://hackmd.io/_uploads/rkCc_5sB6.png) ![螢幕擷取畫面 2023-12-05 022149](https://hackmd.io/_uploads/BJ5TO5jST.png) - 單因子ANOVA變異數分析(One-Way ANOVA): 比較一個因子下的三個或三個以上群體的平均值是否相等 ![螢幕擷取畫面 2023-12-05 153217](https://hackmd.io/_uploads/SyHfML2BT.png) ![螢幕擷取畫面 2023-12-05 153305](https://hackmd.io/_uploads/rkESMI2Sa.png) ![螢幕擷取畫面 2023-12-05 153411](https://hackmd.io/_uploads/rJJFMLhHT.png) 練習一 顯著,4.83 > 3.89 ![螢幕擷取畫面 2023-12-05 153451](https://hackmd.io/_uploads/BJYiGInSp.png) ![螢幕擷取畫面 2023-12-05 153512](https://hackmd.io/_uploads/S1S6fLnB6.png) 練習二 ![螢幕擷取畫面 2023-12-05 155522](https://hackmd.io/_uploads/S1qOPLhr6.png) <br/> - 雙因子ANOVA變異數分析(Two-Way ANOVA): 比較兩個因子對於結果的影響,同時考慮這兩個因子的主效應和交互作用效應 ![螢幕擷取畫面 2023-12-05 154959](https://hackmd.io/_uploads/HkqVIUnH6.png) -- 無交互 (=單因子做兩次) ![螢幕擷取畫面 2023-12-05 154217](https://hackmd.io/_uploads/ryGdE8nra.png) ![螢幕擷取畫面 2023-12-05 154253](https://hackmd.io/_uploads/S1qYNI2S6.png) 練習一 ![螢幕擷取畫面 2023-12-05 154323](https://hackmd.io/_uploads/HJgnVU3rp.png) ![螢幕擷取畫面 2023-12-05 154359](https://hackmd.io/_uploads/Syj6NI2Sp.png) 練習二 ![螢幕擷取畫面 2023-12-05 160317](https://hackmd.io/_uploads/SJZIYL2HT.png) ![螢幕擷取畫面 2023-12-05 160350](https://hackmd.io/_uploads/HkXOFLnra.png) -- 有交互 ![螢幕擷取畫面 2023-12-05 155040](https://hackmd.io/_uploads/Bk3wU82ra.png) ![螢幕擷取畫面 2023-12-05 154905](https://hackmd.io/_uploads/B1MbI8nH6.png) <br/> ### :+1:多元迴歸: 一個因變數如何受到兩個或更多自變數的影響。xi 自變數間的相關性越低越好,若 > 0.8,通常只取一個; xi與yi相關性越高越好。若xi為0,對yi預測力最大,並可避免多元共線性問題 ![螢幕擷取畫面 2023-12-05 022501](https://hackmd.io/_uploads/SJG9K5jH6.png) ![螢幕擷取畫面 2023-12-05 022848](https://hackmd.io/_uploads/Syzd5csra.png) ![螢幕擷取畫面 2023-12-05 022930](https://hackmd.io/_uploads/r1595qoST.png) 練習一 ![螢幕擷取畫面 2023-12-05 024130](https://hackmd.io/_uploads/HyiPacjS6.png) <br/> ### :+1:迴歸分析的假設(Assumption regression analysis) - 線性關係假設:自變數與因變數之間存在**線性關係 ** - 獨立性假設:模型和觀測值之間**相互獨立**,即一個觀測值的殘差不受其他觀測值的影響 - 常數變異數假設:無論自變數的取值如何,因變數的變異性都應該保持相對穩定,也稱為**同方差性假設** - 常態性假設:**殘差(預測值與實際值之差)是常態分佈**的,這有助於進行統計推論 - 無共線性假設:自變數之間**不存在**完美共線性,即自變數不是嚴格相關的,共線性可能導致參數估計不準確 <br/> ### :+1:迴歸分析的誤差、細微差別(Subtleties of regression analysis) - 線性假設:大多數迴歸模型都基於線性假設,在某些情況下,這個假設可能不成立,需要考慮**非線性模型** - 多重共線性:當自變數之間存在高度相關性時,迴歸模型可能受到**多重共線性**的影響,使得參數估計不準確,可以透過**特徵選擇**或**正則化方法**來解決 - 變數選擇:選擇哪些**自變數**包含在模型中是一個重要的問題,需要考慮領域知識和特徵的重要性 - 異常值:異常值(Outliers)可能對迴歸模型產生顯著影響,在分析前需要檢測和**處理異常值** <br/>

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully