'what formula does python statsmodels library uses to compute the bp_stat value (the Q value for the Box Pierce test)

As far as I know, the $Q$ statistics is computed with the formula

$Q = N \sum_{j=1}^K \rho_j^2$ I created an example where I compute $Q$ by hand and by using:\

sm.stats.acorr_ljungbox(X, lags=[20], return_df=True, boxpierce=True)

From the formula above I get $Q=98.90109886278258$, from statsmodels I get

lb_stat       lb_pvalue       bp_stat    bp_pvalue
102.988873  3.661944e-13    102.474971  4.530947e-13

I understand that bp_stat is the Box-pierce Q statistics, right?

In this case, I get 102.474971.

Does anyone know what formula is Python (statsmodels) using here?

Thanks. PD. I checked the manual and could not find it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source