Obtains residuals, fitted values and their standard errors from a REML
analysis (S.J. Welham).
Options
RESIDUALS = variate |
Saves the residuals |
---|---|
SERESIDUALS = variate |
Saves standard errors of the residuals |
FITTEDVALUES = variate |
Saves the fitted values |
SEFITTEDVALUES = variate |
Saves prediction standard errors for the fitted values |
RMETHOD = string token |
Which random terms to use when calculating the residuals (final , all ); default fina |
MAXNUNITS = scalar |
Maximum number of units for which the full variance-covariance matrix will be formed; default 1000 |
EXIT = scalar |
Exit code set to zero if the saving was successful, one otherwise |
SAVE = REML save structure |
Save structure for the required analysis; default uses the save structure from the most recent REML |
No parameters
Description
The VFRESIDUALS
procedure saves residuals, fitted values and their standard errors from a REML
analysis. The residuals are formed as differences between the data and the fitted model. The RMETHOD
option controls which random terms are used to calculate the residuals, with settings:
all |
uses all of the random effects, and |
---|---|
final |
uses only the final random term (default). |
The final
setting thus provides conditional residuals, with the fitted model is calculated from all of the fixed and random terms in the model. The all
setting provides marginal residuals, with the fitted model is calculated from the fixed terms alone.
The residuals and fitted values can be saved, in variates, using the RESIDUALS
and FITTEDVALUES
options, respectively. The SERESIDUALS
option saves the standard errors of the residuals, and the SEFITTEDVALUES
option saves the prediction standard errors of the fitted values (i.e. the square root of the prediction error variances).
The standard errors can be calculated in several different ways, and VFRESIDUALS
will attempt to use the most efficient method. One method involves saving the full variance-covariance matrix for the data. This can be time-consuming for large data sets, so the MAXNUNITS
option sets a limit (default 1000) on the size of data set for which this may be used.
By default, VFRESIDUALS
forms the residuals etc. from the most recent REML
analysis. However, you can form them from an earlier analysis, by using the SAVE
option to specify its save structure (saved using the SAVE
parameter of the REML
command that performed the analysis).
VFRESIDUALS
is currently unable to form standard errors for models containing spline terms.
Options: RESIDUALS
, SERESIDUALS
, FITTEDVALUES
, SEFITTEDVALUES
, RMETHOD
, MAXNUNITS
, EXIT
, SAVE
.
Parameters: none.
Method
The linear mixed model is
y = Xβ + Zu + ε
where
y is a vector of data,
β is a vector of fixed effects, with design matrix X,
u is a vector of random effects, with design matrix Z,
ε is a vector of random error
The conditional residuals take the form
ε~c = y – Xβ^ – Zu~
with variance matrix
var(ε~c) = σ2 (R – W C-1 W′)
where
Wα = Xβ + Zu
σ2 C-1 = var(α^ – α)
and R is the matrix of variances and covariances fitted to the residual.
The standard errors of the residuals are given by the square root of the diagonal of the variance matrix. The diagonal of σ2 (W C-1 W′) can be obtained as the standard error of the predicted fitted values, and the matrix R can be derived from the fitted model.
The marginal residuals take the form
ε~m = y – Xβ^
with variance matrix
var(ε~m) = σ2 (H – X (X′ H-1 X)-1 X′)
where
σ2 H = var(y)
Again, the standard errors are given by the square root of the diagonal of this matrix. The diagonal of σ2 X (X′ H-1 X)-1 X′ can be obtained as the standard errors of the predicted fitted values. The matrix H can be derived from the fitted model, or obtained using the UVCOV
option of VKEEP
.
See also
Directives: REML
, VCOMPONENTS
, VKEEP
.
Commands for: REML analysis of linear mixed models.
Example
CAPTION 'VFRESIDUALS example',\ !t('Incomplete block design, data from Cochran & Cox',\ '(1957), Experimental Designs, p.406.'); STYLE=meta,plain FACTOR [LEVELS=2; VALUES=25(1,2)] Reps & [LEVELS=10; VALUES=5(1...10)] Blocks & [LEVELS=25; VALUES=1...25,1,6...21,2,7...22,3,8...23,4,9...24,\ 5,10...25] Treats VARIATE [NVALUES=50] Yield READ Yield 6 7 5 8 6 16 12 12 13 8 17 7 7 9 14 18 16 13 13 14 14 15 11 14 14 24 13 24 11 8 21 11 14 11 23 16 4 12 12 12 17 10 30 9 23 15 15 22 16 19 : VCOMPONENTS [FIXED=Treats] RANDOM=Reps+Blocks REML [PRINT=*] Yield; SAVE=S VFRESIDUALS [RESIDUALS=residual; SERESIDUALS=seresidual;\ FITTEDVALUES=fittedvalue; SEFITTEDVALUES=sefittedvalue] PRINT Yield,fittedvalue,sefittedvalue,residual,seresidual CAPTION 'The standard errors are equal, because the design is balanced.'