# How does tau squared (between-study variance) differ for network meta-analysis versus pairwise meta-analysis?

I'm currently trying to replicate a random effects network meta-analysis in Excel.

When estimating between-study heterogeneity, I can calculate Cochran's Q just fine via:

$$Q=\sum w_i(y_i-\hat\theta)^2$$

However, I run into issues when trying to calculate tau squared via:

$$\large\hat\tau^2=\frac{Q-(k-1)}{\sum w_i-\frac{\sum w_i^2}{\sum w_i}}$$

In this calculation, I replace $$(k-1)$$ with the degrees of freedom for the NMA, but still get a value for tau squared that is systematically smaller than the value produced by R (netmeta package) when validating the approach. I also get the correct number when I only include 2 comparators in the analysis.

Is there some other adjustment that needs to be made to this formula when there are more than 2 arms?

Thank you very much for your help in advance!