Beruflich Dokumente
Kultur Dokumente
Loglinear models treat all variables the same, no response - explanatory distinction. When there is one response and
one or more explanatory variables, the logit model is more natural.
Loglinear models model the cell counts, the nij. It assumes a Poisson distribution and uses a log link in the general
linear model framework. Even though it assumes a Poisson distribution, it can be used for all types of sampling
( multinomial and independent multinomial as well ).
ln( ij ) = + i + j + ij
X Y XY
and this is called the loglinear model.
It is the interaction term that describes the relationship between X and Y. The main effect terms ( in this case the
iX and Yj ) will always be in the models along with the intercept term.
In order to uniquely estimate the parameters we need to set constraints. The constraints are not unique but the fit of
various models is unique regardless of the constraints. R again uses indicator variables and sets the first level of all
parameters ( numerically or alphabetically ) equal to 0, i.e., anything with a 1 in its subscript will be set to 0.
1 1
iX I I1
Yj J J1
ijXY IJ (I 1)(J 1)
IJ
This model is called the saturated model because we have I J independent parameters to estimate and I J nij to use
to estimate them. We can estimate everything in the model but then we have no degrees of freedom left over to test
any hypotheses. We have no measure of error since ij = nij .
ni n j
ln( ij ) = + i + j ij =
X Y
Independence Model:
n
Example - Loglinear Model for 2 x 2 Tables
In a study in France, 139 people were given regular doses of Vitamin C over a period of time and another 140
people were given a placebo. At the end of the time period, each person was classified as to whether or not they had a
cold during the period. The results are given below with the expected values for the independence model given in
parentheses.
Cold
No Yes
Placebo 109 (115.91) 31 (24.09) 140
Vitamin C 122 (115.09) 17 (23.91) 139
231 48 279
> cbind(treat,cold,fitted(data.ind))
treat cold
1 "placebo" "no" "115.913978494624"
2 "placebo" "yes" "24.0860215053783"
3 "vitC" "no" "115.086021505376"
4 "vitC" "yes" "23.9139784946256"
> cbind(manfact,size,fitted(cars.ind))
manfact size
1 "A" "small" "140.833"
2 "A" "intermed" "135.036"
3 "A" "large" "65.1309999999999"
4 "B" "small" "79.2959999999999"
5 "B" "intermed" "76.032"
6 "B" "large" "36.672"
7 "C" "small" "158.179"
8 "C" "intermed" "151.668"
9 "C" "large" "73.1529999999999"
10 "D" "small" "34.692"
11 "D" "intermed" "33.264"
12 "D" "large" "16.044"