Basis function regression for 3 parameters

6 views (last 30 days)
Yash Bhatia
Yash Bhatia on 30 Nov 2022
Edited: Torsten on 30 Nov 2022
I am currently working on finding the coefficients for a linear regression model, given its dependence on basis functions. The model is y(x1, x2, x3) = a_0 f_0(x1, x2, x3) + a_1 f_1(x1, x2, x3) + a_2 f_2(x1, x2, x3).... up to a_10 f_10(x1, x2, x3). The functions are, for example, f_0 = 1, f_1 = sin(x1*x2), f_2 = x1*x3^2 and so on.
Given this, I am aware that for a bivariate regression model y(x1, x2) , the matrices would look something like the attached picture. Then we can simply solve for X given the model is a linear system Ax = B
My question is, is there an analogous set of matrices for 3 predictors? I would imagine this would make A an (11x11x11) matrix, and B would still be (11x1) matrix. But when I construct these matrices in MATLAB and try to solve the system using the expression
X = A\B;
it informs me the matrices must be 2 dimensional.

Answers (1)

Torsten
Torsten on 30 Nov 2022
Put the equations
y(x1(i),x2(j),x3(k)) = a_0*f_0(x1(i), x2(j), x3(k)) + a_1*f_1(x1(i), x2(j), x3(k)) + a_2*f_2(x1(i), x2(j), x3(k)) + ... + a_10*f_10(x1(i), x2(j), x3(k))
in matrix form
Y = F*a
and solve for a as
a = F\Y
  2 Comments
Torsten
Torsten on 30 Nov 2022
Edited: Torsten on 30 Nov 2022
Write
y(x1(i),x2(j),x3(k)) = a_0*f_0(x1(i), x2(j), x3(k)) + a_1*f_1(x1(i), x2(j), x3(k)) + a_2*f_2(x1(i), x2(j), x3(k)) + ... + a_10*f_10(x1(i), x2(j), x3(k))
as
y(x1(i),x2(j),x3(k)) = [f_0(x1(i), x2(j), x3(k)) f_1(x1(i), x2(j), x3(k)) f_2(x1(i), x2(j), x3(k)) ...f_10(x1(i), x2(j), x3(k))]*[a_0 ;a_1 ;a_2 ;...;a_10]
Can you see what the (ijk)-th row of F and the (ijk)-th entry of Y is ?

Sign in to comment.

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by