0
$\begingroup$

I need help understanding what in what is wrong with what I am doing, or why is this happening. So basically I have two tables and one variable:

u=21000x1 - the original signal
y=21000x1 - signal corrupted by the noise
dt= 1^-4

I am trying to make a polynomial model based on ARX(I will have to try out ARMAX, BJ and OE also) In the System Identification toolbox, as I have imported and divided my data into Training and Validation sub-sets with ratio 75/25, I have then clicked on estimate>>>polynomial models>>>Order Selection>>>Estimate. As the bar-chart appeared I zoomed in on the bar that was marked in red(red was marked as best fit, MDL and AIC). I have selected this model and imported it(I also have imported a couple of other models from the bar-chart). But the calculated Fit in Model Output graph was 2.5% for best fit and even lower for other models, after that I tried randomly entering the values, but every model had very low fits, that were either on minus or slightly above the 0.

Then I wanted to check if really there are no best fits, and I have created the following program, that creates the models in a for loop, and checks their fit with compare function, but there are also problems, i.e. the models have:

  1. very low fits,
  2. the fit-percentage calculation varies from the fit-calculation in the System Identification Toolbox Model Output
  3. the fit percentege for my coded models plummeted to minus couple of thousands.

My Code:

min_wsp = 1; % Minimalna wartość współczynnika
max_wsp = 10; % Maksymalna wartość współczynnika

wsp_range = min_wsp:max_wsp;

num_wsp = 3;

combinations = combvec(wsp_range, wsp_range, wsp_range);

train_ratio = 0.75;
validation_ratio = 0.25;


num_samples = length(u);

num_train = round(train_ratio * num_samples);
num_validation = num_samples - num_train;

u_train = u(1:num_train);
y_train = y(1:num_train);

u_validation = u(num_train+1:end);
y_validation = y(num_train+1:end);

results = cell(size(combinations, 2), 5); % 5 kolumn: a1, a2, a3, % wariancji, % wariancji modelu


for i = 1:size(combinations, 2)
    a3 = combinations(1, i); % it represents nk from System Identification toolbox
    a2 = combinations(2, i); % it represents nb from System Identification toolbox
    a1 = combinations(3, i); % it represents na from System Identification toolbox
    
    data_train = [u_train, y_train];
    data_valid = [u_validation, y_validation];
    model = arx(data,[a1 a2 a3], 'Ts', dt)
    
    y_simulated_train = sim(model, data_train);
    
    y_simulated_validation = sim(model, data_valid);
    
    [output, percentage_fit] = compare(data_valid, model);
    
    fit_percentage_validation = percentage_fit
    
    disp(['Model ARX for a1=', num2str(a1), ', a2=', num2str(a2), ', a3=', num2str(a3)]);
    disp(['% Fit percentage (validation): ', num2str(percentage_fit), '%']);
    
    results{i, 1} = a1;
    results{i, 2} = a2;
    results{i, 3} = a3;
    results{i, 4} = fit_percentage_validation;
    
    disp('---------------------------------');
end

headers = {'a1', 'a2', 'a3', 'Fit percentage (validation)'};
xlswrite('wyniki.xlsx', headers, 'Sheet1', 'A1');
xlswrite('wyniki.xlsx', results, 'Sheet1', 'A2');
disp('Wyniki zapisane do pliku Excela (wyniki.xlsx).');

Question I don't understand why there are discrepancies, between the coded model and the model from System Identifcation Toolbox and I don't understand why the Fit-Percentages both in System Identification Toolbox and in the coded Models are so low:

1)

The most important:

Can someone explain to me why no model can fit my data?

Secondary priority:

Can someone please help me fix my code so it would give me identical results as the Polynomial Model in System Identification Toolbox, and explain why it does not give the identical results?

Link to download my data:(I used https://wetransfer.com/) https://we.tl/t-RgTCyjlkKx

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.