Skip to main content
added 40 characters in body
Source Link
Michael Hardy
  • 11.1k
  • 1
  • 33
  • 56

Question edited with the correct code - apologies

I have observed a somewhat puzzling negative correlation.

In code (R) (mathematical formulation below)

set.seed(123)
N=1000
R1=vector('double',N)
R2=vector('double',N)
x=rnorm(100)
for (k in 1:N){
  y1=x+rnorm(100)
  y2=x+rnorm(100)
  X=c(x,x)
  Y=c(y1,y2)
  R1[k]=cor(y1,y2)
  R2[k]=var(X)/var(Y)  
}
cor.test(R1,R2)

    Pearson's product-moment correlation

data:  R1 and R2
t = -7.2284, df = 998, p-value = 9.704e-13
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.2811533 -0.1633130
sample estimates:
       cor 
-0.2230479 

It turns out that R1 and R2 are very close to each other but negatively correlated. This is only the case when x is kept out of the loop (i.e. fix across experiments).

Would you know why?

Mathematical formulation

Let

\begin{align} & x_i \sim \operatorname N(0,1),\quad i=1,\ldots,100 \quad (\sim\text{indicates i.i.d.}) \\[6pt] & y_{1,i} = x_i + u_i, \quad u_i\sim\operatorname N(0,1) \\[6pt] & y_{2,i} = x_i + v_i, \quad v_i\sim\operatorname N(0,1) \end{align}

We can arrange these random variables as vectors:

\begin{align} & \mathbf x = [x_i]_{i=1,\ldots,100} \\[6pt] & \mathbf y_1 = [y_{1,i}]_{i=1,\ldots,100} \\[6pt] & \mathbf y_2 = [y_{2,i}]_{i=1,\ldots,100} \end{align}

And we now create the concatenated vectors as follows:

\begin{align} & \mathbf X = [\mathbf x, \mathbf x] \\[6pt] & \mathbf Y = [\mathbf y_1, \mathbf y_2] \end{align}

It turns out that the Pearson's correlation between y1$\mathbf y_1$ and y2$\mathbf y_2$ is very close to Var(X)/Var(Y).$\operatorname{Var}(X)/\operatorname{Var}(Y).$ However, the two are negatively correlated when we repeat the process of realising y1,i,$y_{1,i}$ and yi$y_{2,i}$ while maintaining xi$x_i$ constant across realisations.

Would you know why?

Question edited with the correct code - apologies

I have observed a somewhat puzzling negative correlation.

In code (R) (mathematical formulation below)

set.seed(123)
N=1000
R1=vector('double',N)
R2=vector('double',N)
x=rnorm(100)
for (k in 1:N){
  y1=x+rnorm(100)
  y2=x+rnorm(100)
  X=c(x,x)
  Y=c(y1,y2)
  R1[k]=cor(y1,y2)
  R2[k]=var(X)/var(Y)  
}
cor.test(R1,R2)

    Pearson's product-moment correlation

data:  R1 and R2
t = -7.2284, df = 998, p-value = 9.704e-13
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.2811533 -0.1633130
sample estimates:
       cor 
-0.2230479 

It turns out that R1 and R2 are very close to each other but negatively correlated. This is only the case when x is kept out of the loop (i.e. fix across experiments).

Would you know why?

Mathematical formulation

Let

\begin{align} & x_i \sim \operatorname N(0,1),\quad i=1,\ldots,100 \quad (\sim\text{indicates i.i.d.}) \\[6pt] & y_{1,i} = x_i + u_i, \quad u_i\sim\operatorname N(0,1) \\[6pt] & y_{2,i} = x_i + v_i, \quad v_i\sim\operatorname N(0,1) \end{align}

We can arrange these random variables as vectors:

\begin{align} & \mathbf x = [x_i]_{i=1,\ldots,100} \\[6pt] & \mathbf y_1 = [y_{1,i}]_{i=1,\ldots,100} \\[6pt] & \mathbf y_2 = [y_{2,i}]_{i=1,\ldots,100} \end{align}

And we now create the concatenated vectors as follows:

\begin{align} & \mathbf X = [\mathbf x, \mathbf x] \\[6pt] & \mathbf Y = [\mathbf y_1, \mathbf y_2] \end{align}

It turns out that the Pearson's correlation between y1 and y2 is very close to Var(X)/Var(Y). However, the two are negatively correlated when we repeat the process of realising y1,i, and yi while maintaining xi constant across realisations.

Would you know why?

Question edited with the correct code - apologies

I have observed a somewhat puzzling negative correlation.

In code (R) (mathematical formulation below)

set.seed(123)
N=1000
R1=vector('double',N)
R2=vector('double',N)
x=rnorm(100)
for (k in 1:N){
  y1=x+rnorm(100)
  y2=x+rnorm(100)
  X=c(x,x)
  Y=c(y1,y2)
  R1[k]=cor(y1,y2)
  R2[k]=var(X)/var(Y)  
}
cor.test(R1,R2)

    Pearson's product-moment correlation

data:  R1 and R2
t = -7.2284, df = 998, p-value = 9.704e-13
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.2811533 -0.1633130
sample estimates:
       cor 
-0.2230479 

It turns out that R1 and R2 are very close to each other but negatively correlated. This is only the case when x is kept out of the loop (i.e. fix across experiments).

Would you know why?

Mathematical formulation

Let

\begin{align} & x_i \sim \operatorname N(0,1),\quad i=1,\ldots,100 \quad (\sim\text{indicates i.i.d.}) \\[6pt] & y_{1,i} = x_i + u_i, \quad u_i\sim\operatorname N(0,1) \\[6pt] & y_{2,i} = x_i + v_i, \quad v_i\sim\operatorname N(0,1) \end{align}

We can arrange these random variables as vectors:

\begin{align} & \mathbf x = [x_i]_{i=1,\ldots,100} \\[6pt] & \mathbf y_1 = [y_{1,i}]_{i=1,\ldots,100} \\[6pt] & \mathbf y_2 = [y_{2,i}]_{i=1,\ldots,100} \end{align}

And we now create the concatenated vectors as follows:

\begin{align} & \mathbf X = [\mathbf x, \mathbf x] \\[6pt] & \mathbf Y = [\mathbf y_1, \mathbf y_2] \end{align}

It turns out that the Pearson's correlation between $\mathbf y_1$ and $\mathbf y_2$ is very close to $\operatorname{Var}(X)/\operatorname{Var}(Y).$ However, the two are negatively correlated when we repeat the process of realising $y_{1,i}$ and $y_{2,i}$ while maintaining $x_i$ constant across realisations.

Would you know why?

added 40 characters in body
Source Link
Michael Hardy
  • 11.1k
  • 1
  • 33
  • 56

Question edited with the correct code - apologies

I have observed a somewhat puzzling negative correlation.

In code (R) (mathematical formulation below)

set.seed(123)
N=1000
R1=vector('double',N)
R2=vector('double',N)
x=rnorm(100)
for (k in 1:N){
  y1=x+rnorm(100)
  y2=x+rnorm(100)
  X=c(x,x)
  Y=c(y1,y2)
  R1[k]=cor(y1,y2)
  R2[k]=var(X)/var(Y)  
}
cor.test(R1,R2)

    Pearson's product-moment correlation

data:  R1 and R2
t = -7.2284, df = 998, p-value = 9.704e-13
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.2811533 -0.1633130
sample estimates:
       cor 
-0.2230479 

It turns out that R1 and R2 are very close to each other but negatively correlated. This is only the case when x is kept out of the loop (i.e. fix across experiments).

Would you know why?

Mathematical formulation

Let

xi ~ N(0,1), i=1,...,100 (~ indicates i.i.d.)

y1,i = xi+ui, ui ~ N(0,1)

y2,i = xi+vi, vi ~ N(0,1)\begin{align} & x_i \sim \operatorname N(0,1),\quad i=1,\ldots,100 \quad (\sim\text{indicates i.i.d.}) \\[6pt] & y_{1,i} = x_i + u_i, \quad u_i\sim\operatorname N(0,1) \\[6pt] & y_{2,i} = x_i + v_i, \quad v_i\sim\operatorname N(0,1) \end{align}

We can arrange these random variables as vectors:

x=[xi]i=1,...,100

y1=[y1,i]i=1,...,100

y2=[y2,i]i=1,...,100\begin{align} & \mathbf x = [x_i]_{i=1,\ldots,100} \\[6pt] & \mathbf y_1 = [y_{1,i}]_{i=1,\ldots,100} \\[6pt] & \mathbf y_2 = [y_{2,i}]_{i=1,\ldots,100} \end{align}

And we now create the concatenated vectors as follows:

X=[x,x]

Y=[y1,y2]\begin{align} & \mathbf X = [\mathbf x, \mathbf x] \\[6pt] & \mathbf Y = [\mathbf y_1, \mathbf y_2] \end{align}

It turns out that the Pearson's correlation between y1 and y2 is very close to Var(X)/Var(Y). However, the two are negatively correlated when we repeat the process of realising y1,i, and yi while maintaining xi constant across realisations.

Would you know why?

Question edited with the correct code - apologies

I have observed a somewhat puzzling negative correlation.

In code (R) (mathematical formulation below)

set.seed(123)
N=1000
R1=vector('double',N)
R2=vector('double',N)
x=rnorm(100)
for (k in 1:N){
  y1=x+rnorm(100)
  y2=x+rnorm(100)
  X=c(x,x)
  Y=c(y1,y2)
  R1[k]=cor(y1,y2)
  R2[k]=var(X)/var(Y)  
}
cor.test(R1,R2)

    Pearson's product-moment correlation

data:  R1 and R2
t = -7.2284, df = 998, p-value = 9.704e-13
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.2811533 -0.1633130
sample estimates:
       cor 
-0.2230479 

It turns out that R1 and R2 are very close to each other but negatively correlated. This is only the case when x is kept out of the loop (i.e. fix across experiments).

Would you know why?

Mathematical formulation

Let

xi ~ N(0,1), i=1,...,100 (~ indicates i.i.d.)

y1,i = xi+ui, ui ~ N(0,1)

y2,i = xi+vi, vi ~ N(0,1)

We can arrange these random variables as vectors:

x=[xi]i=1,...,100

y1=[y1,i]i=1,...,100

y2=[y2,i]i=1,...,100

And we now create the concatenated vectors as follows:

X=[x,x]

Y=[y1,y2]

It turns out that the Pearson's correlation between y1 and y2 is very close to Var(X)/Var(Y). However, the two are negatively correlated when we repeat the process of realising y1,i, and yi while maintaining xi constant across realisations.

Would you know why?

Question edited with the correct code - apologies

I have observed a somewhat puzzling negative correlation.

In code (R) (mathematical formulation below)

set.seed(123)
N=1000
R1=vector('double',N)
R2=vector('double',N)
x=rnorm(100)
for (k in 1:N){
  y1=x+rnorm(100)
  y2=x+rnorm(100)
  X=c(x,x)
  Y=c(y1,y2)
  R1[k]=cor(y1,y2)
  R2[k]=var(X)/var(Y)  
}
cor.test(R1,R2)

    Pearson's product-moment correlation

data:  R1 and R2
t = -7.2284, df = 998, p-value = 9.704e-13
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.2811533 -0.1633130
sample estimates:
       cor 
-0.2230479 

It turns out that R1 and R2 are very close to each other but negatively correlated. This is only the case when x is kept out of the loop (i.e. fix across experiments).

Would you know why?

Mathematical formulation

Let

\begin{align} & x_i \sim \operatorname N(0,1),\quad i=1,\ldots,100 \quad (\sim\text{indicates i.i.d.}) \\[6pt] & y_{1,i} = x_i + u_i, \quad u_i\sim\operatorname N(0,1) \\[6pt] & y_{2,i} = x_i + v_i, \quad v_i\sim\operatorname N(0,1) \end{align}

We can arrange these random variables as vectors:

\begin{align} & \mathbf x = [x_i]_{i=1,\ldots,100} \\[6pt] & \mathbf y_1 = [y_{1,i}]_{i=1,\ldots,100} \\[6pt] & \mathbf y_2 = [y_{2,i}]_{i=1,\ldots,100} \end{align}

And we now create the concatenated vectors as follows:

\begin{align} & \mathbf X = [\mathbf x, \mathbf x] \\[6pt] & \mathbf Y = [\mathbf y_1, \mathbf y_2] \end{align}

It turns out that the Pearson's correlation between y1 and y2 is very close to Var(X)/Var(Y). However, the two are negatively correlated when we repeat the process of realising y1,i, and yi while maintaining xi constant across realisations.

Would you know why?

added 116 characters in body
Source Link

Question edited with the correct code - apologies

I have observed a somewhat puzzling negative correlation.

In code (R) (mathematical formulation below)

set.seed(123)
N=1000
R1=vector('double',N)
R2=vector('double',N)
x=rnorm(100)
for (k in 1:1000N){
  y1=x+0.5*rnormy1=x+rnorm(100)
  y2=x+0.5*rnormy2=x+rnorm(100)
  X=c(x,x)
  Y=c(y1,y2)
  R1[k]=cor(y1,y2)
  R2[k]=var(X)/var(Y)  
}
cor.test(R1,R2)
 
    Pearson's product-moment correlation

data:  R1 and R2
t = -47.88442284, df = 998, p-value = 19.208e704e-0613
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.212774532811533 -0.091672191633130
sample estimates:
       cor 
-0.15279692230479 

It turns out that R1 and R2 are very close to each other but negatively correlated. This is only the case when x is kept out of the loop (i.e. fix across experiments).

Would you know why?

Mathematical formulation

Let

xi ~ N(0,1), i=1,...,100 (~ indicates i.i.d.)

y1,i = xi+ui, ui ~ N(0,1)

y2,i = xi+vi, vi ~ N(0,1)

We can arrange these random variables as vectors:

x=[xi]i=1,...,100

y1=[y1,i]i=1,...,100

y2=[y2,i]i=1,...,100

And we now create the concatenated vectors as follows:

X=[x,x]

Y=[y1,y2]

It turns out that the Pearson's correlation between y1 and y2 is very close to Var(X)/Var(Y). However, the two are negatively correlated when we repeat the process of realising y1,i, and yi while maintaining xi constant across realisations.

Would you know why?

I have observed a somewhat puzzling negative correlation.

In code (R) (mathematical formulation below)

x=rnorm(100)
for (k in 1:1000){
  y1=x+0.5*rnorm(100)
  y2=x+0.5*rnorm(100)
  X=c(x,x)
  Y=c(y1,y2)
  R1[k]=cor(y1,y2)
  R2[k]=var(X)/var(Y)  
}
cor.test(R1,R2)
    Pearson's product-moment correlation

data:  R1 and R2
t = -4.8844, df = 998, p-value = 1.208e-06
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.21277453 -0.09167219
sample estimates:
       cor 
-0.1527969 

It turns out that R1 and R2 are very close to each other but negatively correlated. This is only the case when x is kept out of the loop (i.e. fix across experiments).

Would you know why?

Mathematical formulation

Let

xi ~ N(0,1), i=1,...,100 (~ indicates i.i.d.)

y1,i = xi+ui, ui ~ N(0,1)

y2,i = xi+vi, vi ~ N(0,1)

We can arrange these random variables as vectors:

x=[xi]i=1,...,100

y1=[y1,i]i=1,...,100

y2=[y2,i]i=1,...,100

And we now create the concatenated vectors as follows:

X=[x,x]

Y=[y1,y2]

It turns out that the Pearson's correlation between y1 and y2 is very close to Var(X)/Var(Y). However, the two are negatively correlated when we repeat the process of realising y1,i, and yi while maintaining xi constant across realisations.

Would you know why?

Question edited with the correct code - apologies

I have observed a somewhat puzzling negative correlation.

In code (R) (mathematical formulation below)

set.seed(123)
N=1000
R1=vector('double',N)
R2=vector('double',N)
x=rnorm(100)
for (k in 1:N){
  y1=x+rnorm(100)
  y2=x+rnorm(100)
  X=c(x,x)
  Y=c(y1,y2)
  R1[k]=cor(y1,y2)
  R2[k]=var(X)/var(Y)  
}
cor.test(R1,R2)
 
    Pearson's product-moment correlation

data:  R1 and R2
t = -7.2284, df = 998, p-value = 9.704e-13
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.2811533 -0.1633130
sample estimates:
       cor 
-0.2230479 

It turns out that R1 and R2 are very close to each other but negatively correlated. This is only the case when x is kept out of the loop (i.e. fix across experiments).

Would you know why?

Mathematical formulation

Let

xi ~ N(0,1), i=1,...,100 (~ indicates i.i.d.)

y1,i = xi+ui, ui ~ N(0,1)

y2,i = xi+vi, vi ~ N(0,1)

We can arrange these random variables as vectors:

x=[xi]i=1,...,100

y1=[y1,i]i=1,...,100

y2=[y2,i]i=1,...,100

And we now create the concatenated vectors as follows:

X=[x,x]

Y=[y1,y2]

It turns out that the Pearson's correlation between y1 and y2 is very close to Var(X)/Var(Y). However, the two are negatively correlated when we repeat the process of realising y1,i, and yi while maintaining xi constant across realisations.

Would you know why?

Source Link
Loading