Mixed-effects models provide a powerful and flexible tool for analyzing grouped data, that is, data that can be classified according to one or more grouping variables. Mixed-effects models incorporate both fixed and random effects:
Fixed effects are parameters associated with an entire population, or with repeatable levels of experimental factors.
Random effects are instead associated with experimental units drawn at random from a population.
Such models typically describe relationships between a response variable and some covariates in data grouped according to one or more classification factors. Common applications are longitudinal data, repeated measures data, multilevel data, and block designs. Mixed-effects models flexibly represent the covariance structure induced by the grouping of the data by associating common random effects to observations sharing the same level of a classification factor.
The parameters in a Mixed-Effects model are the fixed effects coefficients, the variance-covariance matrix of the random effects, plus the variance of the noise term. These parameters are estimated by maximum likelihood (ML) or by restricted maximum likelihood (REML). Best Linear Unbiased Predictors of the random effects are also estimated.
The Fixed-Effects part of the Linear Mixed Effects model assumes that the response is obtained by taking a specific linear combination of the predictors. If the predictors affect the response in a nonlinear way, the Nonlinear Mixed-Effects dialog may be appropriate.
The within-group errors have a Gaussian (normal) distribution and are allowed to be correlated and/or to have unequal variances.
The Compare Models dialog can be used to compare two Linear Mixed Effects Models fitted using this dialog.
Choose Statistics Mixed Effects
Linear. The dialog shown below appears.
Model page
The Model page allows you to specify the basic parameters of the linear mixed-effects model that S-PLUS will fit. The data sets used for fitting mixed-effects models typically contain measurements of a continuous response variable, at several levels of a covariate (for example, time, dose, or treatment), grouped according to one or more classification factors. Additional covariates may also be present, some may vary within a group (inner covariates), and some may not (outer covariates).
In the Linear Mixed Effects Models 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.
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.
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.
Random Effects
The variable names for the selected data set appear in the scrolling list.
Clicking this button opens the Random Effects Formula dialog for advanced formula specification.
Random Terms
Select the random effects from the dropdown list.
A one-sided formula specifying the random effects and the grouping variables. Its form is
~ x1 + + xN | group1/ group2/ /groupM
Fixed Effects
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 '~'.
Select one or more variables as the independent variables, or predictor, in the formula. To select more than one variable, Ctrl-click the variables.
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
The Options page allows you to specify the within-group error covariance structure by combining correlation structures and variance functions. By default, the within-group errors are assumed to be independent and have equal variances. You can also specify optimization options for the model fitting function with this dialog page.
In the Linear Mixed Effects Models dialog, the Options page has the following options:
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 structures are used to model within-group correlation not captured by the random effects. These are generally associated with temporal or spatial dependencies.
Results page
In the Linear Mixed Effects Models dialog, the Results page has the following options:
Printed Results
Short Output for Mixed Effects Models
Display a short summary of the model fit to the designated output window. This includes the model call, random effects, the number of observations, and the number of groups.
Long Output for Mixed Effects Models
Display a detailed summary of the model fit to the designated output window. This includes the model call, random effects, fixed effects, standardized within-group residuals, the number of observations, and the number of groups.
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
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.
Levels
Select an integer giving the level(s) of grouping to be used in extracting the residuals. Level values increase from outermost to innermost grouping, with level zero corresponding to the population residuals. The default is the highest or innermost level of grouping.
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
In the Linear Mixed Effects Models, 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.
Random Effects Dot
A Trellis dot-plot of the random effects is generated, with a different panel for each random effect (coefficient).
Random Effects Scatter
Select this for a scatter plot of estimated random effects.
Random Effects Normal QQ
Select this for a diagnostic plot for assessing the normality of residuals and random effects in the linear mixed-effects fit
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.
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
Levels Integer specifying the desired prediction level. Levels increase from outermost to innermost grouping, with level 0 representing the population (fixed effects) predictions. Defaults to the innermost level.
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.
Random Effects Options
Levels Integer value giving the level of grouping to be used for the random effects plot.
Predict page
In the Linear Mixed Effects Models, the Predict page has the following options'
Standard Predictions
Save Predictions
Select this to save the standard predictions.
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
Levels
Choose an integer specifying the desired prediction level. Levels increase from outermost to innermost grouping, with level 0 representing the population (fixed effects) predictions. Defaults to the innermost level.
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.
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
Levels
Choose an integer specifying the desired prediction level. Levels increase from outermost to innermost grouping, with level 0 representing the population (fixed effects) predictions. Defaults to the innermost level.
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 Linear Mixed Effects Models
Lme, lmeControl, lme.lmList, lme.groupedData, lmeObject, lmList, reStruct, varFunc, pdClasses, corClasses, varClasses