Generalized Least Squares

Generalized least squares models are regression (or ANOVA) models in which the residuals have a nonstandard covariance structure. Like simple least squares regression, generalized least squares regression uses the method of least squares to fit a continuous, univariate response as a linear function of several predictor variables, but in this case the errors are allowed to be correlated and/or to have unequal variances. Any model that can be fitted by the S-PLUS function lm, including polynomials, multiple predictors and interaction terms, can be fitted using this dialog.

If the predictors affect the response in a nonlinear way, the Nonlinear Generalized Least Squares selection may be appropriate.

Choose Statistics __image\arrow5.gif Generalized Least Squares __image\arrow5.gif Linear. The dialog shown below appears.

Model page

__image\gls1.gif

In the Generalized Least Squares dialog, the Model page has the following options:

Data

Data Set

Select a data set from the dropdown list or type the name of a data set. You can also type into the Data Set edit field any expression that evaluates to a data set.

Subset Rows

Enter an S-PLUS expression that identifies the rows to use in the analysis. To use all the rows in the data set, leave this field blank.

Omit Rows with Missing Values

Select this box to omit from the analysis any rows in the data set that contain missing values for any of the variables in the model.

Variables

Dependent Variables

Select a variable as the dependent variable in the formula. The variable name will appear in the formula field below, followed by a '~'.

Independent Variables

Select one or more variables as the independent variables, or predictor, in the formula. To select more than one variable, Ctrl-click the variables.

Formula

In the Formula field, enter a formula specifying the desired model. In its simplest form a formula consists of the response variable, a tilde (~), and a list of predictor variables separated by "+"s. An intercept is automatically included by default.

Create Formula

Click the Create Formula button to open a formula builder dialog used to construct a formula specifying the desired model. See the online Help section Building Formulas for more information.

Save Model Object

In the Save As field, enter the name for the object in which to save the results of the analysis. If an object with this name already exists, its contents are overwritten. The model object can be used in later functions such as plotting.

Options page

__image\gls2.gif

In the Generalized Least Squares dialog, the Options page has the following options:

Variance Structure

Variance Structure

The variance functions are used to model heteroscedasticity in the within-group error.

Optimization Options

Method Choose the fitting method. REML (the default) fits by maximizing the restricted log-likelihood. ML maximizes the log-likelihood.

Control Enter a list of control values for the estimation algorithm to replace the default values returned by the function lmeControl. Defaults to an empty list.

Correlation Structure

Correlation Structure

Results page

__image\gls3.gif

In the Generalized Least Squares dialog, the Results page has the following options:

Printed Results

Short Output for Generalized Least Squares Regression

Display a short summary of the model fit. This includes the model formula, the regression coefficients, the residual standard error and the degrees of freedom.

Long Output for Generalized Least Squares Regression

Display a detailed summary of the model fit. This includes the model formula, the regression coefficients and their standard errors, t-statistics, and p-values, the residual standard error, the degrees of freedom, the correlation coefficients, and standardized residuals.

ANOVA Table

Display an analysis of variance table. The sums-of-squares in the table are for the terms added sequentially (Type I sums-of-squares).

Confidence Intervals

Select this to print the confidence intervals.

Saved Results

Save In

Enter the name of a data set in which a part of the analysis, such as fitted values and residuals, predictions, confidence intervals, or standard errors, is saved.

Fitted Values

Save the fitted values from the model in the object specified in Save In.

Pearson Residuals

Select to save the Pearson residuals. They are a rescaled version of the working residuals. Their sums-of-squares is the chi-squared statistic.

Normalized Residuals

Select this to save the normalized residuals.

Response Residuals

Select to save the response residuals. These are the ordinary residuals (the response minus the fitted value).

Plot page

__image\gls4.gif

In the Generalized Least Squares dialog, the Plot page has the following options:

Plots

Residuals vs Fit

Select this to display a plot of the residuals versus the fitted values.

Sqrt Abs Residuals vs Fit

Display a plot of the square root of the absolute values of the residuals versus the fitted values. This plot is useful for checking for the constant variance assumption of the model.

Response vs Fit

Display a plot of the response variable versus the fitted values. The line y = x is also drawn on the graph.

Residuals Normal QQ

Display a normal quantile-quantile plot of the residuals.

Augmented Predictions

Select this to obtain a plot of predictions versus the primary covariate, with a different panel for each value of the grouping factor.

Autocorrelation of Residuals

Select this to plot the empirical autocorrelation function for the within-group residuals from the mixed-effects model fitted.

Variogram of Residuals

Select this to plot the semi-variogram for the within-group residuals.

Specified Formula

Select this to activate the formula field thereby adding considerable flexibility to the type of plot obtained from the linear mixed-effects object.

Specified Formula Options

The formula gives considerable flexibility in the type of plot specification. A conditioning expression (on the right side of a | operator) always implies that different panels are used for each group.

General Options

Group Variables A panel will be produced for each level of the variable selected here.

Include Grid Select this if you want a grid to be added to the plot.

Augmented Prediction Options

Primary Covariate Covariate to be used to generate the augmented predictions. By default, if a covariate can be extracted from the data used to generate object it will be used as primary.

Minimum lower limit for the primary covariate. Defaults to min(primary)

Maximum upper limit for the primary covariate. Defaults to max(primary)

Number of Values the number of primary covariate values at which to evaluate the predictions. Defaults to 51.

Variogram Options

The semi-variogram for the within-group residuals from an linear mixed effects model fit is calculated for pairs of residuals within the same group.

Formula Choose a variable to be used for calculating the distances between residual pairs, preceded by a "~". For example, enter "~ Time" to specify a formula for the covariate Time.

Predict page

__image\gls5.gif

In the Generalized Least Squares dialog, the Predict page has the following options:

Standard Predictions

Save Predictions

Select this to save the standard predictions.

Save In

Enter the name of a data set in which a part of the analysis, such as fitted values and residuals, predictions, confidence intervals, or standard errors, is saved. If an object with the name you enter does not already exist (in database 1), then it is created

New Data

Enter the name of a matrix or data set to use for computing predictions. It must contain the same names as the terms in the right side of the formula for the model. If omitted, the original data are used for computing predictions.

Augmented Predictions

Save Augmented Predictions

Select this to save the augmented predictions.

Save In

Enter the name of a data set in which a part of the analysis, such as fitted values and residuals, predictions, confidence intervals, or standard errors, is saved. If an object with the name you enter does not already exist (in database 1), then it is created

Primary Covariate

Choose a covariate to be used to generate the augmented predictions. By default, if a covariate can be extracted from the data used to generate the object, it will be used as primary.

Minimum

Enter a lower limit for the primary covariate. Defaults to min(primary).

Maximum

Enter an upper limit for the primary covariate. Defaults to max(primary).

Number of Values

Enter the number of primary covariate values at which to evaluate the predictions. Defaults to 51.

S-Plus language functions related to Generalized Linear Least Squares Regression

gls, glsContol, glsObject, corStruct, varFunc, corClasses, varClasses