Use Optimization Toolbox to optimise Linear regression model response
10 次查看(过去 30 天)
显示 更早的评论
Hi all,
I used experimental data and function fitlm to fit two regression models, Stress (S) and Mass (M), which are all response of 3 predictors, x1,x2,x3.
All 3 predictors have their constraints, say x1 = [15 20], x2 = [25 30], x3 = [1 3].
I am trying to use the Optimisation Toolbox to find:
1. the minimum Mass(M) with constraint Stress(S) <=200
2. the maximum Stress(S) with constraint Mass(M) <= 45
The challenges for me here are:
- how to write the objective function of Stress(S) and Mass(S) without manually typing a giant function with all the coefficients found in the regression model?
- Mass (M) and Stress(S) are responses of the 3 predictors, therefore I do not see strong correlation between M and S but obvious they are. I can do this in excel Solver but do not really know how to do this in Matlab.
Thank you for reading this and thank you for your reply in advance.
0 个评论
回答(1 个)
John D'Errico
2017-8-18
编辑:John D'Errico
2017-8-18
You already have the regression models? Now, given these models, you want to find some optimal point, based on some constraints?
From what you have said, these models are probably polynomial in form, since you have lots of coefficients.
If all of the models are purely linear, then linprog would suffice. I doubt they are linear though, as you would have few coefficients to worry about.
So then fmincon will be appropriate.
Do NOT type in the coefficients. Do NOT do that. People think they see a coefficient like 1.237 in the command window, so they can just use that number as the coefficient in some messy regression model. NONONONONO!!!!!!!!!
The number is NOT truly 1.237. There are more digits than that in the number. You need to use the number as it was estimated and stored in MATLAB. The difference is almost always important in a large polynomial regression model. Otherwise, the next frenzied question you ask on this site is why does my regression model not predict properly, or why does it predict strange things?
How to do this all? You learn to use MATLAB. You learn to use matrices & vectors, matrix multiplication, etc. Yes, I know, that is not very specific as a response, because you have told us essentially nothing of significance in your question. So I can't be more helpful than that. But it is accurate.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!