Nested data is data for which a variable (or set of variables) signifies an observation as belonging to a group. We might refer to simple nesting (with 1 layer of groups) as categorical. Use of categorical data with linear models is called ANOVA. [i](Analysis of Variance)[/i]
To illustrate, let’s start with the linear model in matrix notation.
- is the vector of dependent observations.
- is the detailing the observed values of independent variables. The first column is the mean or independent variable intercept.
- describes the parameters of the model. It is a vector of coefficients, meant to be multiplied against to get the vector of predicted values, .
- is the vector of random errors. We assume that .
Classical Effects Model with One Way ANOVA
I had said before that use of categorical variables within the linear regression framework can be termed as ANOVA. Let’s look at how that works. Suppose we have a categorical variable, which defines what group an observation is in. Also suppose that variable can take one of 4 possible levels, signifying 4 possible groups. Within each group, we have 2 observations.
Membership within each group is signified by a dummy variable, taking on the values of either 0 or 1. Because we are treating the model parameters as fixed but unknown, we call the Classical Effects model a Fixed Effects Model.
- is the coefficient associated with group .
- is the per-observation error associated with group , individual .
This method of defining the variable presents a problem, though. When we attempt to take the affine transformation and solve the standard regression problem, we must take the inverse of the matrix . Using the above matrix, the Affine transformation is singular, and thus not invertible.
The solution is in realizing that in order to know what of 4 groups an observation belongs to, we only need 3 dummy variables. If we treat one group as control, and all other groups as deviations from that control, we can accomplish the task.
Thus, we interpret as deviation from the control group. The matrix is now invertible, and thus we can solve for ‘s 2,3,4 as a deviation from .
An alternate, though less used parameterization would be to remove the intercept and have individual intercepts per group.
This parameterization is called the Means Model. The weakness of this parameterization is we are given no information about the significance of differences between any particular group and the control group, though it does allow simple interpretation of the means of the various groups.
Two Way ANOVA
Dimensions of ANOVA are defined by the way in which the categories are stacked. One Way ANOVA refers to a single layer of groups. Two Way ANOVA refers to two layers, nesting sets of groups within groups.
As an example, let’s think of students in a classroom. Each individual student is an observation. These observations are correlated by the fact they belong to the same class. At this level, they are uncorrelated to students in other classes. We identify individual observations with the subscript notation , denoting the ‘th group and ‘th observation within that group.
Let’s say a school has 5 classrooms, with 30 kids per class. In this case, we can make comparitive statements between classrooms using One-Way ANOVA. If we decided to include other schools, and wanted to make comparitive statements between schools, then we would need to nest the groups of classrooms per school within each school. This adds another layer, and we now call this [i]Two Way ANOVA[/i]. We identify individual observations using the subscript , denoting the ‘th top level group, the ‘th nested group, and the ‘th observation within that group.
This idea of nesting can be extended ad-infinitum.