lingam icon indicating copy to clipboard operation
lingam copied to clipboard

Improper bootstrap sampling in VARLiNGAM

Open paullabonne opened this issue 8 months ago • 3 comments

Hi @ikeuchi-screen,

I think the bootstrap method in VARLiNGAM uses the residuals from each iteration to resample rather than resampling from the original residuals: https://github.com/cdt15/lingam/blob/1495ba515024a27d0ea0cabbc2e15d4aee76823a/lingam/var_lingam.py#L155

As a result the draws are not independent.

Happy to send a pull request for that as well if you wish.

paullabonne avatar May 15 '25 09:05 paullabonne

Hi @paullabonne ,

I'm sorry, but I don't understand the points of the feedback. Could you please explain what code modifications are necessary?

Thank you for the pull request! https://github.com/cdt15/lingam/pull/162

ikeuchi-screen avatar May 15 '25 10:05 ikeuchi-screen

In each draw of the bootstrap, the model is re-estimated with https://github.com/cdt15/lingam/blob/1495ba515024a27d0ea0cabbc2e15d4aee76823a/lingam/var_lingam.py#L173

and if I am correct it is the residuals from this estimation which are used for resampling in https://github.com/cdt15/lingam/blob/1495ba515024a27d0ea0cabbc2e15d4aee76823a/lingam/var_lingam.py#L155

So each draw is dependent on the previous draw. So for instance if one round of estimation is bad it will contaminate all the following draws. My understanding of bootstrapping is that each draw should be independent and sampled from the original residuals, which here should be the one from https://github.com/cdt15/lingam/blob/1495ba515024a27d0ea0cabbc2e15d4aee76823a/lingam/var_lingam.py#L145

Storing the residuals from L145 and using those in resample() instead of self._residuals should work, see https://github.com/cdt15/lingam/commit/e8196a7a6db5e2d0d105f9b865db3f9f894db628

paullabonne avatar May 15 '25 10:05 paullabonne

Thanks for the detailed explanation. I now understand what needs to be corrected!

ikeuchi-screen avatar May 16 '25 10:05 ikeuchi-screen