# model selection, adjusted goodness of fit, DfBeta ###### tags: `Categorical data analysis` ## Model selection 以下以 crab data 為例,共有這些模型  若要將兩個模型做比較看哪個比較好,可以有兩種方法: AIC 跟 LR test,通常若兩個模型有複雜跟簡單的關係 Ex. model6c 跟 model7a ,會使用 LR test,若 model 之間沒啥關係 Ex. model7a 跟 model7b ,通常使用 AIC。 這邊的 G2 即是該 model 的 deviance,所以 LR test 為 :::success <font size = 5.5> $G2(簡單) - G2(複雜) \rightarrow \chi^2(df(簡單) - df(複雜))$ </font> ::: 當 test statistics 顯著時,認為簡單的模型配適度不佳,可能有 overdispersion 的問題,比較傾向使用較複雜的model ## Goodness of fit Adjustment 當 effective sample size 約等於 sample size 時,也就是一組裡面的樣本數過少, LR test 的大樣本卡方會有問題,這個時候可以做 Hosmer-Lemeshow(HL) test,概念上是他會自己做分組(通常會分成10組),解決樣本數過少的問題。當 test statistic 顯著時代表該模型配適不佳,可能有 overdispersion 的問題  ### SAS code ``` sas= proc logistic data = m3 desc; class v2 (ref = first) v3 v7 v8 / param = ref; model y = v1 v2 v3 v7 v8 / aggregate scale = none lackfit; run; ``` ### SAS intepretation  以上結果 fail to reject $H_0$,代表說這個 logistic model 配適是合適的,沒有 overdispersion 的問題 ## 敏感點偵測(DfBeta) 在觀察值中,常常會有 outlier 或者是敏感點,意思是這個點對 $\beta$ 跟 deviance 的估計影響很大,這個時候可以用 leave-one-out 的方法來找出敏感點 ### SAS code ``` sas= proc logistic data = m3 desc; class v2 (ref = first) v3 v7 v8 / param = ref; model y = v1 v2 v3 v7 v8 / influence ; ods output influence = out; run; ``` ### SAS intepretation   1. 流水碼: 移掉第 k 筆資料 2. 移掉第 k 筆資料後所做出來的模型估計值 3. Pearson residual 的估計值 4. Deviance residual 的估計值 5. 與把全部資料都放進去所估出來的 $\beta_0$ 的差異 6. 與把全部資料都放進去所估出來的 $\beta$ 的差異 7. 與把全部資料都放進去所估出來的 deviance residual 的差異 8. 與把全部資料都放進去所估出來的 pearson residual 的差異  1. DiffChi 2. DiffDev 可以從 DiffChi 看出似乎有兩個 case 是 influencial case,所以可以嘗試把這兩個點拿掉之後再做做看 logistic,然後跟原本的比較。
×
Sign in
Email
Password
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