What does added variable plot meen?

4 vues (au cours des 30 derniers jours)
avner yakov
avner yakov le 10 Mar 2018
I have a linear regression model and I want to make scatter plot with confidence bounds, the problem is I have a multiple variables so the plot(linear_model) command is plotting something that called "added variable plot". Are this the same as scatter plot? If not, How can i plot the bounds intervals? i now i can get the from predict(linear_model) but how can i plot them along side my fit?

Réponses (1)

Anudeep Kumar
Anudeep Kumar le 3 Avr 2025
Hey Avnor,
An added variable plot, also known as a partial regression leverage plot, illustrates the incremental effect on the response of specified terms caused by removing the effects of all other terms.
An added variable plot created by plotAdded”, or even “plot” in your case, with a single selected term corresponding to a single predictor variable includes these plots:
  • Scatter plot of adjusted response values against adjusted predictor variable values
  • Fitted line for adjusted response values as a function of adjusted predictor variable values
  • 95% confidence bounds of the fitted line
As far as I understand the bounds are plotted by the function in the same plot.
In any case, below is how you can plot bounds to scatter plot if you have obtained the bounds from “predict” function.
% Sample data
X = rand(100, 2); % Two predictor variables
y = 3 + 2*X(:,1) + 5*X(:,2) + randn(100, 1); % Response variable
% Fit the linear regression model
mdl = fitlm(X, y);
% New data for prediction (can use original data for plotting)
newData = X;
% Obtain predictions and confidence intervals
[yPred, yCI] = predict(mdl, newData);
% Plot the data
figure;
hold on;
scatter3(X(:,1), X(:,2), y, 'b'); % Scatter plot of the original data
% Plot the regression line (for visualization, use one predictor)
% Here, we are assuming a 2D plot; adjust for higher dimensions if needed
plot3(newData(:,1), newData(:,2), yPred, 'r', 'LineWidth', 2); % Fitted line
% Plot confidence intervals
% Note: This example assumes a simple 2D visualization; adjust for your specific case
fill3([newData(:,1); flipud(newData(:,1))], ...
[newData(:,2); flipud(newData(:,2))], ...
[yCI(:,1); flipud(yCI(:,2))], ...
'r', 'FaceAlpha', 0.2, 'EdgeColor', 'none');
xlabel('Predictor 1');
ylabel('Predictor 2');
zlabel('Response');
title('Scatter Plot with Regression Line and Confidence Bounds');
hold off;
I have added the link to the documentation of “plot” :
I hope this helped

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by