- Ensure that the input data ‘Con_mat’ is correctly formatted and appropriate for the ARIMA model. It should be a non-empty column vector of numeric values.
- Verify that the parameter values used for the ARIMA model are valid. For example, check if the order of the AR and MA components (‘p’ and ‘q’) is within a reasonable range.
- Try adjusting the model order ‘p’ or using a different model specification that better suits your data.
How to set p and q in ARMA model?
7 views (last 30 days)
Show older comments
Hi,
I'm pretty new to time-series forcasting, and I wanted to use an ARMA model for my measurement data using the BIC code that is given on Matchwork as follow, however, I got an error no matter how time series I have used. Also, I was wondering how the order 0 for p and q could be determined in the output, since we can define the matrix with 0 row and column, so any help would be highly appreciated.
code
LogL = zeros(4,4); % Initialize
PQ = zeros(4,4);
for p = 1:4
for q = 1:4
Mdl = arima(p,0,q);
[EstMdl,~,LogL(p,q)] = estimate(Mdl,Con_mat,'Display','off');
PQ(p,q) = p + q;
end
end
logL = LogL(:);
pq = PQ(:);
[~,bic] = aicbic(logL,pq+1,100);
BIC = reshape(bic,4,4)
minBIC = min(BIC,[],'all')
[minP,minQ] = find(minBIC == BIC)
Error
Error using BIC_Predictor (line 6)
Estimated variance model is invalid.
Caused by:
Error using arima/validateModel (line 1152)
Nonseasonal autoregressive polynomial is unstable.
Regards
0 Comments
Answers (1)
Karanjot
on 26 Sep 2023
Hi Hamed,
I understand that want to debug the following error in your ARMA model:
%{
Error using BIC_Predictor (line 6)
Estimated variance model is invalid.
Caused by:
Error using arima/validateModel (line 1152)
Nonseasonal autoregressive polynomial is unstable.
%}
Please provide the data / variables associated with the code you shared. Meanwhile, I recommend observing the following:
The error is resolved by ensuring the above points. Here’s an example:
Con_mat = zeros(10,1); % Initialize as column vector appropriate for the model
LogL = zeros(4,4); % Initialize
PQ = zeros(4,4);
for p = 1:4
for q = 1:4
Mdl = arima(p,0,q);
[EstMdl,~,LogL(p,q)] = estimate(Mdl,Con_mat,'Display','off');
PQ(p,q) = p + q;
end
end
logL = LogL(:);
pq = PQ(:);
[~,bic] = aicbic(logL,pq+1,100);
BIC = reshape(bic,4,4)
minBIC = min(BIC,[],'all')
[minP,minQ] = find(minBIC == BIC)
To learn more about the ‘arima’ function, please refer to the below documentation:
I hope this helps!
0 Comments
See Also
Categories
Find more on Conditional Mean Models 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!