how to plot adjusted r squared , sum of squared error and f statistic separately in matlab

First, let's generate some data to demonstrate the plotting of adjusted R-squared, sum of squared error, and F-statistic separately.

main.m
% Generate random data
x = 0:0.1:5;
y = 2*x + 1 + 0.5*sin(x) + randn(size(x));

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

% Get the adjusted R-squared, sum of squared error, and F-statistic
adj_r_squared = lm.Rsquared.Adjusted;
sse = sum(lm.Residuals.Raw.^2);
f_statistic = lm.FStat.pValue;

% Plot adjusted R-squared
figure;
bar(adj_r_squared);
title('Adjusted R-squared');
xlabel('Model');
ylabel('Value');

% Plot sum of squared error
figure;
bar(sse);
title('Sum of Squared Error');
xlabel('Model');
ylabel('Value');

% Plot F-statistic
figure;
bar(f_statistic);
title('F-Statistic');
xlabel('Model');
ylabel('Value');
621 chars
33 lines

Make sure you have the Statistics and Machine Learning Toolbox for Matlab installed in order to use the fitlm function.

gistlibby LogSnag