manylm is used to fit multivariate linear models
to high-dimensional data, such as multivariate abundance data in ecology.
This is the base model-fitting function - see plot.manylm for 
assumption checking, and anova.manylm or summary.manylm 
for significance testing.
manylm(
   formula, data=NULL,  subset=NULL, weights=NULL, 
   na.action=options("na.action"),  method="qr", model=FALSE, 
   x=TRUE, y=TRUE, qr=TRUE, singular.ok=TRUE, contrasts=NULL, 
   offset, test="LR" , cor.type= "I", shrink.param=NULL, 
   tol=1.0e-5, …)an object of class "formula" (or one that
    can be coerced to that class): a symbolic description of the
    model to be fitted. The details of model specification are given
    under Details.
an optional data frame, list or environment (or object
    coercible by as.data.frame to a data frame) containing
    the variables in the model.  If not found in data, the
    variables are taken from environment(formula),
    typically the environment from which manylm is called.
an optional vector specifying a subset of observations to be used in the fitting process.
an optional vector of weights to be used in the fitting
    process.  Should be NULL or a numeric vector.
    If non-null, weighted least squares is used with weights
    weights (that is, minimizing sum(weights*e^2)); otherwise
    ordinary least squares is used.
a function which indicates what should happen
    when the data contain NAs.  The default is set by
    the na.action setting of options, and is
    na.fail if that is unset.  The ‘factory-fresh’
    default is na.omit.  Another possible value is
    NULL, no action.  Value na.exclude can be useful.
the method to be used; for fitting, currently only
    method = "qr" is supported; method = "model.frame" returns
    the model frame (the same as with model = TRUE, see below).
logicals.  If TRUE the corresponding
    components of the fit (the model frame, the model matrix, the
    response, the QR decomposition) are returned.
logical. If FALSE (the default in S but
    not in R) a singular fit is an error.
an optional list. See the contrasts.arg
    of model.matrix.default.
this can be used to specify an a priori
    known component to be included in the linear predictor
    during fitting.  This should be NULL or a numeric vector of
    length either one or equal to the number of cases.
    One or more offset terms can be included in the
    formula instead or as well, and if both are specified their sum is
    used.  See model.offset.
choice of test statistic. Can be one of "LR" (default) = likelihood ratio statistic "F" = Lawley-Hotelling trace statistic NULL = no test
This parameter is merely stored in manylm, and will be used as the default value of test in subsequent functions for inference.
structure imposed on the estimated correlation matrix under the fitted model. Can be "I"(default), "shrink", or "R". See anova.manylm for details of its usage. This parameter will be used as the default value of cor.type in subsequent functions for inference.
shrinkage parameter to be used if cor.type="shrink". This parameter will be used as the default value of shrink.param in subsequent functions for inference.
the tolerance used in estimations.
additional arguments to be passed to the low level regression fitting functions (see below).
manylm returns an object of c("manylm", "mlm", "lm") for multivariate
 formula response and of of class c("lm") for univariate response.
A manylm object is a list containing at least the following components:
  
a named matrix of coefficients
the residuals matrix, that is response minus fitted values.
the matrix of the fitted mean values.
the numeric rank of the fitted linear model.
(only for weighted fits) the specified weights.
the residual degrees of freedom.
the hat matrix.
the matrix (t(x)%*%x).
the test argument supplied.
the cor.type argument supplied.
the resample argument supplied.
the nBoot argument supplied.
the matched call.
the terms object used.
(only where relevant) a record of the levels of the factors used in fitting.
if requested (the default), the model frame used.
the offset used (missing if none were used).
if requested, the response matrix used.
if requested, the model matrix used.
In addition, non-null fits will have components assign and (unless not requested) qr relating to the linear fit, for use by extractor functions such as summary.manylm.
Models for manylm are specified symbolically. For details on this 
  compare the details section of lm and formula. If the formula 
  includes an offset, this is evaluated and subtracted from the 
  response.   
  See model.matrix for some further details. The terms in
  the formula will be re-ordered so that main effects come first,
  followed by the interactions, all second-order, all third-order and so
  on: to avoid this pass a terms object as the formula (see
  aov and demo(glm.vr) for an example). 
  A formula has an implied intercept term.  To remove this use either
  y ~ x - 1 or y ~ 0 + x.  See formula for
  more details of allowed formulae. 
  manylm calls the lower level function manylm.fit 
  or manylm.wfit for the actual numerical computations. 
  For programming only, you may consider doing likewise. 
  All of weights, subset and offset are evaluated
  in the same way as variables in formula, that is first in
  data and then in the environment of formula.
  For details on arguments related to hypothesis testing (such as cor.type
  and resample) see summary.manylm or
  anova.manylm.
# NOT RUN {
data(spider)
spiddat <- log(spider$abund+1)
lm.spider <- manylm(spiddat~.,data=spider$x)
lm.spider
#Then use the plot function for diagnostic plots, and use anova or summary to
#evaluate significance of different model terms.
# }
Run the code above in your browser using DataLab