How to find a particular data in a residuals plot

I have a residual plot ( using plotResiduals(mdl, 'fitted'))where the data is taken from a Table.
Since I know the row number of the data in Table, how can I find the location a certain data in the plot? eg: the locations of the 15th and 50th data.

 Réponse acceptée

Not at all certain about this.
If I understand correctly, that would seem to me to be:
xd = x([15, 50]); % Desired Values Of Independent Variable
yd = y([15, 50]); % Desired Values Of Dependent Variable

10 commentaires

Sorry. where should I add the code?
plotResiduals(mdl, 'fitted');
% Does matlab has this --->
% A = 'Tell me the residual of the 15th and 50th data from the plot' function
ans:
A = [residual 1 residual 2]
Try this:
x = 1:60; % Create Data
y = 5 + x/10 + rand(size(x))*0.1; % Create Data
mdl = fitlm(x,y); % Model
h = plotResiduals(mdl, 'fitted');
D15 = [h(1).XData(15); h(1).YData(15)]; % First Residual
D50 = [h(1).XData(50); h(1).YData(50)]; % Second Residual
Yes. This is exactly what I am looking for. Can I check with you what does the bracket one mean?
h(1)
Great!
Of course! The ‘h’ handle returns two objects: ‘h(1)’, a line object that is essentially a scatterplot of the residuals, and ‘h(2)’, the horizontal dashed reference line.
The line object returned by ‘h(1)’ returns the information you want as a structure, and the rest accesses the relevant fields of that structure.
Sorry, I don't follow you? What are Line object and horizontal dashed reference line?
The ‘h’ handle returns references to two line objects. The first, ‘h(1)’, is actually the scatterplot of the residuals. The second, ‘h(2)’ (that we do not use here) is the horizontal dashed (or dotted) line in the plot.
At least this is the way it appears in R2017a. If you run your code or my demonstration code, you should see both ‘lines’ (the scatterplot of x symbols) and the horizontal dashed (or dotted) reference line at 0 in the PlotResiduals plot.
See the third (last) plot in the documentation on PlotResiduals (link) as Residual Plots for Generalized Linear Models (link). That illustrates the 'fitted' plot I am referring to.
Ah. Thanks for the explanation. I get what you mean now. Wondering under what circumstances h(2) can be used, since it is just a horizontal line?
My pleasure.
I’m not sure about using ‘h(2)’. Possibly the minimum and maximum values of the independent variable, but beyond that, it doesn’t seem to have significant utility other than with respect to the plot.
Noted. Cheers :)
Cheers!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by