Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


VGAM (version 1.0-6)

loglinb2: Loglinear Model for Two Binary Responses

Description

Fits a loglinear model to two binary responses.

Usage

loglinb2(exchangeable = FALSE, zero = "u12")

Arguments

exchangeable

Logical. If TRUE, the two marginal probabilities are constrained to be equal. Should be set TRUE for ears, eyes, etc. data.

zero

Which linear/additive predictors are modelled as intercept-only? A NULL means none of them. See CommonVGAMffArguments for more information.

Value

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 four joint probabilities, labelled as (Y1,Y2) = (0,0), (0,1), (1,0), (1,1), respectively.

Details

The model is P(Y1=y1,Y2=y2)=exp(u0+u1y1+u2y2+u12y1y2) where y1 and y2 are 0 or 1, and the parameters are u1, u2, u12. The normalizing parameter u0 can be expressed as a function of the other parameters, viz., u0=log[1+exp(u1)+exp(u2)+exp(u1+u2+u12)]. The linear/additive predictors are (η1,η2,η3)T=(u1,u2,u12)T.

References

Yee, T. W. and Wild, C. J. (2001) Discussion to: ``Smoothing spline ANOVA for multivariate Bernoulli observations, with application to ophthalmology data (with discussion)'' by Gao, F., Wahba, G., Klein, R., Klein, B. Journal of the American Statistical Association, 96, 127--160.

McCullagh, P. and Nelder, J. A. (1989) Generalized Linear Models, 2nd ed. London: Chapman & Hall.

See Also

binom2.or, binom2.rho, loglinb3.

Examples

Run this code
# NOT RUN {
coalminers <- transform(coalminers, Age = (age - 42) / 5)
# Get the n x 4 matrix of counts
fit0 <- vglm(cbind(nBnW,nBW,BnW,BW) ~ Age, binom2.or, data = coalminers)
counts <- round(c(weights(fit0, type = "prior")) * depvar(fit0))
# Create a n x 2 matrix response for loglinb2()
# bwmat <- matrix(c(0,0, 0,1, 1,0, 1,1), 4, 2, byrow = TRUE)
bwmat <- cbind(bln = c(0,0,1,1), wheeze = c(0,1,0,1))
matof1 <- matrix(1, nrow(counts), 1)
newminers <- data.frame(bln    = kronecker(matof1, bwmat[, 1]),
                        wheeze = kronecker(matof1, bwmat[, 2]),
                        wt     = c(t(counts)),
                        Age    = with(coalminers, rep(age, rep(4, length(age)))))
newminers <- newminers[with(newminers, wt) > 0,]

fit <- vglm(cbind(bln,wheeze) ~ Age, loglinb2(zero = NULL),
            weight = wt, data = newminers)
coef(fit, matrix = TRUE)  # Same! (at least for the log odds-ratio)
summary(fit)

# Try reconcile this with McCullagh and Nelder (1989), p.234
(0.166-0.131) / 0.027458   # 1.275 is approximately 1.25
# }

Run the code above in your browser using DataLab