regress

Perform multiple linear regression using the model y = X * beta + e.

Syntax

[b,bi,r,ri,stats]=regress(y,X)

[b,bi,r,ri,stats]=regress(y,X,alpha)

Inputs

y
The response values.
Type: double
Dimension: vector
X
The regressor variable values. The first column is a vector of 1 values.
Type: double
Dimension: matrix
alpha
The level of significance (default: 0.05).
Type: double
Dimension: scalar

Outputs

b
The regression coefficients (beta estimates).
bci
The regression coefficient confidence intervals.
r
The residuals.
rci
The residuals confidence intervals.
stats
Regression statistics. The following values are returned:
R^2, the coefficient of determination
F, the F statistic
p, the p value
v, the estimated variance of the random errors
Dimension: vector

Example

y = [6.59; 7.89; 8.49; 3.5; 6.7; 6.9; 4.99; 5.09; 8.09]
X = [1.0, -0.69, 2.0; 1.0, -0.69, 3.0; 1.0, -0.69, 4.0;
1.0, 0.0, 2.0; 1.0, 0.0, 3.0; 1.0, 0.0, 4.0;
1.0, 0.41, 2.0; 1.0, 0.41, 3.0; 1.0, 0.41, 4.0]
[b,bi,r,ri,stats]=regress(y,X)
b = [Matrix] 3 x 1
 2.12192
-1.59846
 1.40000
bi = [Matrix] 3 x 2
-0.82651  5.07035
-3.30187  0.10494
 0.45306  2.34694
r = [Matrix] 9 x 1
 0.56514
 0.46514
-0.33486
-1.42192
 0.37808
-0.82192
 0.72345
-0.57655
 1.02345
ri = [Matrix] 9 x 2
-1.17863  2.30891
-1.59401  2.52430
-2.14839  1.47867
-2.90897  0.06513
-1.97507  2.73122
-2.77729  1.13345
-1.05248  2.49938
-2.68810  1.53499
-0.56601  2.61290
stats = [Matrix] 1 x 4
0.75369  9.17986  0.01494  0.89858