The Neurophysiological Biomarker Toolbox (NBT)



How to run linear regression analysis in Matlab

Linear regression analysis can be done using the LinearModel class (which only exists from Matlab R2012b (Statistics toolbox) (as always it is good to check the help of this class type help LinearModel in the command window)

As an example, we here fit a very simple model:

This can be done typing:

 mdl = LinearModel.fit(X,Y); 

assuming X is data matrix with and along the columns, and Y is a vector of Y data.

Type

mdl 

to see the outcome of the fit.

Next we want to predict from the data using the model we fitted above. This is done using the 'predict' function.

Y2 = predict(mdl,X2);
tutorial/how_to_run_linear_regression_analysis_in_matlab.txt · Last modified: 2013/06/06 20:31 by Simon-Shlomo Poil
The NBTwiki platform - version 2.8 - 9 May 2013
Copyright (C) 2008-2015