13Mixed‐Effect Models
13.1 Regression with categorical covariates
Up to this point, we have treated all categorical explanatory variables in regression models by defining dummy variables to represent the levels of the variable. Effectively, this partitions the data into groups with observations within a group in some sense more similar than those from different groups. This has worked well so far for our examples, allowing us to take account of such explanatory variables with little fuss.
Let us delve into this idea a bit further because, as we'll see, this isn't the only way of incorporating information about categorical explanatory variables. Indeed, in some instances, this method would be downright silly as we'll now show.
Let us first consider a simple example where we have a regression model with a categorical covariate, sex, which has two levels: male and female. For any individual that we find, the knowledge that it is, say, female conveys a great deal of information about the individual, and this information draws on experience gleaned from many other individuals that were female. A female will have a whole set of attributes (associated with her being female) no matter what population that individual was drawn from.
Now, take a different example where we are looking at the effect of adding fertiliser (, a binary variable) on crop yield (), where the experiment was conducted ...
Get The R Book, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.