Download - personal.rdg.ac.uk

Transcript
16.3
Model comparison and selection
We need a formal way of deciding if the 3 intercepts are different but the 3 slopes are not. We
do this by comparing competing models using the linear model framework as:
Data = pattern + residual
Here pattern (structure) represents the systematic component of the model. It includes terms
that may potentially explain variability in the data (the key response of interest). The residual
includes the random, unexplained component of variability.
The description of the model as linear does not necessarily mean a straight line, but that the
terms are included into the pattern one after the other, i.e. terms are additive. In the pattern part
of the statistical model here we consider 2 terms for inclusion: fertiliser and variety. In
increasing level of complexity:
•
•
•
just fertiliser in the model represents a single common straight line for all 3 varieties,
adding variety makes a set of 3 parallel straight lines and
adding the interaction of fertiliser by variety allows the slopes to change, so making a
set of 3 separate straight lines.
The mixing of numeric and categorical variables is achieved by using a linear model. The
rationale for comparing models is to select the model giving the simplest, yet adequate
summary of the observed data. Ideally the simplest model here is a single regression line, as it
has only fertiliser in the pattern.
In Stata we first make a copy of the variety categorical variable as a new numeric variable
named varietyn with:
. encode variety, generate(varietyn)
. codebook varietyn
The codebook command reveals that the numerical values created for varietyn have
inherited the value labels of the original string variable, so 1=NEW, 2=OLD, 3=TRAD. This
extra step is necessary to obtain the breakdown of the ANOVA table into a hierarchical order of
the competing models.
Now fit all terms into the model by:
. anova yield fertiliser varietyn fertiliser*varietyn, category(varietyn) sequential
This gives the output shown in Fig. 16.3.
Note:
(a) In our previous use of the anova command (see section 12.3 in chapter 12), we used the
option continuous(<varname>) to indicate a continuous variable in the model. Here we do the
opposite with category(<varname>) to indicate categorical variables. If neither is used, all
terms in the model are assumed to be categorical.
(b) The option sequential fits terms one by one so that each term is adjusted for the preceding
terms.
51