⚡ Bolt: Avoid redundant matrix inversions in Vuong test#16
Conversation
- Updated `calcAB` to return `Ainv` (the asymptotic covariance matrix directly, without inversion) and updated the `B` matrix construction. - Updated `calcLambda` to use `Ainv` directly, removing `chol2inv(chol(AB1$A))` and `chol2inv(chol(AB2$A))` and avoiding redundant matrix inversions.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Eliminated redundant and expensive matrix inversions when calculating Vuong's test statistic.
calcABnow preserves and returns the covariance matrixtmpvcasAinvdirectly, avoiding thechol2inv(chol(tmpvc))call, which was subsequently being inverted again incalcLambdaviachol2inv(chol(AB$A)).🎯 Why: Calculating the inverse of an inverse matrix effectively cancels itself out, simply yielding the original matrix. Matrix inversions are$O(K^3)$ operations, meaning the performance cost scales significantly as the parameter space grows. The codebase was computing these unnecessary inversions 4 times per
vuongtest()call (two for each model). By removing them, the test will be considerably faster without any loss in accuracy, and it also prevents floating-point precision loss.📊 Impact: Reduces matrix inversions from 4 to 0.
🔬 Measurement: Execute
vuongtest()locally with complex models. Execution time will scale noticeably better than before for high numbers of variables.PR created automatically by Jules for task 12340760796224175654 started by @seonghobae