# gls

##### Fit Linear Model Using Generalized Least Squares

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

- Keywords
- models

##### Usage

```
gls(model, data, correlation, weights, subset, method, na.action,
control, verbose)
## S3 method for class 'gls':
update(object, model., \dots, evaluate = TRUE)
```

##### Value

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`

can be used to extract
some of its components.

##### References

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. (1996), and Venables, W.N. and Ripley,
B.D. (1997). The use of variance functions for linear
and nonlinear models is presented in detail in Carroll, R.J. and Ruppert,
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.

Carroll, R.J. and Ruppert, 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 Wolfinger, R.D. (1996) "SAS Systems for Mixed Models", SAS Institute.

Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer, esp. pp. 100, 461.

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

##### See Also

`corClasses`

,
`glsControl`

,
`glsObject`

,
`glsStruct`

,
`plot.gls`

,
`predict.gls`

,
`qqnorm.gls`

,
`residuals.gls`

,
`summary.gls`

,
`varClasses`

,
`varFunc`

##### Examples

```
# 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 as a power of the absolute fitted values
fm2 <- update(fm1, weights = varPower())
```

*Documentation reproduced from package nlme, version 3.1-86, License: GPL (>=2)*