필터 지우기
필터 지우기

How to create a multiple linear regression model

조회 수: 4 (최근 30일)
Keegan Carvalho
Keegan Carvalho 2018년 6월 27일
답변: Ameer Hamza 2018년 6월 27일
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
Keegan Carvalho
Keegan Carvalho 2018년 6월 27일
편집: dpb 2018년 6월 27일
Actually i tried it but I'm a little confused on the result.
Estimate SE tStat pValue
________ _______ _______ ________
(Intercept) 8477.6 4797.1 1.7672 0.098969
x1 39.134 46.506 0.84148 0.41422
x2 128.31 80.696 1.59 0.13415
x3 -0.86657 0.61528 -1.4084 0.18083
This is what I got.
I used the following code:
data=readtable('seyreg.csv')
X = [data.sst,data.at,data.vlm]
lm = fitlm(X,data.sl,'linear')
Is this correct?
Adam Danz
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
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.

카테고리

Help CenterFile Exchange에서 Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by