how can i plot adjusted r squared and sum of squared error in matlab

To plot the adjusted R-squared and the sum of squared error in MATLAB, you first need to calculate these values using your data. Once you have the calculated values, you can use the plot function in MATLAB to create the plot.

Here is an example of how you can do this:

main.m
% Generate example data
x = 1:10;
y = 2*x + randn(size(x));

% Fit a linear regression model
model = fitlm(x, y);

% Calculate adjusted R-squared
adjR2 = model.Rsquared.Adjusted;

% Calculate sum of squared error
SSE = sum(model.Residuals.Raw.^2);

% Create the plot
figure;
subplot(2, 1, 1);
plot(adjR2);
title('Adjusted R-squared');

subplot(2, 1, 2);
plot(SSE);
title('Sum of Squared Error');
396 chars
23 lines

In this example, we first generate some example data (x and y) and fit a linear regression model to it using the fitlm function. We then calculate the adjusted R-squared and the sum of squared error using the Rsquared.Adjusted property and the Residuals.Raw property of the model object, respectively. Finally, we create a figure with two subplots using the subplot function and plot the adjusted R-squared and the sum of squared error using the plot function.

Note that this example assumes you have already fitted a regression model to your data using the fitlm function. If you have a different model or want to plot different statistics, you may need to adapt the code accordingly.

gistlibby LogSnag