polypredci

版本 1.0.0.0 (4.3 KB) 作者: Star Strider
POLYPREDCI calculates prediction intervals for ‘polyfit’ and ‘polyval’ curve fits.
594.0 次下载
更新时间 2016/6/11

查看许可证

POLYPREDCI takes the actual (x,y) data and polynomial order as arguments, uses ‘polyfit’ and ‘polyval’ to do the regression, then calculates and returns the fitted curve and the one-sided prediction confidence intervals on the fit. It uses the one-tailed t-statistic to calculate the confidence intervals. That calculation is entirely contained within POLYPREDCI, so the Statistics and Machine Learning Toolbox is not required. (It does not calculate confidence intervals for the parameters. See the related function ‘polyparci’ for that.) It is extensively internally documented.

POLYPREDCI follows published equations (in several references) to calculate the confidence intervals. They are close to but not the same as those calculated by ‘nlpredci’. I have no idea how ‘nlpredci’ calculates its confidence intervals, since they do not appear in the documentation that I can find.

POLYPREDCI has three required arguments and two optional arguments. The three required arguments are: ‘x’ (the independent data vector), ‘y’ (the dependent data vector), and ‘n’ (the polynomial order). The two optional arguments are ‘alfa’ (the desired level of statistical significance), and ‘xv’ (high-resolution vector for polynomial fit and confidence interval calculations). The default value for ‘alfa’ is 0.95.

POLYPREDCI was stimulated by a Question from ‘pocketHands’ on 2016 06 10, who thought ‘polyparci’ would do this. (It won’t!)

POLYPREDCI was created with R2016a but should work on all recent releases.

Example on using POLYPREDCI:

x = linspace(0, 2.5, 15); % Create Data
y = 2 + 3*x.^2 + 5*randn(size(x)); % Create Data

n = 3; % Polynomial Order
alfa = 0.99; % Desired Significance
xv = linspace(min(x), max(x))'; % Optional High-Resolution Vector
[ p, yhat, ci ] = polypredci( x, y, n, alfa, xv ); % Define Both ‘alfa’ & ‘xv’
% [ p, yhat, ci ] = polypredci( x, y, n, alfa ); % Use ‘alfa’
% [ p, yhat, ci ] = polypredci( x, y, n ); % Use Defaults

figure(1)
plot(x, y, 'bp')
hold on
if length(yhat) == length(x)
plot(x, yhat, '--r')
plot(x, yhat+ci, '--g')
plot(x, yhat-ci, '--g')
elseif length(yhat) == length(xv)
plot(xv, yhat, '--r')
plot(xv, yhat+ci, '--g')
plot(xv, yhat-ci, '--g')
end
hold off
grid

引用格式

Star Strider (2024). polypredci (https://www.mathworks.com/matlabcentral/fileexchange/57630-polypredci), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2016a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0