HP Filter array size problems in Matlab 2023a

I am running the HP filter using the function built into Matlab for a vector with 100.000 rows.
Until last week, I was using Matlab 2021a on a computer with 8GB of RAM and the HP filtering worked flawlessly.
Since today, I'm running the same code using Matlab 2023a on a computer with 32GB of RAM and the HP filter runs into the error:
"Error using \
Requested 100002x100000 (74.5GB) array exceeds maximum array size preference (31.7GB). This might cause MATLAB to become unresponsive."
How is this possible and any idea what I can do about it?

 Accepted Answer

It would help to have the data and the code.
There are likely version differences, specifically that the arguments to the mldivide, \ functions in R2023a are a row vector and a column vector, where in R2021a, they were both (most likely) column vectors. (Without seeing the code, I cannot determine the reason for this change.) Probably the best approach is to manually transpose one of the vectors so that they are both the appropriate dimensions.

4 Comments

I see, I guess you are right.
This line of code replicates the issue.
[~,ufiltered] = hpfilter(ones(100000,1));
It's a shame because even when using a shorter series, the HP filter has become much more computationally expensive now.
Before, it was a matter of a second for a series with 100.000 periods.
Thank you!
The documentation for Y states ‘Each column of Y corresponds to a variable, and each row corresponds to an observation.’ so it wants a column vector (or data organised as column vectors), not a row vector.
According to Version History there were changes in R2022a and R2023a that may have affected the way the function operates. (I do not have the Econometrics Toolbox, so I have no experience with the hpfilter function.)
I thought you were referring to a highpass filter, such as would be produced by the Signal Processing Toolbox.
If my Answer helped you solve your problem, please Accept it!
.
I see, I copied the wrong line of code.
The problem is the same for a column vector.
[~,ufiltered] = hpfilter(ones(1,100000));
Nevertheless, I guess your answer solved it since it must come down to a version change. Disapponting to see such a big hit to performance of the hpfilter function.
Thank you for the quick responses.
As always, my pleasure!

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Release

R2023a

Community Treasure Hunt

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

Start Hunting!