

loglin {base}                                R Documentation

_F_i_t_t_i_n_g _L_o_g_-_L_i_n_e_a_r _M_o_d_e_l_s

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

     `loglin' is used to fit log-linear models to multidi-
     mensional contingency tables by Iterative Proportional
     Fitting.

_U_s_a_g_e_:

     loglin(table, margin, start = rep(1, length(table)), fit = FALSE,
            eps = 0.1, iter = 20, param = FALSE, print = TRUE)

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

   table: a contingency table to be fit, typically the out-
          put from `table'.

  margin: a list of vectors with the marginal totals to be
          fit.

          (Hierarchical) log-linear models can be specified
          in term of these marginal totals which give the
          ``maximal'' factor subsets contained in the model.
          For example, in a three-factor model, `list(c(1,
          2), c(1, 3))' specifies a model which contains
          parameters for the grand mean, each factor, and
          the 1-2 and 1-3 interactions, respectively (but no
          2-3 or 1-2-3 interaction), i.e., a model where
          factors 2 and 3 are independent conditional on
          factor 1 (sometimes represented as `[12][13]').

          The names of factors (i.e., `names(dim-
          names(table))') may be used rather than numeric
          indices.

   start: a starting estimate for the fitted table.  This
          optional argument is important for incomplete
          tables with structural zeros in `table' which
          should be preserved in the fit.  In this case, the
          corresponding entries in `start' should be zero
          and the others can be taken as one.

     fit: a logical indicating whether the fitted values
          should be returned.

     eps: maximum deviation allowed between observed and
          fitted margins.

    iter: maximum number of iterations.

   param: a logical indicating whether the parameter values
          should be returned.

   print: a logical.  If `TRUE', the number of iterations
          and the final deviation are printed.

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

     The Iterative Proportional Fitting algorithm as pre-
     sented in Haberman (1972) is used for fitting the
     model.  At most `iter' iterations are performed, con-
     vergence is taken to occur when the maximum deviation
     between observed and fitted margins is less than `eps'.
     All internal computations are done in double precision;
     there is no limit on the number of factors (the dimen-
     sion of the table) in the model.

     Assuming that there are no structural zeros, both the
     Likelihood Ratio Test and Pearson test statistics have
     an asymptotic chisquare distribution with `df' degrees
     of freedom.

     Package `MASS' contains `loglm', a front-end to
     `loglin' which allows the log-linear model to be speci-
     fied and fitted in a formula-based manner similar to
     that of other fitting functions such as `lm' or `glm'.

_V_a_l_u_e_:

     A list with the following components.

     lrt: the Likelihood Ratio Test statistic.

 pearson: the Pearson test statistic (X-squared).

      df: the degrees of freedom for the fitted model.
          There is no adjustment for structural zeros.

  margin: list of the margins that were fit.  Basically the
          same as the input `margin', but with numbers
          replaced by names where possible.

     fit: An array like `table' containing the fitted val-
          ues.  Only returned if `fit' is `TRUE'.

   param: A list containing the estimated parameters of the
          model.  The ``standard'' constraints of zero
          marginal sums (e.g., zero row and column sums for
          a two factor parameter) are employed.  Only
          returned if `param' is `TRUE'.

_A_u_t_h_o_r_(_s_)_:

     Kurt Hornik

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

     S. J. Haberman (1972).  Log-linear fit for contingency
     tables-Algorithm AS51.  Applied Statistics, 21,
     218-225.

     Alan Agresti (1990).  Categorical data analysis.  New
     York: Wiley.

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

     `table'

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

     ## Currently no appropriate data sets are available.

