How to use chi2gof in system identification white residual test?
1 view (last 30 days)
Show older comments
Tarek Hajj Shehadi
on 22 May 2022
Answered: Rajiv Singh
on 31 May 2022
I have a BJ model that I am trying to validate using flexibility tests. The chi2gof sounds like a good option.
Goal: I want to apply white null hypotheses test to check whether the residual is white or not.
I will show you how I applied it:
First create the BJ model using training data
BJ_Mod=bj(train_dat,[8 7 1 1 0]);
Now we compute the correlation of the residual on the validating data
res_BJ = resid(val_dat,BJ_Mod); %val_dat (contains 411 points)
res_out_BJ = res_BJ.OutputData;
[res_corr_BJ, lags_BJ] = xcorr(res_out_BJ, 'unbiased');
corr_0_BJ = max(res_corr_BJ); %Compute residual at origin
Now define I wish to now apply chi2 test on
[chi_gof,p,stat] = chi2gof(res_corr_BJ/corr_0_BJ,'Alpha',0.05);
I received the following as output:
chi_gof = 1
p=9.0250e-05
chi2stat: 18.6259
df: 2
edges: [-0.2853 -0.1567 -0.0282 0.1003 0.2288 1.0000]
O: [68 222 372 154 5]
E: [63.4314 255.3488 341.3373 142.0305 18.8521]
Question: I am afraid that the results might be incorrect based on the way I implemented the algorithm. What I received from the output (as shown above) that my model fails this hypotheses. The main concern is whether this algorithm makes sense. I hope someone can check this code and confirm whether this is the way to do white null test using chi2 criteria on a system identification model.
Furthermore, do we apply this test on just the validating points or on all the data points of the set?
0 Comments
Accepted Answer
Rajiv Singh
on 31 May 2022
The approach looks fine to me in principle, hard to say more without looking at the data. One thing you can try is call RESID without output arguments. This will plot the residual with confidence bounds based on chi2 stats on the prediction errors. If the residual curve is within the bounds, you basiclaly have uncorrelated, white residuals.
0 Comments
More Answers (0)
See Also
Categories
Find more on Linear Model Identification 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!