MATLAB: Defining the own response model using Regstats function

multiple regressionregressionregstatsuser-defined model

I am trying to fit my data – predictors x1,x2,x3 and response y – using regstats function of MATLAB. I wish to use my own model response for y.
Consider the model polynomial
y = a + b*x1 + c*x2 + d*x3 + e*x1^2*x2 + f*x2^2*x3 + g*x3^2*x1 + h*x1^2*x3 + ….. so on and so forth
If I were to use a polynomial like this as my model, I could specify my model matrix as defined in the x2fx function. However, my query is if I were to specify a model something like the one given below, how could I do so.
y = 3*x1 + 4*x2 + 5*x3 + a*x1^2*x2 + b*x2^2*x3 + …….
which means that my model has some pre-determined coefficients already and I need to find coefficients only for some select terms.
Thanks in advance.

Best Answer

One way to do this is to move all the known stuff to the left-hand-side:
y - 3*x1 - 4*x2 - 5*x3 = a*x1^2*x2 + b*x2^2*x3 + ...
So call regstats giving your response variable as
y - 3*x1 - 4*x2 - 5*x3
Related Question