## General Linear Regression Model

version 1.1.0.0 (3.41 KB) by
Generalized form of single and multivariate regression model (linear and non-linear)

Updated 28 Jan 2016

out = GenRegModel(x,y, deg) returns a linear regression fit of y using variables x with a polynomial degree defined by deg. By default deg = 1. Each column of x represents a separate regressor of the model. y is a colum vector, which is to be estimated by regression.
The output is saved in out as a structured form:out.b contains the coefficients of the polynomial models as columns out.model is the model equation out.y_hat is estimate of all y variables as column vectors

out.SSE: sum of squared error for models of each variables in y
out.SST: sum of squared total for models of each variables in y
out.SSR: sum of squared regression for models of each variables in y
out.R2: R-squared measurement for models of each variables in y
out.KL: measure of Kullback-Leibler (KL) divergence for models of each variables in y

out = genRegModel(x,y,deg,setb,bvalue) allows to set one or more coefficients to specific value(s). setb is an array of the indices of variables, which weights are pre-set, whereas bvalue is the array of those pre-set values. For example, if we do not want the constant term in our equation, then setb = 0, the first index, and bvalue = 0, no weight to constant. Mare sure to define deg even if this is 1 in this case!

Examples
x1 = random('uniform',1,10,[100,1]);
x2 = random('uniform',1,10,[100,1]);
y = (1./x1+1./x2).^(-1)+abs(random('normal',0,1,[100 1]));
out1 = genRegModel([x1 x2],y,1);
out2 = genRegModel([x1 x2],y,2,[0 2],[0,1]);

### Cite As

Shoaibur Rahman (2022). General Linear Regression Model (https://www.mathworks.com/matlabcentral/fileexchange/48738-general-linear-regression-model), MATLAB Central File Exchange. Retrieved .

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