Plotting of a prediction line over scatterplot
显示 更早的评论
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!!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!