loglin(table, margin, start=<<see below>>, fit=F, eps=0.1, iter=20, param=F, print=T)
The margins to be fit describe the model, similar to describing an ANOVA model. A high-order term automatically includes all the lower-order terms within it; e.g., the term c(1,3) includes the one-factor terms 1 and 3. A factor that had constraints in the sampling plan should always be included. For example, if the sampling plan was such that there would be (precisely) x females and y males sampled, then gender should be in all models.
Both the LRT and the Pearson test statistics are asymptotically distributed chisquare with df degrees of freedom (assuming there are no zeros). A general rule of thumb is that the asymptotic distribution is trustworthy when the number of observations is 10 times the number of cells. If the two test statistics differ considerably, not much faith can be put in the test. Using the test statistics to select a model is a rather backwards use of hypothesis testing - a model can be "proved" wrong, but passing the test doesn't mean that the model is right. Bayesian techniques have been developed to select a good model (or models).
The start argument can be used to produce analyses when the cells are assigned different weights, see Clogg and Eliason (1988). The start should be one over the weights.
A suggested analysis strategy is to use the default settings to narrow down the number of models, and then to set the fit and param options to TRUE in order to investigate the more promising models further.
Fienberg, S. E. (1980). The Analysis of Cross-Classified Categorical Data (2nd edition). Cambridge, Mass.: MIT Press.
Haberman, S. J. (1972). Log-linear fit for contingency tables-Algorithm AS51. Applied Statistics 21, 218-225.
Lunneborg, C. E. and Abbott, R. D. (1983). Elementary Multivariate Analysis for the Behavioral Sciences. New York: North-Holland.
loglin(barley.exposed, list("cultivar", "time", "cluster")) # model of independenceloglin(barley.exposed, list(1:2, c(1, 3))) # factors 2 and 3 are independent conditional on factor 1
bar.ci1 <- loglin(barley.exposed, list(1:2, c(1, 3)), param=T, fit=T) # return parameter values and the fit (barley.exposed - bar.ci1$fit)/sqrt(bar.ci1$fit) # scaled residuals