CDCgov / ww-inference-model

An in-development R package and a Bayesian hierarchical model jointly fitting multiple "local" wastewater data streams and "global" case count data to produce nowcasts and forecasts of both observations
https://cdcgov.github.io/ww-inference-model/
Apache License 2.0
16 stars 2 forks source link

Adding fixed geometric mean marginal variance correlation matrix correction function #52

Closed cbernalz closed 2 months ago

cbernalz commented 2 months ago

Goals

We want to add a function that ensured that the geometric mean marginal variance is fixed given the correlation matrix.

Context

This is regarding Dylan's issue on fixing the geometric mean marginal variance. The problem is here : Suppose we have that $\vec{X}\sim\text{MVN}(\vec{0},\Sigma)$. We want to be able to decompose $\Sigma$ into two components, a scalar measure of dispersion and a matrix to measure the correlation among elements in $\vec{X}$. We want to enforce that the correlated case to have the same degree of dispersion from the central value, here 0, as an uncorrelated case. So, for any given omega, some correlation matrix, we want to have a function that corrects omega, to make sure the scalar measure of dispersion has the same value, denote this as $\sigma_{\text{generalized}}^2$.

So to do this, we will look at the geometric mean marginal variance, that is related to the determinant. Which means that we want the $\text{det}(\Sigma) = \sigma_{\text{generalized}}^2$. To do this, let omega = $\Omega$. Also, let

$$ \Omega_{\text{normalized}} = \frac{\Omega}{\text{det}(\Omega)^{1/n}}. $$

And let some scalar $c = (\sigma{\text{generalized}}^2)^{1/n}$. Looking at the following decomposition of $\Sigma$, $\Sigma = c\Omega\{\text{normalized}}$, we get that :

$$ \text{det}(\Sigma) = \text{det}({c\Omega_{\text{normalized}}}) = \text{det}((\sigma{\text{generalized}}^2)^{1/n}\cdot\frac{\Omega}{\text{det}(\Omega)^{1/n}}) = \sigma{\text{generalized}}^2\cdot \frac{\text{det}(\Omega)}{\text{det}(\Omega)} = \sigma_{\text{generalized}}^2 $$

This determinant is known as the generalized variance. So we need a function that normalized omega into $\Omega_{\text{normalized}}$. Which will give us the the decomposition $\Sigma = c\Omega_{\text{normalized}}$, where $c = (\sigma_{\text{generalized}}^2)^{1/n}$ and $\vec{X}$ has a generalized variance of $c^n$.

Requirements