Azzera filtri
Azzera filtri

Precise Prediction Model Development

1 visualizzazione (ultimi 30 giorni)
I have four coefficient for prediction model, x1, x2, y1 and y2. with the help of these four cofficient I have develop quadratic 15 coefficient model.
Model: y = B0+B1*X1+B2*Y1+B3*X2+B4*Y2+B5*X1Y1+B6*X1X2+B7*X1Y2+B8*Y1X2+B9*Y1Y2+B10*X2Y2+B11*X1^2+B12*Y1^2+B13*X2^2+B14*Y2^2
However, I am going to precise this model
Precise model:
y = B0 + B6*X1X2 + B9*Y1Y2 + B11*X1^2 + B12*Y1^2 + B13*X2^2 + B14*Y2^2
My concern is how can I buid a funciton which could response for the Precise model instead of quadratic one.
respone will be appreciated. Thank you
  3 Commenti
suraj karki
suraj karki il 22 Mag 2022
Modificato: suraj karki il 22 Mag 2022
Hello Strider
I have used 'fitlm' function to fit the data and y will be the response of the precise model.
suraj karki
suraj karki il 22 Mag 2022
with four independent variable x1, y1, x2 and y2 defined in tabular form I have used fitlm function with quadratic type.
Which have provided 15 coefficient model but I want to develop a model which is going to include 7 coefficient i.e
y = B0 + B6*X1X2 + B9*Y1Y2 + B11*X1^2 + B12*Y1^2 + B13*X2^2 + B14*Y2^2
coeff{i}= fitlm(coeff_table(i).table, 'quadratic','RobustOpts','on');

Accedi per commentare.

Risposta accettata

Star Strider
Star Strider il 22 Mag 2022
What are you predicting?
How does y fit in with this? Is it a separate vector?
With those concerns met, building the function and estimating ther parameters is straightforward —
xy = [X1(:) X2(:) Y1(:) Y2(:)]
% % b(1) = B0, b(2) = B6, b(3) = B9, b(4) = B11, b(5) = B12, b(6) = B13, b(7) = B14
% yfcn = (b,xy) = b(1) + b(2).*xy(:,1).*xy(:,2) + b(3).*xy(:,3).*xy(:,4) + b(4).*xy(:,1).^2 + b(5).*xy(:,3).^2 + b(6).*xy(:,2).^2 + b(7).*xy(:,4).^2; % Regression Function
DM = [yfcn = (b,xy) = [ones(size(xy(:,1))), xy(:,1).*xy(:,2), *xy(:,3).*xy(:,4), *xy(:,1).^2, *xy(:,3).^2, xy(:,2).^2, xy(:,4).^2]; % Design Matrix
B = DM \ y(:) % Calculate Coefficients
I wrote ‘yfcn’ for record-keeping purposes, although you can use it with nonlilnear parameter estimation problems if you wish. However, since this is a linear problem, the ‘DM’ design matrix and the parameter calculation for ‘B’ in the following line will be most efficient.
Be sure to check it for coding errors in ‘DM’ in case I missed something.
.
  4 Commenti
suraj karki
suraj karki il 22 Mag 2022
Thank you Strider
Star Strider
Star Strider il 22 Mag 2022
As always, my pleasure!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by