Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: stats
See also: gls linreg linregfs

Quantlet: linregres
Description: linregres computes some residual analysis for a linear regression.

Reference(s):

Usage: {res,out} = linregres (x, y, yh)
Input:
x n x p regressors
y n x 1
yh n x 1
Output:
xfs n x 4
out n x 2

Note:

Example:
; loads the library stats
library("stats")
; reset random generator
randomize(0)
; generate x
x = normal(100, 3)
; generate y
y = 10*x[,3]+x[,1].*x[,2]
; do the forward selection
{xfs,bfs}=linregfs(x, y, 0.05)
; compute residual number
{res,out}=linregres(xfs, y, xfs*bfs)
; create a display fro plotting
disp = createdisplay(2,2)
; show residual plots
;    residuals               leverage
;    standardized residuals  Cook distance
show(disp, 1, 1, y~res[,1])
show(disp, 2, 1, y~res[,3])
show(disp, 1, 2, y~res[,2])
show(disp, 2, 2, y~res[,4])

Result:
shows the residual plots. From the standardized residuals
we find three points in the bottom with an absolute value
larger than 3. The leverage plot shows on the right and
the left sets of points with a leverage larger than 0.04
(thus they are influential). The Cook distance plot shows
no datapoints larger than 1 and we can not find outliers
in x.



Author: S. Klinke, 19970522
(C) MD*TECH Method and Data Technologies, 05.02.2006