Filter löschen
Filter löschen

How to use correctly fitlm modelspec ?

6 Ansichten (letzte 30 Tage)
NoNo
NoNo am 4 Nov. 2015
Hello,
I want to make a linear regression using three variables (SlopeS, SlopeD, MaxWRatio) and my response vector errorPs. When I use the function fitlm with the model specification "interactions" it gives me y = x1 + x2 + x3 + x1*x2 + x1*x3 + x2*x3. Now I want to test the fitlm for y = x1*x2 + x1*x3 + x2*x3. How can I do it ? I try with a terms matrix and also with a formula but I always have errors... Could you help me ? Below is my code. Thank you very much in advance ! N0N0.
% first with term matrix
XS = [SlopeS,SlopeD,MaxWRatio]; % it is 13x3 doubles
y = errorPs; % it is 13 doubles
T = [0 0 0 0, 1 1 0 0, 0 1 1 0, 1 0 1 0];
Regression = fitlm(XS,y,T);
I obtain the error and I don't understand what I have to change:
Error using classreg.regr.TermsRegression/createFormula (line 818)
The terms matrix must have one column for each predictor variable, and the
last column for the response variable.
And with formula:
% second with formula
XS = [SlopeS,SlopeD,MaxWRatio]; % it is 13x3 doubles
y = errorPs; % it is 13 doubles
Regression = fitlm(XS,y,'y ~ SlopeS:SlopeD:MaxWRatio'
And here I obtain this error and I still don't know what to change !
The model formula contains names not recognized as predictor or response
names.
Thank you for your help !!!!

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by