How to create a multiple linear regression model
조회 수: 4 (최근 30일)
이전 댓글 표시
I wanted to create a regression model in which sl = sst+at+vlm (Column headings in the csv file). I have attached the csv file and will be grateful if someone could provide me with the code. I wanted to get a formula like y = 1 +ax1 +bx2 +cx3.
Thanks!
댓글 수: 3
Adam Danz
2018년 6월 27일
What are you confused about and is what correct? Your code along with your data should produce those results. Interpreting those results is a whole other story that can't be told without knowing more background information. Is there something unexpected in the output?
If you're having trouble understanding the output table or are uncertain of the inputs to the model, read the matlab literature on fitlm .
If your uncertainty is due to not understanding linear models it would be helpful to read a chapter about them or watch some introductory videos.
If there's a more specific question about the matlab code or function, people may be able to help more.
답변 (1개)
Ameer Hamza
2018년 6월 27일
Your use of fitlm() is correct. Alternatively, if you don't need all the extra information provided by fitlm() and speed is a concern then you can use MATLAB mldivide (\.) to solve it more efficiently.
data = readtable('seyreg.csv');
X = [data.sst data.at data.vlm ones(size(data.sst))];
Y = data.sl;
coefficient = X\Y;
the coefficient are in same order as the column of X.
댓글 수: 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!