<< fullfact Regression tools (regtools) nlinlsq >>

Regression tools (regtools) >> Regression tools (regtools) > linregr

linregr

An interactive tool for carrying out multi linear regression.

Calling Sequence

linregr()           // start linregr with some demo data in interactive mode...
linregr(Data[,Names,ZDef,Ydef,alfa]) // Start in interactive mode using the data set Data (with optional column names Names, regression variables ZDef, Ydef and alfa.)
[beta,stat]=linregr(Data,Names,Zdef,Ydef[,alfa]) // run in silent command line mode - returning the results as variables.

Parameters

Data :

matrix containing experimental variables as column vectors.

Names:

optional space separated string containing names for each column in Data. Each name must be a valid name for a Scilab variable.

Zdef:

optional space separated string defining the linear regression matrix Z

Ydef:

optional space separated string defining the dependent variable

alfa:

optional significance level (default = 0.05) for the parameter confidence interval estimate

beta:

parameter estimates (only in command line mode).

stat:

data structure with various statistical results (only in command line mode).

stat.Z:

dependent variable matrix

stat.ZTZ:

ZTZ=Z'*Z;

stat.cov:

cov=inv(ZTZ); // covariance matrix

stat.b:

b=cov*Z'*Y; // linear regression parameters

stat.Yhat:

Yhat=Z*b; // estimate of Y

stat.Y:

dependent observations

stat.resid:

resid=Y-Yhat; // residuals

stat.SSr:

SSr=resid'*resid; // residual error

stat.Ybar:

Ybar=mean(Y); // average Y

stat.SSt:

SSt=(Y-Ybar)'*(Y-Ybar); // variance of the data points Y about mean(Y)

stat.SSe:

SSe=(Yhat-Ybar)'*(Yhat-Ybar); // variance of the estimates Yhat about mean(Y)

stat.SSxy:

SSxy=sqrt(SSr/(n-p)); // standard error of estimates of y on x

stat.SSy:

SSy=sqrt(SSt/length(Y));

stat.bdev:

bdev=sqrt(diag(cov))*SSxy; // Standard deviation of estimate

stat.bdelta:

bdelta=cdft('T',n-p,1-alfa/2,alfa/2)*bdev; // confidence interval for b

stat.bint:

bint=[b-bdelta, b+bdelta]; // confidence interval for b given as min and max values

stat.R2:

R2=1-SSr/SSt; // R^2 of multiple correlation of y on all x

stat.R2adj:

R2adj=1-SSr/SSt*(n-1)/(n-p-1); // R2 adjusted for the number of regression variables

Description

linregr is a user friendly tool for analysing data using multi linear regression.

In interactive mode a graphical user interface is presented and statistical results from regression analysis is presented in the Scilab Console window.

When run in silent command line mode the results are returned as the parameters beta and stat. In this mode no statistical information is displayed in the Scilab Console window.

See the Scilab Demonstrations section for some linear regression test problems from the NIST StRD Dataset Archives.

Examples

X=[0:.1:2*%pi]'; Y=[X+rand(X)+X.^2+10*sin(X)];
[b,stat]=linregr([Y X],'y x','x x.^2 sin(x)','y')  // solve problem in command line mode

// Example from http://en.wikipedia.org/wiki/Simple_linear_regression
Height=[1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83]';
Weight=[52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29, 63.11, 64.47, 66.28, 68.10, 69.92, 72.19, 74.46]';
linregr([Weight Height],'Weight Height'); // Interactive mode

See also

Bibliography

http://en.wikipedia.org/wiki/Regression_analysis

NIST StRD Dataset Archives - Linear regression: http://www.itl.nist.gov/div898/strd/general/dataarchive.html

Authors

<< fullfact Regression tools (regtools) nlinlsq >>