how to plot adjusted r squared , sum of squared error and fatatistic in matlab

To plot the adjusted R-squared, sum of squared error, and F-statistic in MATLAB, you will need to first compute these values using your data. Once you have the values, you can create a plot using the plot function.

Here's an example code snippet that demonstrates how to plot these metrics:

main.m
% Example data
y = [1, 2, 3, 4, 5];
y_pred = [1.2, 2.5, 3, 3.8, 5.1];

% Compute the residual sum of squares (SSR)
ssr = sum((y - y_pred).^2);

% Compute the total sum of squares (SST)
sst = sum((y - mean(y)).^2);

% Compute the sum of squares error (SSE)
sse = sst - ssr;

% Compute the adjusted R-squared
n = length(y);
p = 1; % Number of predictors in your model (e.g., 1 for simple linear regression)
r_squared = 1 - ssr/sst;
adjusted_r_squared = 1 - (1 - r_squared) * (n - 1) / (n - p - 1);

% Compute the F-statistic
mse = sse / (n - p - 1); % Mean squared error
f_statistic = (r_squared/p) / ((1 - r_squared)/(n - p - 1)); 

% Plot the metrics
figure;
plot(1:3, [adjusted_r_squared, sse, f_statistic], 'bo-');
xticks(1:3);
xticklabels({'Adjusted R-squared', 'Sum of Squared Error', 'F-Statistic'});
ylabel('Value');
title('Model Evaluation Metrics');
858 chars
31 lines

In this example, we have provided some dummy data for the observed y values and predicted y_pred values. You would need to replace these with your own data. Then, the code computes the SSR, SST, SSE, adjusted R-squared, and F-statistic. Finally, it creates a plot with the three metrics on the y-axis and their names on the x-axis.

Note that the code assumes a simple linear regression model with one predictor (p=1), but you can modify it accordingly for your specific model.

I hope this helps! Let me know if you have any further questions.

gistlibby LogSnag