

   FFiitt LLiinneeaarr MMooddeell UUssiinngg GGeenneerraalliizzeedd LLeeaasstt SSqquuaarreess

        gls(model, data, correlation, weights, subset, REML, na.action, control,
            verbose)

   AArrgguummeennttss::

      model: a two-sided linear formula object describing the
             model, with the response on the left of a `~'
             operator and the terms, separated by `+' opera-
             tors, on the right.

       data: an optional data frame containing the variables
             named in `model', `correlation', `weights', and
             `subset'. By default the variables are taken from
             the environment from which `gls' is called.

   correlation: an optional `corStruct' object describing the
             within-group correlation structure. See the docu-
             mentation of `corClasses' for a description of the
             available `corStruct' classes. Defaults to `NULL',
             corresponding to uncorrelated errors.

    weights: an optional `varFunc' object or one-sided formula
             describing the within-group heteroscedasticity
             structure. If given as a formula, it is used as
             the argument to `varFixed', corresponding to fixed
             variance weights. See the documentation on `var-
             Classes' for a description of the available `var-
             Func' classes. Defaults to `NULL', corresponding
             to homocesdatic errors.

     subset: an optional expression saying which subset of the
             rows of `data' should  be  used in the fit. This
             can be a logical vector, or a numeric vector indi-
             cating which observation numbers are to be
             included, or a  character  vector of the row names
             to be included.  All observations are included by
             default.

       REML: a logical value.  If `TRUE' the model is fit by
             maximizing the restricted log-likelihood.  If
             `FALSE' the log-likelihood is maximized.  Defaults
             to `FALSE'.

   na.action: a function that indicates what should happen when
             the data contain `NA's.  The default action
             (`na.fail') causes `gls' to print an error message
             and terminate if there are any incomplete observa-
             tions.

    control: a list of control values for the estimation algo-
             rithm to replace the default values returned by
             the function `glsControl'.  Defaults to an empty
             list.

    verbose: an optional logical value. If `TRUE' information
             on the evolution of the iterative algorithm is
             printed. Default is `FALSE'.

   DDeessccrriippttiioonn::

        This function fits a linear model using generalized
        least squares. The errors are allowed to be correlated
        and/or have unequal variances.

   VVaalluuee::

        an object of class `gls' representing the linear model
        fit. Generic functions such as `print', `plot' and
        `summary' have methods to show the results of the fit.
        See `glsObject' for the components of the fit. The
        functions `resid', `coef', and `fitted'.

   AAuutthhoorr((ss))::

        Jose Pinheiro and Douglas Bates

   RReeffeerreenncceess::

        The different correlation structures available for the
        `correlation' argument are described in Box, G.E.P.,
        Jenkins, G.M., and Reinsel G.C. (1994), Littel, R.C.,
        Milliken, G.A., Stroup, W.W., and Wolfinger, R.D.
        (1997), and Venables, W.N. and Ripley, B.D. (1997). The
        use of variance functions for linear and nonlinear mod-
        els is presented in detail in Carrol, R.J. and Rupert,
        D. (1988) and Davidian, M. and Giltinan, D.M. (1995).

        Box, G.E.P., Jenkins, G.M., and Reinsel G.C. (1994)
        "Time Series Analysis: Forecasting and Control", 3rd
        Edition, Holden-Day.

        Carrol, R.J. and Rupert, D. (1988) "Transformation and
        Weighting in Regression", Chapman and Hall.

        Davidian, M. and Giltinan, D.M. (1995) "Nonlinear Mixed
        Effects Models for Repeated Measurement Data", Chapman
        and Hall.

        Littel, R.C., Milliken, G.A., Stroup, W.W., and Wolfin-
        ger, R.D. (1997) "SAS Systems for Mixed Models", SAS
        Institute.

        Venables, W.N. and Ripley, B.D. (1997) "Modern Applied
        Statistics with S-plus", 2nd Edition, Springer-Verlag.

   SSeeee AAllssoo::

        `glsControl', `glsObject', `corStruct', `varFunc',
        `corClasses', `varClasses'

   EExxaammpplleess::

        library(lme)
        data(Ovary)
        # AR(1) errors within each Mare
        fm1 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary,
                   correlation = corAR1(form = ~ 1 | Mare))
        # variance increases with a power of the absolute fitted values
        fm1 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary,
                   varFunc = varPower())

