PARFOR Transparency violation error when using jcitest

4 views (last 30 days)
I am trying to run some simulations that involves using using Johnansen's test, but I always receive a transparency violation error. I prepared a minimal working example of the problem below. Is there something about the jcitest() function which makes it impossible to use in a parfor loop? Is there a way to solve that problem?
p = 4;
parfor i=1:2
y = [cumsum( randn(100,1) ), cumsum( randn(100,1) )];
[h1,~,~,~,~] = jcitest(y, 'model', 'H1*', 'lags', p-1, ...
'test', 'trace', 'display', 'off');
end
  3 Comments
Stéphane Surprenant
Stéphane Surprenant on 3 Nov 2020
I just opened another MATLAB process with everything clear in it. I got to the bottom of my script, launched this code exactly and got a transparency violation error. I joined a screen shot here. I have no idea why I have a transparency violation error and you don't, but I assure you that this exact code does produce such an error.
Stéphane Surprenant
Stéphane Surprenant on 16 Nov 2020
It turns out that if I define a function prior to the loop, say,
testing = @(y,p) jcitest(y, 'model', 'H1*', 'lags', p-1, ...
'test', 'trace', 'display', 'off');
and use it inside the loop, the problem completely goes away. I checked, double checked and triple checked... everything seem fine and it's going to massively help with my simulation study. I'll leave it here in case someone else runs into this weird problem.

Sign in to comment.

Answers (0)

Categories

Find more on Parallel Computing Toolbox in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!