loglinb2                package:VGAM                R Documentation

_L_o_g_l_i_n_e_a_r _M_o_d_e_l _f_o_r _T_w_o _B_i_n_a_r_y _R_e_s_p_o_n_s_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Fits a loglinear model to two binary responses.

_U_s_a_g_e:

     loglinb2(exchangeable = FALSE, zero = NULL)

_A_r_g_u_m_e_n_t_s:

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 predictor is modelled as an intercept
          only? A 'NULL' means none of them. 

_D_e_t_a_i_l_s:

     The model is

         P(Y1=y1,Y2=y2) = exp(u0 + u1*y1 + u2*y2 + u12*y1*y2)

     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)].

_V_a_l_u_e:

     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.

_N_o_t_e:

     The response must be a two-column matrix of ones and zeros only.
     This is more restrictive than 'binom2.or', which can handle more
     types of input formats.

_A_u_t_h_o_r(_s):

     Thomas W. Yee

_R_e_f_e_r_e_n_c_e_s:

     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.

     Documentation accompanying the 'VGAM' package at <URL:
     http://www.stat.auckland.ac.nz/~yee> contains further information
     and examples.

_S_e_e _A_l_s_o:

     'binom2.or', 'binom2.rho', 'loglinb3'.

_E_x_a_m_p_l_e_s:

     data(coalminers)
     coalminers = transform(coalminers, age=(age-42)/5)

     # Get the n x 4 matrix of counts 
     temp = vglm(cbind(nBnW,nBW,BnW,BW) ~ age, binom2.or, coalminers)
     counts = round(c(weights(temp, type="prior")) * temp@y)

     # Create a n x 2 matrix response for loglinb2()
     fred = matrix(c(0,0, 0,1, 1,0, 1,1), 4, 2, byrow=TRUE)
     yy = kronecker(matrix(1, nrow(counts), 1), fred)
     wt = c(t(counts))
     age = rep(coalminers$age, rep(4, length(coalminers$age)))
     yy = yy[wt>0,]
     age = age[wt>0]
     wt = wt[wt>0]

     fit = vglm(yy ~ age, loglinb2, trace=TRUE, wei=wt)
     coef(fit, mat=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 

