File Exchange

image thumbnail


version (17.6 KB) by Giuseppe Cardillo
A simple function on LS linear regression with many informative outputs


Updated 05 Apr 2018

View Version History

GitHub view license on GitHub

This function computes a least-square linear regression suppling several output information.
Syntax: myregr(x,y)

X - Array of the independent variable
Y - Dependent variable. If Y is a matrix, the i-th Y row is a
repeated measure of i-th X point. The mean value will be used
verbose - Flag to display all information (default=1)
- Slope with standard error an 95% C.I.
- Intercept with standard error an 95% C.I.
- Pearson's Correlation coefficient with 95% C.I. and its
adjusted form (depending on the elements of X and Y arrays)
- Spearman's Correlation coefficient
- Regression Standard Error
- Total Variability
- Variability due to regression
- Residual Variability
- Student's t-Test on Slope (to check if slope=0)
- Student's t-Test on Intercept (to check if intercept=0)
- Modified Levene's test for homoschedasticity of residuals
- Power of the regression
- Deming's regeression
- a plot with:
o Data points
o Least squares regression line
o Red dotted lines: 95% Confidence interval of regression
o Green dotted lines: 95% Confidence interval of new y
evaluation using this regression.
- Residuals plot

SEE also myregrinv, myregrcomp

Created by Giuseppe Cardillo

To cite this file, this would be an appropriate format: Cardillo G. (2007) MyRegression: a simple function on LS linear regression with many informative outputs.

Cite As

Giuseppe Cardillo (2020). MyRegression (, GitHub. Retrieved .

Comments and Ratings (12)

Giuseppe Cardillo

Why people always talk before read? Robert Did you read "Description" and "Updates" sections before posting your comments?


In the code you have a line where it tries to automatically download dependent software. That is a a super bad design and really puts a bad taste in ones mouth for your package. You should just tell people they need to download powerStudent and indicate the dependency.

Chris Choi

Having a few statistics that MATLAB default functions do not provide is awesome especially when it's too cumbersome to write a new one. Good job!

Suryo Kusumo

hamed nozari

very good. thanks


useful for me

Oleg Komarov

In spite of the many useful fcns written by giuseppe, I don't see much use for this one, especially if we consider that the Statistics TB is mandatory (not to talk about fcns by other authors...). Regress, regstats and my personal enhanced variation do already the most...



It might already be in stat toolbox, but for those of use that can't afford the toolbox, this is great.

Kai M

This is a great file. It's way simpler than the theoretically overloaded MatLab code. Very nice gimmicks include outlier exclusion, plotted confidence intervals etc. This really saves time, because all you need is plugging in the two vectors you want to correlate. Thanks a lot to the author!!!

Dimitri Shvorob

REGRESS of Statistics Toolbox already does most of the calculations, and is not restricted to the single-regressor case. The author is apparently unaware of the 'b = inv(x'*x)*(x'*y)' formula, and computes OLS coefficients with POLYFIT.(?!). Redundant and badly written.

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: powerStudent

Inspired: myregrinv

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!