!!!sum contrasts (deviation coding) {{outline}} ---- *reference level は 0 *その要因の「平均」を意味する !!options() * Rの各種オプションを設定するコマンド * contrastsの設定がどうなっているかを確認する {{pre options()$contrasts unordered ordered "contr.treatment" "contr.poly" }} * contrastsのオプションは、unorderedとorderedの二種類ある * このオプションを変えてしまうこともできるが、変えてしまうと、その後もその設定がデフォルトになってしまうので、普通のデフォルトにまた戻さないと、困ったことになる。 contrasts(flevels) <- NULL * モデル式のオプションとして、指定する場合は、その場合だけそのオプションになるので、安全 ! contr.sum * 以下の「Understanding Sum Contrasts for Regression Models: A Demonstration」の例 lm(RT~Gender*Strategy, data = df, contrasts = list(Gender = "contr.sum", Strategy = "contr.sum")) * 多重共線性を避けるため、原則、最後のレベルを投入しない。省略する。 ** omitオプションを使うと省略するレベルを明示的に指定できる。 omit= "除くもの" !!References * [Understanding Sum Contrasts for Regression Models: A Demonstration|https://rpubs.com/monajhzhu/608609] * https://www.rcps.jp/doku.php?id=%E3%83%A1%E3%83%A2:%E3%83%9E%E3%83%AB%E3%83%81%E3%83%AC%E3%83%99%E3%83%AB%E3%83%A2%E3%83%87%E3%83%AB:%E4%B8%80%E8%88%AC%E7%B7%9A%E5%BD%A2%E3%83%A2%E3%83%87%E3%83%AB * https://stats.oarc.ucla.edu/r/library/r-library-contrast-coding-systems-for-categorical-variables/#DEVIATION * https://cran.r-project.org/web/packages/faux/vignettes/contrasts.html !Brehm and Alday (2022) Contrast coding in a decade of mixed models Journal of Memory and Language 125: 1-13 * カテゴリー変数を使う場合は、どのコントラストを使ったかを明示的に書くこと。 * デフォルトのtreatment codingの場合もその旨書くこと。 ** 例:"Factor A (magenta, green) was treatment coded or the three levels of Factor B, coffee, tea, and cocoa, were coded with two contrasts: (.25,.25, -.5) and (.5, -.5.0)" * そのうえで、何と何を対比して比較したかをわかりやすく言い換えて説明すること。 ** 例1:"The model intercept therefore reflects the reference level of factor A, magenta ** 例2:"The first contrast tests caffeinated versus non-caffienated beverages, and the second tests coffee versus tea"