View source: R/family.loglin.R
| loglinb4 | R Documentation |
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)
exchangeable |
Logical.
If |
zero |
Which linear/additive predictors
are modelled as intercept-only?
A |
order4 |
Logical or either 2 or 3 or 4.
If logical and |
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.
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.
The response must be a 4-column matrix
of ones and zeros only.
By default, each of the 16 combinations of
the multivariate
response need to appear in the data set,
therefore data sets will usually
need to be large in order for this
family function to work most simply.
As stated above, reduce order4
if there are problems.
After estimation, the response attached
to the object is also
a 4-column matrix; possibly in the future
it might change into
a 16-column matrix.
Yunhao (Harry) Han wrote
@deriv and @weight,
and Thomas Yee wrote the rest.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.