How to create a multiple linear regression model
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Adam Danz
le 27 Juin 2018
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.
Réponses (1)
Ameer Hamza
le 27 Juin 2018
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 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!