0

Recently, I posted this question (When is the Law of Large Numbers not True?) where I was interested in creating an example where the Law of Large Numbers (LLN) DOES NOT apply.

Part 1: In short, the idea I came up with was to create a correlated random variable such that the IID/finite variance assumption required for LLN is not met:

Suppose there are $N$ random variables with each pairwise covariance $Cov(X_i, X_j) = c_{ij}$. Note that there will be $\frac{N(N-1)}{2}$ covariance terms.

We can redefine $M = \sum_{{i=1}}^{N} \frac{X_i}{N}$ and the variance of M as:

$$Var(M) = Var\left(\frac{X_1 + X_2 + ... + X_N}{N}\right) = \frac{1}{N^2} \left[ Var(X_1) + Var(X_2) + ... + Var(X_N) + 2Cov(X_1, X_2) + Cov(X_1, X_3) + 2Cov(X_2, X_3) + .... \right] = \frac{1}{N^2} \left( N\sigma^2 + \sum_{{i=1}}^{n} \sum_{{j \neq i, j=1}}^{n} Cov(X_i, X_j) \right)$$

We can apply this result within Chebyshev's Inequality:

$$\lim_{{n \to \infty}} P\left( \left| \overline{X_n} - \mu \right| \geq \epsilon \right) \leq \frac{\frac{1}{N^2} \left( N\sigma^2 + \sum_{{i=1}}^{N} \sum_{{j \neq i, j=1}}^{N} Cov(X_i, X_j) \right)}{\epsilon^2} $$

And from here, it is uncertain whether:

$$\lim_{{N \to \infty}} \sum_{{i=1}}^{N} \sum_{{j \neq i, j=1}}^{N} \frac{Cov(X_i, X_j)}{N^2} = 0 $$

Therefore, in the above case, the Weak Law of Large Numbers does not hold.

My Question: In the previous question (i.e. When is the Law of Large Numbers not True?), I was told that my "example is too broad to say one way or the other. For different choices of distributions (and thus different $c_{ij}$'s, we may have CLT or not have CLT (similarly WLLN)."

Part 2: To make my example more concrete, I thought that perhaps I could see how this example behaves when the correlation increases. For a given correlation (rho) value, random samples are generated from a correlated Normal Distribution (with mean = 0) and the sample means is calculated for each random sample (sample size for each sample changes). This is then repeated for different values of rho.

Here is a quick recap of the Multivariate Normal Distribution:

$$f(\mathbf{x} | \boldsymbol{\mu}, \boldsymbol{\Sigma}) = \frac{1}{\sqrt{(2\pi)^k |\boldsymbol{\Sigma}|}} \exp\left(-\frac{1}{2} (\mathbf{x} - \boldsymbol{\mu})^T \boldsymbol{\Sigma}^{-1} (\mathbf{x} - \boldsymbol{\mu})\right)$$

where:

  • $\mathbf{x} = [x_1, x_2, ..., x_k]^T$ is a $k$-dimensional real vector.

  • $\boldsymbol{\mu} = [\mu_1, \mu_2, ..., \mu_k]^T$ is the mean vector where $\boldsymbol{\mu} \in \mathbb{R}^k$.

  • $\boldsymbol{\Sigma}$ is the covariance matrix where $\boldsymbol{\Sigma} \in \mathbb{R}^{k \times k}$.

  • The covariance matrix $\boldsymbol{\Sigma}$ is defined as:

$$\boldsymbol{\Sigma} = \begin{bmatrix} \sigma_{1}^2 & \sigma_{12} & \cdots & \sigma_{1k} \\ \sigma_{21} & \sigma_{2}^2 & \cdots & \sigma_{2k} \\ \vdots & \vdots & \ddots & \vdots \\ \sigma_{k1} & \sigma_{k2} & \cdots & \sigma_{k}^2 \end{bmatrix}$$

where $\sigma_{ii}$ is the variance of the $i$-th dimension and $\sigma_{ij}$ (or $\sigma_{ji}$) is the covariance between the $i$-th and $j$-th dimensions.

The correlation between the $i$-th and $j$-th dimensions is given by:

$$\rho_{ij} = \frac{\sigma_{ij}}{\sqrt{\sigma_{ii} \sigma_{jj}}}$$

Part 3: I made the following simulation using the R programming language for a 2 dimensional normal distribution:

set.seed(123)

mu <- 0 sigma <- 1

N <- 500

correlations <- seq(0, 1, by = 0.1)

sample_means_df <- data.frame()

for (rho in correlations) { # Generate two sets of random numbers with the specified correlation Sigma <- matrix(c(sigma^2, rhosigma^2, rhosigma^2, sigma^2), nrow=2) data <- MASS::mvrnorm(N, mu = c(mu, mu), Sigma = Sigma)

sample_means &lt;- numeric(N)


for (n in 1:N) {
    sample_means[n] &lt;- mean(data[1:n,])
}


sample_means_df &lt;- rbind(sample_means_df, data.frame(SampleSize = 1:N, SampleMean = sample_means, Correlation = rho))

}

library(ggplot2) ggplot(sample_means_df, aes(x = SampleSize, y = SampleMean, color = Correlation)) + geom_line() + geom_hline(aes(yintercept = mu), color = "black") + scale_color_gradientn(colors = rainbow(5), name = "Correlation") + labs(x = "Sample Size", y = "Sample Mean", title = "Sample Mean vs. Sample Size for Different Correlations", subtitle = paste("Population Mean:", mu)) + theme_bw()

enter image description here

In the above plot, empirically, we can see that for larger correlations values (i.e. purple, blue colors), the sample mean takes a much longer time to approach the true mean compared to smaller correlations values (i.e. red, yellow).

Mathematically, this suggests that the limit in the presence of larger correlation values takes longer to approach 0. Thus:

  • Is my understanding of this correct?
  • Have I fully defined an example where LLN does not apply?

Thanks!

Note: A comparison of the 0 correlation case vs the 0.95 correlation case (0 correlation approaches true value faster)

set.seed(123)

mu <- 0 sigma <- 1

N <- 1000

correlations <- c(0, 0.95)

correlation sample_means_df <- data.frame()

for (rho in correlations) { correlation Sigma <- matrix(c(sigma^2, rhosigma^2, rhosigma^2, sigma^2), nrow=2) data <- MASS::mvrnorm(N, mu = c(mu, mu), Sigma = Sigma)

sample_means &lt;- numeric(N)


for (n in 1:N) {
    sample_means[n] &lt;- mean(data[1:n,])
}


sample_means_df &lt;- rbind(sample_means_df, data.frame(SampleSize = 1:N, SampleMean = sample_means, Correlation = rho))

}

library(ggplot2) ggplot(sample_means_df, aes(x = SampleSize, y = SampleMean, color = as.factor(Correlation))) + geom_line() + geom_hline(aes(yintercept = mu), color = "black") + scale_color_manual(values = c("red", "blue"), name = "Correlation") + labs(x = "Sample Size", y = "Sample Mean", title = "Sample Mean vs. Sample Size for Different Correlations", subtitle = paste("Population Mean:", mu)) + theme_bw()

enter image description here

stats_noob
  • 3,112
  • 4
  • 10
  • 36
  • The law of large numbers is dependent on specific conditions under which it holds. So, not the law of large numbers can be refuted , but the wrong formal application of it , if its conditions are not satisfied. – Peter Dec 12 '23 at 18:57
  • 1
    @Peter: thank you for your reply! This is exactly what I am interested in. I want to create an example where the conditions required for LLN to work are not met... and then physically observe LLN not working. Have I done this correctly? thank you so much! – stats_noob Dec 12 '23 at 18:59
  • This is not simulating correlated random variables... you are only using a bivariate normal and then averaging the two samples. So the only thing turning up the correlation does is increases the variance of the independent normals you're simulating from 1/2 to 1 – spaceisdarkgreen Dec 12 '23 at 19:50
  • The easiest way to simulate data where the LLN would fail to hold is the Cauchy distribution. At each iteration $t$, let $X_t$ and $Y_t$ be two independent standard Normals, and let $C_t = X_t/Y_t$ be their ratio. Then the average of these $C_t$'s does not converge to its expectation. – Matthew Esmaili Dec 12 '23 at 19:53
  • @ Matthew Esmaili: thank you for your reply! Is there any way to modify my question to such that LLN will not apply? – stats_noob Dec 12 '23 at 20:07
  • 1
    @stats_noob If you cumulatively sum a vector of independent normals (i.e. make a random walk), LLN won't hold on the resulting vector. There are two assumptions typical of LLNs being violated 1) correlations don't decay out with time 2) marginal variances are increasing relatively quickly with time – spaceisdarkgreen Dec 12 '23 at 22:16
  • @ spaceisdarkgreen: please see the updates. I believe that I am simulating correlated random variables (see my explanation in Part 2). Thanks! – stats_noob Dec 13 '23 at 02:29
  • 1
    @stats_noob I'm no R expert, but the way I read this, "data" is an Nx2 matrix of N independent draws from a bivariate normal, and "mean(data[1:n,])" is the mean of the initial nx2 submatrix. Or in other words, the mean of n independent samples from the distribution given by the mean of two normals that are jointly distributed with the given correlation. The correlation of the bivariate normal affects the variance of the mean of the pair... higher correlations give a higher variance, so that is probably why you are seeing slower convergence at higher "correlation". – spaceisdarkgreen Dec 13 '23 at 02:39
  • 1
    @stats_noob On the other hand, if you just unrolled the Nx2 rowwise into a 2Nx1, then I guess that would be simulating a correlated sequence (albeit with a bit of an odd corr structure that depends on whether it's an even or odd time step) and you'd see the same long-run behavior, just with finer grain on the x axis. Note that the LLN most definitely holds here though, regardless of how we think about it, as your plot suggests, even when "correlation" =1 – spaceisdarkgreen Dec 13 '23 at 02:50
  • @ spaceisdarkgreen: thank you so much for your replies! are you familiar with python? I can try to write this in Python for you if you would like. – stats_noob Dec 13 '23 at 02:52
  • my apologies, i just realized this: each individual sample is correlated within itself... but pairs of samples are independent from each other (i.e. uncorrelated). I think the math example I created might be correct, but the computer simulation does not correspond to the math example. – stats_noob Dec 13 '23 at 05:08

0 Answers0