Defining my own response model using Regstats function

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.

 Réponse acceptée

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

2 commentaires

Thanks a lot. That should do.
okay I ran into another bump. While the solution that you suggested works for the case that I had mentioned in my question, I have now ran into a slight variation of the aforementioned model. Consider the following model function
y = 3*log(a)*x1 + 4*log(b)*x2 + 5*log(c)*x3 ....
which means that the (unknown) coefficients appear as logarithms and also have a factor associated with them. How could I use regstats to solve such a problem.
I had thought that I could consider the entire coefficient as another coefficient variable e.g. a1 = 3*log(a), b1 = 4*log(b), etc. Then once I compute a1, b1, etc from regstats I could divide the result by the numerical factor and then take antilog of the result. But that surely is incorrect way of doing it because I am not getting the right results.
Any suggestions/comments would be much appreciated.
Thanks in advance.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by