Fits a loglinear model to four binary responses.
loglinb4(order4 = 4, zero = c("u12", "u13", "u14", "u23",
"u24", "u34", if (order4 > 2) c("u123", "u124",
"u134", "u234") else NULL, if (order4 > 3) "u1234"
else NULL), exchangeable = FALSE)An object of class "vglmff"
(see vglmff-class).
The object is used by modelling functions
such as vglm,
rrvglm and vgam.
When fitted,
the fitted.values slot of the object
contains the joint probabilities,
labelled as
\((Y_1,Y_2,Y_3,Y_4)\) = (0,0,0,0), (0,0,0,1), (0,0,1,0), (0,0,1,1), (0,1,0,0), (0,1,0,1), (0,1,1,0), (0,1,1,1), (1,0,0,0), (1,0,0,1), (1,0,1,0), (1,0,1,1), (1,1,0,0), (1,1,0,1), (1,1,1,0), (1,1,1,1), respectively.
Logical.
If TRUE, the four marginal probabilities
are constrained to be equal,
as well as their higher-order interaction terms.
Which linear/additive predictors
are modelled as intercept-only?
A NULL means none.
See CommonVGAMffArguments for
further information.
Logical or either 2 or 3 or 4.
If logical and TRUE then 4, else 3.
It ends up an integer that is either 2 or 3 or 4.
Any higher-order term is 0, e.g.,
u1234 = 0 if order4 = 3.
Yunhao (Harry) Han wrote
@deriv and @weight,
and Thomas Yee wrote the rest.
The full model is
\(P(Y_1=y_1,Y_2=y_2,Y_3=y_3,Y_4=y_4) =\)
$$\exp(u_0+u_1 y_1+u_2 y_2+u_3 y_3+u_4 y_4+
u_{12} y_1 y_2+
u_{13} y_1 y_3+
u_{14} y_1 y_4 +
u_{23} y_2 y_3 +
u_{24} y_2 y_4 +
u_{34} y_3 y_4 +
u_{123} y_1 y_2 y_3 +
u_{124} y_1 y_2 y_4 +
u_{134} y_1 y_3 y_4 +
u_{234} y_2 y_3 y_4 +
u_{1234} y_1 y_2 y_3 y_4)$$
where \(y_1\), \(y_2\) and
\(y_3\) and
\(y_4\) are 0
or 1, and the parameters are \(u_1\),
\(u_2\),
\(u_3\),
\(u_4\),
\(u_{12}\),
\(u_{13}\),
\(u_{14}\),
\(u_{23}\),
\(u_{24}\),
\(u_{34}\), and if
order4 >= 3 then
\(u_{123}\),
\(u_{124}\),
\(u_{134}\),
\(u_{234}\), too, and if
order4 == 4 then
\(u_{1234}\) too.
The normalizing parameter \(u_0\) can
be expressed as a function of the others.
The the parameters are estimated by
identitylink.
Unlike loglinb3,
a fourth-order (full) association parameter,
\(u_{1234}\) for the product
\(y_1 y_2 y_3 y_4\),
is not assumed to be zero for this
family function by default.
Note the default for this argument might change
in the future.
If the data cannot support such a high
order interaction term then reduce order4.
The linear/additive predictors are,
for the full model,
\((\eta_1,\eta_2,\ldots,\eta_{15})^T =
(u_1,u_2,u_3,u_4,u_{12},u_{13},\ldots,u_{1234})^T\).
The ordering agrees with combn
piecemeal.
loglinb3,
loglinb2,
combn,
hunua.
lfit4 <- vglm(cbind(cyadea, beitaw, kniexc, vitluc) ~ altitude,
loglinb4, hunua, trace = TRUE)
coef(lfit4, matrix = TRUE)
head(fitted(lfit4))
head(predict(lfit4))
summary(lfit4, HDEtest = FALSE)
Run the code above in your browser using DataLab