# how to get aic from gapfill function?

2 views (last 30 days)
Peter Mills on 2 Jul 2018
Edited: Peter Mills on 2 Jul 2018
How do I get the values of aic for MATLAB gapfill function?
gn = 3;
mt = mtlb;
gl = randi([300 600],gn,1);
for kj = 1:gn
mt(kj*1000+randi(100)+(1:gl(kj))) = NaN;
end
lb = fillgaps(mt,4001,'aic');
How do I get the aic values that were used to optimize for model as outputs? How do I get the mae and rmse of the accuracy of each prediction of missing values?
I have tried a for loop of model order but it works out very slow.
order=1:4001;
MAEmetric=length(order);
RMSEmetric=length(order);
for i=1:4001
lb = fillgaps(mt,4001,order(i));
MAEmetric(i)=mae(mtlb,lb);
RMSEmetric(i)=rmse(mtlb,lb);
end
The following function is required for rmse
function r=rmse(data,estimate)
% Function to calculate root mean square error from a data vector or matrix
% and the corresponding estimates.
% Usage: r=rmse(data,estimate)
% Note: data and estimates have to be of same size
% Example: r=rmse(randn(100,100),randn(100,100));
% delete records with NaNs in both datasets first
I = ~isnan(data) & ~isnan(estimate);
data = data(I); estimate = estimate(I);
r=sqrt(sum((data(:)-estimate(:)).^2)/numel(data));

### Categories

Find more on Monte-Carlo 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!