help with linear regression function
2 views (last 30 days)
Show older comments
miguel antonio
on 3 Oct 2013
Commented: Shashank Prasanna
on 3 Oct 2013
bear with me this is goign to be a long description: Im trying to follow the interpret linear regression example from mathworks but I'm getting errors:
I have 3 sets of data: the order is age, weight, BP 52 173 132 59 184 143 67 194 153 73 211 162 64 196 154 74 220 168 54 188 137 61 188 149 65 207 159 46 167 128 72 217 166
I'm trying to set BP as the dependet(predictor) and age and weidgt as the independent columns. this is my code
if true
% code
age=[ 52 59 67 73 64 74 54 61 65 46 72]'
BP=[132 143 153 162 154 168 137 149 159 128 166]'
weight =[173 184 194 211 196 220 188 188 207 167 217]'
x1= age;
x2=weight;
BP=y;
X=[x1,x2,y]
lm= fitlm(X,y,'linear')% when I enter this I get this error
??? Undefined function or method 'fitlm' for
input arguments of type 'double'.
end
can somebody help me? please I need help
0 Comments
Accepted Answer
Shashank Prasanna
on 3 Oct 2013
Edited: Shashank Prasanna
on 3 Oct 2013
fitlm is a convenience interface function for LinearModel.fit that was introduced in MATLAB R2013b. If you are using an earlier release, replace fitlm with the latter.
Here is the release notes that talk about the change:
lm = LinearModel.fit(X,y,'linear')
If you are using a version of MATLAB earlier than R2012a you can use the REGRESS function to do the same.
2 Comments
Shashank Prasanna
on 3 Oct 2013
What version of MATLAB are you using? Do you have the Statistics Toolbox installed? You can find out both the information but running:
>> ver
If you have a version of MATLAB before R2012a use REGRESS (search for it in the MATLAB documentation)
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!