# Binary data, overdispersion ###### tags: `Categorical data analysis` ## Binary data 前面在檢測有無線性關係用的是 :::success <font size = 5.5> $\pi_i = \alpha + \beta x_i$ </font> ::: 這個就會有範圍的問題。而如果採用logit link i.e. :::success <font size = 5.5> $ln \frac{\pi_i}{1 - \pi_i} = \alpha + \beta x_i$ $0 < \pi_i = \frac{e^{\alpha + \beta x_i}}{1 + e^{\alpha + \beta x_i}} < 1$ </font> ::: 如此便可以將linear model跟parameter的範圍confine成一樣的了 ### Alternative 對於劑量vs.是否死亡的experiment,假設$Y = 1$為死亡,想要test $P(Y = 1| X = x)$,其中$X$為耐受度的分布,也就是說$P(Y = 1| X = x)$其實就等價於$P(X \leq x)$。 若假設耐受度分布為standard normal,則有 <font size = 5.5> $\pi_i = \Phi(\alpha + \beta x_i)$ $\Phi^{-1}(\pi_i) = \alpha + \beta x_i$ </font> This is called <b>Probit model</b> ### SAS code ``` sas= proc genmod data = <data>; weight count; model <response> = <explanetory> / dist = <dist of response> link = <link function>; run; ``` ### SAS implementation 以下用這個data set來做hd = 1的generalized linear model   ## Count data It is a horseshoe crab data, we want to know that whether the size of a female horseshoe will affect the amount of the male horseshoe arround it  為了看出更明顯的趨勢,可以將連續變數分成離散化  ### Overdispersion 如此便可以很明顯的看出趨勢,然而,在categorical data裡很常會有over dispersioin的問題,在這個data set裡,可以從下表看出來。因為假設count data是poisson distribution,所以平均應該等於變異數,然而  可以發現sample mean << sample variance #### diagonostics <font size = 5.5> $T = \frac{\chi^2}{df}$ 其中$\chi^2$為pearson residual </font> 如果確定有overdispersion的問題,可以在原本poisson的variance多乘上一個scaling factor來調整 另一種調整方式是把distribution假設成negative binomial,因為其平均為$\mu$, 變異數為$\mu + \frac{\mu^2}{k}$,且當$k \rightarrow \infty$時,negative binomial會收斂到poisson ### Index count data 常常會是以一個區或一段時間作為count的基準,但這樣population不同,自然就會影響到count的數量。所以需要一個index來scale,使他們的base line都一樣 <font size = 5.5> 考慮r.v. Y的基準為$t$ $ln\frac{\mu(x)}{t} = \alpha + \beta x$ $ln(\mu(x)) = \alpha + \beta x + lnt$ </font> This is how we adjust count number in terms of the baseline 在程式中只須加上offset = , 即可進行population的scale。稱作位移變數 
×
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