Plotting of a prediction line over scatterplot
Show older comments
Hello, I am trying to run this program and plot the prediction line "y" over the scatterplot of age and ulna data points. However, the prediction line results with "doubling back" sections. Any suggestions as to fixing this so that the prediction line is smooth?
%Program Hollingrsquaredulna.m
%Load data
load ulnaestimation.txt;
data = ulnaestimation;
age = data(:,1);
ulna = data(:,2);
%Set parameters
a = 24.18358006;
b = 1.214523208;
K = 13.94615385;
y = (((K-b)*(age.^2))./((a.^2)+(age.^2)))+b;
%Compute RSS
residuals = sqrt(ulna) - sqrt(y);
squareresiduals = residuals.^2;
RSS = sum(squareresiduals);
%Compute denominator
residuald = sqrt(ulna) - mean(sqrt(ulna));
squareresiduald = residuald.^2;
denominator = sum(squareresiduald);
%Compute rsquared
rsquared = 1 - (RSS/denominator)
%Set parameters and compute AIC
q = length(age);
variance = RSS/q;
k = 3;
AIC = (q*log(variance))+2*k
scatter(age,ulna)
hold on
plot(age,y)
Any help is greatly appreciated!!
Accepted Answer
More Answers (0)
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!