Regression model with two equation

2 ビュー (過去 30 日間)
Tasha Williams
Tasha Williams 2023 年 1 月 12 日
コメント済み: Torsten 2023 年 1 月 13 日
What is the best way to create a regression model that is based on two equations ?
For example:
y1=A1x1+B1
y2=A2x2+B2
Where y2 is dependent on y1.
All input values is array of data and not just one point.
I've tried using fminsearch, fitlm, lsqr. I'm just not sure how to couple the two equation while also doing a regression and finding the best combination on A1 and A2 terms.
  2 件のコメント
Torsten
Torsten 2023 年 1 月 12 日
Why is y2 dependent on y1 ? According to your model equations, this does not seem to be the case.
Tasha Williams
Tasha Williams 2023 年 1 月 12 日
B2 include an equation with 3 variable (l,m,n) where l and m are known while n is a thermodynamic property based on the output of y1. I have simplified the equations in order to answer the question in a more straight forward way.

サインインしてコメントする。

回答 (1 件)

the cyclist
the cyclist 2023 年 1 月 12 日
As @Torsten mentions in his comment, the way you have written your equations, it is not possible to see why they are coupled.
That being said, the MATLAB function you need maybe the mvregress function. See that documentation page for details, and also you could take a look at this answer of mine, which gives some example design matrices.
  8 件のコメント
Tasha Williams
Tasha Williams 2023 年 1 月 13 日
No constraints on y1.
Yes, that is correct, y1 should be a vector of the same length as x1 once calculated. x1 can be different for different data sets but lets say it's a column vector with 10 values.
Torsten
Torsten 2023 年 1 月 13 日
If the relation
y1 = rho_suc*D*E - A1*x1
has to be satisfied with equality for all elements of the x1 vector, then your problem should be formulated as
min: (y2 - B2(y1) - A2*x2).^2
under the constraint
y1 - (rho_suc(y1)*D*E - A1*x1) = 0
with y1, A1 and A2 as unknowns.
You can use fmincon to solve where the constraint can be implemented in function "nonlcon".

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by