Chapter 7 Contrast coding for designs with two predictor variables

library(knitr)
library(kableExtra)
library(tidyverse)
library(brms)
## Lade nötiges Paket: Rcpp
## Loading 'brms' package (version 2.17.0). Useful instructions
## can be found by typing help('brms'). A more detailed introduction
## to the package is available through vignette('brms_overview').
## 
## Attache Paket: 'brms'
## Das folgende Objekt ist maskiert 'package:lme4':
## 
##     ngrps
## Die folgenden Objekte sind maskiert von 'package:extraDistr':
## 
##     ddirichlet, dfrechet, pfrechet, qfrechet,
##     rdirichlet, rfrechet
## Das folgende Objekt ist maskiert 'package:stats':
## 
##     ar
library(bcogsci)
library(papaja)
## Lade nötiges Paket: tinylabels
## 
## Attache Paket: 'papaja'
## Das folgende Objekt ist maskiert durch '.GlobalEnv':
## 
##     ci
library(MASS)
library(hypr)
library(bcogsci)

Chapter 6 provides a basic introduction into contrast coding in situations where there is one predictor variable, i.e., one factor, which can be tested using one specified contrast matrix. Here, we will investigate how contrast coding generalizes to situations where there is more than one predictor variables. This could either be a situation where two factors are present or where one factor is paired with a continuous predictor variables, i.e., a covariate. We first discuss contrast coding for the case of two factors (for \(2 \times 2\) designs; see section 7.1) and then go on to investigate situations where one predictor is a factor and the other predictor is a continuous covariate (see section 7.2). Moreover, one problem in the analysis of interactions occurs in situations where the model is not linear, but has some non-linear link function, such as e.g., in logistic models or when assuming a log-normally distributed dependent variable. In these situations, the model makes predictions for each condition (i.e., design cell) at the latent level of the linear model. However, sometimes it is important to translate these model predictions to the level of the observations (e.g., to probabilities in a logistic regression model). We will discuss how this can be implemented in section 7.3. Now, we first start by treating contrast coding in a factorial 2 x 2 design.