The R Project SVN R

Rev

Rev 59039 | Rev 67599 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 59039 Rev 61433
Line 12... Line 12...
12
loglin(table, margin, start = rep(1, length(table)), fit = FALSE,
12
loglin(table, margin, start = rep(1, length(table)), fit = FALSE,
13
       eps = 0.1, iter = 20, param = FALSE, print = TRUE)
13
       eps = 0.1, iter = 20, param = FALSE, print = TRUE)
14
}
14
}
15
\description{
15
\description{
16
  \code{loglin} is used to fit log-linear models to multidimensional
16
  \code{loglin} is used to fit log-linear models to multidimensional
17
  contingency tables by Iterative Proportional Fitting.  
17
  contingency tables by Iterative Proportional Fitting.
18
}
18
}
19
\arguments{
19
\arguments{
20
  \item{table}{a contingency table to be fit, typically the output from
20
  \item{table}{a contingency table to be fit, typically the output from
21
    \code{table}.}
21
    \code{table}.}
22
  \item{margin}{a list of vectors with the marginal totals to be fit.
22
  \item{margin}{a list of vectors with the marginal totals to be fit.
Line 27... Line 27...
27
    \code{list(c(1, 2), c(1, 3))} specifies a model which contains
27
    \code{list(c(1, 2), c(1, 3))} specifies a model which contains
28
    parameters for the grand mean, each factor, and the 1-2 and 1-3
28
    parameters for the grand mean, each factor, and the 1-2 and 1-3
29
    interactions, respectively (but no 2-3 or 1-2-3 interaction), i.e.,
29
    interactions, respectively (but no 2-3 or 1-2-3 interaction), i.e.,
30
    a model where factors 2 and 3 are independent conditional on factor
30
    a model where factors 2 and 3 are independent conditional on factor
31
    1 (sometimes represented as \sQuote{[12][13]}).
31
    1 (sometimes represented as \sQuote{[12][13]}).
32
     
32
 
33
    The names of factors (i.e., \code{names(dimnames(table))}) may be
33
    The names of factors (i.e., \code{names(dimnames(table))}) may be
34
    used rather than numeric indices.
34
    used rather than numeric indices.
35
  }
35
  }
36
  \item{start}{a starting estimate for the fitted table.  This optional
36
  \item{start}{a starting estimate for the fitted table.  This optional
37
    argument is important for incomplete tables with structural zeros
37
    argument is important for incomplete tables with structural zeros
Line 54... Line 54...
54
  \item{pearson}{the Pearson test statistic (X-squared).}
54
  \item{pearson}{the Pearson test statistic (X-squared).}
55
  \item{df}{the degrees of freedom for the fitted model.  There is no
55
  \item{df}{the degrees of freedom for the fitted model.  There is no
56
    adjustment for structural zeros.}
56
    adjustment for structural zeros.}
57
  \item{margin}{list of the margins that were fit.  Basically the same
57
  \item{margin}{list of the margins that were fit.  Basically the same
58
    as the input \code{margin}, but with numbers replaced by names
58
    as the input \code{margin}, but with numbers replaced by names
59
    where possible.} 
59
    where possible.}
60
  \item{fit}{An array like \code{table} containing the fitted values.
60
  \item{fit}{An array like \code{table} containing the fitted values.
61
    Only returned if \code{fit} is \code{TRUE}.}
61
    Only returned if \code{fit} is \code{TRUE}.}
62
  \item{param}{A list containing the estimated parameters of the
62
  \item{param}{A list containing the estimated parameters of the
63
    model.  The \sQuote{standard} constraints of zero marginal sums
63
    model.  The \sQuote{standard} constraints of zero marginal sums
64
    (e.g., zero row and column sums for a two factor parameter) are
64
    (e.g., zero row and column sums for a two factor parameter) are
Line 79... Line 79...
79
 
79
 
80
  Note that the IPF steps are applied to the factors in the order given
80
  Note that the IPF steps are applied to the factors in the order given
81
  in \code{margin}.  Hence if the model is decomposable and the order
81
  in \code{margin}.  Hence if the model is decomposable and the order
82
  given in \code{margin} is a running intersection property ordering
82
  given in \code{margin} is a running intersection property ordering
83
  then IPF will converge in one iteration.
83
  then IPF will converge in one iteration.
84
    
84
 
85
  Package \CRANpkg{MASS} contains \code{loglm}, a front-end to
85
  Package \CRANpkg{MASS} contains \code{loglm}, a front-end to
86
  \code{loglin} which allows the log-linear model to be specified and
86
  \code{loglin} which allows the log-linear model to be specified and
87
  fitted in a formula-based manner similar to that of other fitting
87
  fitted in a formula-based manner similar to that of other fitting
88
  functions such as \code{lm} or \code{glm}.
88
  functions such as \code{lm} or \code{glm}.
89
}
89
}