1. 程式人生 > >Welcome to DaxinPai's Blog

Welcome to DaxinPai's Blog

在資料分析中,遇到統計問題的時候,基本可以按照下表來:
statistics method

(圖片來源自網上,出處不詳)

那麼首先我們需要判斷是否是正態分佈(Normal Distribution), 四種方法:

  1. 繪製資料的直方圖,看疊加線——這是一種粗略的方法,且不是硬性( hard-and-fast)指標。一般來說看得多了你就知道哪些是屬於正態分佈,哪些不屬於。

  2. 偏態值(Skewness)峰態值(Kurtosis):
    Skewness 是關於分佈是否對稱的指標。
    分為正偏態分佈(positively skewed distribution ,整體往左偏)和負偏態分佈(negatively skewed distribution,整體往右偏)
    Kurtosis 是關於分佈峰值陡峭情況的一個指標。
    它是指整個曲線的形狀是鍾型(bell-shaped )的而不是例如肥胖型或尖峰型等等。
    正態分佈的Skewness 和 Kurtosis 都是 0

    ,所以離0 越遠越不是正態分佈,但是到底多少距離 0 我們可以認為它是正態的呢?這個就難辦了,所以出現了下面的辦法,它是結合了偏態值和峰態值的一種統計檢驗方法。

  3. Kolmogorov-Smirnov test (K-S)Shapiro-Wilk (S-W) test
    他們是通過comparing your data to a normal distribution with the same mean and standard deviation of your sample 來檢驗是否正態的。
    如果檢驗不顯著(NOT significant,即大於0.05),則是正態的,顯著的話(significant,即小於0.05),則是非正態的。
    需要注意的是,樣本越大,越有可能得到顯著的結果。

  4. 另外一種方法就是做圖畫點的方法,叫做“Normal Q-Q Plot”。
    The black line indicates the values your sample should adhere to if the distribution was normal. The dots are your actual data. If the dots fall exactly on the black line, then your data are normal. If they deviate from the black line, your data are non-normal.

一些很明顯不是正態分佈的情形:
when the outcome is an ordinal variable or a rank
when there are definite outliers or
when the outcome has clear limits of detection.

第二個就是判斷是否是方差齊性(Homogeneity of variance)

首先要知道什麼是方差齊性:是指每一個總體的方差都是相同的。它是ANOVA分析的基礎。數學表示如下:
H0=σ21=σ22==σ2n

檢驗是否具有方差齊性的方法主要有三個:
Bartlett’s Test
Levene’s Tes
Brown-Forsythe Test
同時 F statistic test 也可以用來判斷方差齊性。

關於 parametricnonparametric

什麼是 nonparametric?
即方差不齊或者不是正態分佈,Distribution-free,與 Parametric 對應

根據以上即可推出:
什麼時候用 Nonparametric Tests呢?
1、方差不齊或者非正態時
2、資料是 名詞意義的或者有序的 (非正態的常見情況)
3、樣本非常小的時候
當然每一組肯定還是任意分配的

In general, when compared to a corresponding parametric test, a nonparametric test is less powerful.
For very small samples, nonparametric tests can be as powerful as the parametric counter parts.

Q: 樣本大小跟 nonparametric 的關係?
• Validity of the unpaired t-test is not seriously compromised by violating the assumption of
equality of variance IF n1 = n2.
• If sample sizes are unequal, differences in variance can affect the accuracy of the t-statistics.
(From course material)

常見Test 說明

Parametric tests:

T-Test for Independent Samples
Equal Variances、unpaired
T-test 是在比較兩者的均值(means)
independent 是指 unpaired t-test
既可以用作equal variance 又可以是在 unequal variance 的情況下:
Unpaired T-Test
Unpaired T-Test 2

T-Test for Paired Samples

Subjects may be matched on relevant variables (age, twins, etc.), or using self as control.
Paired T-Test

One-Way Analysis of Variance for Independent Samples
ANOVA 是比較兩組以上均值的
one way 指的是independent variable or factor, with 3 or more levels.(一個變數,但該變數在每組的程度不同)
它是基於 F 檢驗的:
F-Test
F-Test2

A significant F-ratio does NOT indicate each group is different from all other groups.
It only tells us that there is a significant difference between at least 2 of the means (largest vs smallest).

(Need to be continued)