How do I read residuals from a model fit?

mdl.residuals is not working for some unknown reason.
I have attached the code here using the LaTex button, but it looks like a single unreadable line, so i am attaching a picture of it as well.
Thanks for taking the time to look at this,
Alex
MatlabResidualProblem.JPG

 Accepted Answer

Never mind.
Residuals needs to be capitalized.

More Answers (1)

Try this instead:
r = mdl.Residuals.Raw
MATLAB prefers that you use its exact names with respect to its structures and structure fields, and since MATLAB is case-sensitive, every detail is relevant.

4 Comments

Hi Star Strider.
Since you are here I have a more complicated question.
A composite multilevel model for change has 3 different types of residuals associared with it.
The one that Residuals.raw shows is the vertical distance from the fitted line to each data point, but the composite model is a combination of a level 1 model that fits each individual's data points to a line and a level 2 model that compares those lines to the overall fit of the data.
In that case there are residuals associated with the differences of the intercepts between the level one models and fit, residuals associated with the differences in slopes of the level 1 model and fit, and covariate residuals that contain information about the relationship between the intercepts and slopes of the level 1 models.
I would like to implement this in Matlab, but am not sure how.
Thanks,
Alex
My pleasure.
I would like to implement this in Matlab, but am not sure how.
Unfortunately, that makes two of us. I am not sufficiently skilled in such linear regression techniques to reply, since I have never done anything nearly so sophisticated.
Figured it couldn't hurt to ask.
Nice talking to you again and have a great 2019!
Alex
Thank you! You, too!
It might be best to use the Contact Us link at the upper right corner of this page, and ask MathWorks directly for help. First, they will know all the capabilities that fitlm has (at least some of which may be undocumented), and second because your request may be more than most of us here have the experise to reply to. As well, if fitlm can’t currently do what you want, your request will be considered a request for an enhancement to fitlm in future releases, or an interim upgrade to the current release.

Sign in to comment.

Products

Release

R2018b

Community Treasure Hunt

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

Start Hunting!