Precise Prediction Model Development
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2022-5-22
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!