Next: macintosh Up: MacAnova Help File Previous: logic   Contents

logistic()

Usage:
logistic([Model],n:Denom [, incr:T, offsets:vec, print:F or silent:T,\
  pvals:T, maxiter:m, epsilon:eps, coefs:F, problimit:smallVal]), Denom
  REAL scalar or vector > 0, vec a REAL vector, m an integer > 0, eps
  and smallVal small REAL scalars > 0.



Keywords: glm, regression, categorical data
logistic(Model,n:Denom) computes a logistic regression fit of the model
specified in the CHARACTER variable Model.  If y is the response
variable in the model it must consist of integers y[i] >= 0.  Denom must
either be an integer scalar >= max(y) or a REAL vector of the same
length as y with Denom[i] >= y[i].  Estimation is by maximum likelihood
on the assumption that y[i] is binomial with Denom[i] trials (Denom
trials for scalar DENOM).

If either Denom or y contains non-integer values a warning message is
printed.

See topic 'models' for information on specifying Model.

logistic() sets the side effect variables RESIDUALS, WTDRESIDUALS, SS,
DF, HII, DEPVNAME, TERMNAMES, and STRMODEL.  See topic 'glm'.  Without
keyword phrase 'inc:T' (see below), TERMNAMES has value vector("","",
...,"Overall model","ERROR1"), DF has value vector(0,0,...,ModelDF,
ErrorDF) and SS has value vector(0,0,...,ModelDeviance,ErrorDeviance).

If, say, Model is "y=x1+x2", an iterative algorithm is used to predict
logit(E[y/Denom]) as a linear function of x1 and x2, where logit(p) =
log(p/(1-p)).  A two line Analysis of Deviance table is printed.

Line 1 is the difference 2*L(1) - 2*L(0), where L(0) is the log
likelihood for a model with all coefficients 0 and L(1) is the maximized
log likelihood for the model fit.

Line 2 is 2*L(2) - 2*L(1) where L(2) is the maximized log likelihood
under a model fitting one parameter for every y[i].  Under certain
conditions, the latter can be used to test the goodness of fit of the
model using a chi-squared test.

logistic(Model,n:Denom,inc:T) computes the full logistic model and all
partial models -- only a constant term, the constant and the first term,
and so on.  It prints an Analysis of Deviance table, with one line for
each term, representing a difference 2*L(i) - 2*L(i-1) where L(i) is the
maximumized log likely for a model including terms 1 through i, plus the
deviance of the complete model labeled as "ERROR1".  Each line except
the last can be used in a chi-squared test to test the significance of
the term on the assumption that the true model includes no later terms.

If you omit Model (logistic(,n:Denom ...)), the model from the most
recent GLM command such as poisson() or anova(), or the model in
CHARACTER variable STRMODEL is used.

Computations are carried out using iteratively reweighted least squares.

logistic(Model,n:Denom,...) is equivalent to glmfit(Model,n:Denom,
dist:"binomial", link:"logit",...).

If you get a warning message similar to the following
   WARNING: problimit = 1e-08 was hit by logistic() at least once
it usually indicates either the presence of an extreme outlier or a best
fitting model in which many of the probabilities are almost exactly 0 or
1.  The latter case may not represent any problem, since the fitted
probabilities at these points will be 1e-8 or 1 - e-8.  You can try
reducing the threshold using keyword 'problimit' (see below), but you
will probably just get the message again.

                     Other keyword phrases
Keyword phrase  Default  Meaning
  maxiter:m       50     Positive integer m is the maximum number of
                         iterations that will be allowed in fitting

  epsilon:eps    1e-6    Small positive REAL specifying relative error
                         in objective function (2*log likelihood)
                         required to end iteration

  problimit:small 1e-8   Iteration is restricted so that no fitted
                         probabilities are < small or > 1 - small. Value
                         of small must be between 1e-15 and 0.0001.

  offsets:OffVec none    Causes model to be fit to logit(p) to be
                         1*Offvec+Model, where OffVec is a REAL vector
                         the same length as response y.  Note OffVec is
                         in logit units.  See topic 'glm_keys' for more
                         details.

  pvals:T or F      F    Nominal chi-squared P-values will be printed
                         for each deviance.  The default value can be
                         changed by setoptions(pvals:T).  See topics
                         setoptions(), 'options'.

See topic 'glm_keys' for information on keyword phrases print:F,
silent:T, coefs:F

Examples of the use of 'offsets'.

  Cmd> logistic("y=x", n:15, offsets:3*x, inc:T, pvals:T)
The P value associated with x can be used to test the hypothesis H0:
beta1 = 3 in the model log(p/(1-p)) = beta0 + beta1*x.

  Cmd> logistic("y=1", n:20, offsets:rep(log(.25/(1-.25)),length(y)),\
       inc:T, pvals:T)
The P value associated with the CONSTANT term can be used to test H0: p
= .25, assuming y contains a random sample from a binomial distribution
with n = 20.


Gary Oehlert 2003-01-15