How to determine if new data lies outside old prediction intervals

조회 수: 1 (최근 30일)
Marcus Glover
Marcus Glover 2024년 6월 21일
댓글: Marcus Glover 2024년 6월 21일
I have made a prediction model (using fit and predint) based on data in my table T. I know how to test if the existing data is outside the prediction interval, but I am unsure how to test new datapoints. I do not want to use the new data to make a new fit, I want to use the existing fit model and prediction intervals from the original data.
I am not sure how to generate a continuous function for the upper and lower interval.
Thanks.
load example_table.mat
T=sortrows(T,"Xdata");
x=T.Xdata;
y=T.Ydata;
fitresult = fit(x,y,'exp1');
pred = predint(fitresult,x,0.95);
plot(fitresult,x,y)
hold on
plot(x,pred,'m--')
legend({'Data','Fitted curve', 'Prediction intervals'},...
'FontSize',8,'Location','northwest')
%% See which rows fall outside of interval
outside = (y < pred(:, 1)) | (y > pred(:, 2));
rows_outside_interval = T(outside, :)
rows_outside_interval = 2x4 table
When Data1 Xdata Ydata ____________________ _____ _____ ______ 29-Feb-2024 07:07:54 -1.5 367.5 30.803 26-Feb-2024 21:05:07 18 389.4 9.4924
% Now I add a new row (that would fall outside), and want to test this against the existing
% prediction interval. Stuck here.
ht=height(T);
T(ht+1,:)=T(1,:);
T(ht+1,"Xdata")={300};
T(ht+1,"Ydata")={25};
T(ht+1,:)
ans = 1x4 table
When Data1 Xdata Ydata ____________________ _____ _____ _____ 03-May-2024 14:19:42 27 300 25
  댓글 수: 2
Tony
Tony 2024년 6월 21일
One idea is to find the pair of x points in the prediction interval series where the new data x lies in-between, assume the prediction is interpolated linearly in that interval, find the y value of the prediction intervals via linear interpolation for the data x, and then compare with your data y
Marcus Glover
Marcus Glover 2024년 6월 21일
Thanks, that is a good idea. I'll look at that and I could even fit the prediction line series itself and see which is faster as I may have a lot of new data at times.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Curve Fitting Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by