Skip to main content
added 42 characters in body
Source Link
kjetil b halvorsen
  • 82.8k
  • 32
  • 201
  • 663
library(MASS)

set.seed(1)
n = 6
layout(matrix(c(1:(n^2)),n))
par(mar = c(1,1,1,1))

for (i in 1:(n^2)) {
  x <- mvrnorm(20, c(0,0), matrix(c(1,-0.3,-0.3,1),2))           ### generate data
  s <- sapply(2:20, FUN = function(i) cor(x[1:i,1],x[1:i,2]))    ### compute cum correlation
  plot(2:20, s,
       type = "l", col = rgb(0,0,0,1), xlim = c(2,20), ylim = c(-1,1),
       xlab = "", ylab = "", xaxt = "n", yaxt = "n")             ### plot correlation curve
  lines(c(2,20),c(1,1)*-0.3,col = 8, lty = 3)                    ### add asymptote at -0.3
}
 
    library(MASS)
    
    set.seed(1)
    n = 6
    layout(matrix(c(1:(n^2)),n))
    par(mar = c(1,1,1,1))
    
    for (i in 1:(n^2)) {
      x <- mvrnorm(20, c(0,0), matrix(c(1,-0.3,-0.3,1),2)) 
            ### generate data
      s <- sapply(2:20, FUN = function(i) cor(x[1:i,1],x[1:i,2])) 
           ### compute cum correlation
      plot(2:20, s,
           type = "l", col = rgb(0,0,0,1), xlim = c(2,20), 
               ylim = c(-1,1),
           xlab = "", ylab = "", xaxt = "n", yaxt = "n")   
          ### plot correlation curve
      lines(c(2,20),c(1,1)*-0.3,col = 8, lty = 3)        
              ### add asymptote at -0.3
    }
library(MASS)

set.seed(1)
n = 6
layout(matrix(c(1:(n^2)),n))
par(mar = c(1,1,1,1))

for (i in 1:(n^2)) {
  x <- mvrnorm(20, c(0,0), matrix(c(1,-0.3,-0.3,1),2))           ### generate data
  s <- sapply(2:20, FUN = function(i) cor(x[1:i,1],x[1:i,2]))    ### compute cum correlation
  plot(2:20, s,
       type = "l", col = rgb(0,0,0,1), xlim = c(2,20), ylim = c(-1,1),
       xlab = "", ylab = "", xaxt = "n", yaxt = "n")             ### plot correlation curve
  lines(c(2,20),c(1,1)*-0.3,col = 8, lty = 3)                    ### add asymptote at -0.3
}
 
    library(MASS)
    
    set.seed(1)
    n = 6
    layout(matrix(c(1:(n^2)),n))
    par(mar = c(1,1,1,1))
    
    for (i in 1:(n^2)) {
      x <- mvrnorm(20, c(0,0), matrix(c(1,-0.3,-0.3,1),2)) 
            ### generate data
      s <- sapply(2:20, FUN = function(i) cor(x[1:i,1],x[1:i,2])) 
           ### compute cum correlation
      plot(2:20, s,
           type = "l", col = rgb(0,0,0,1), xlim = c(2,20), 
               ylim = c(-1,1),
           xlab = "", ylab = "", xaxt = "n", yaxt = "n")   
          ### plot correlation curve
      lines(c(2,20),c(1,1)*-0.3,col = 8, lty = 3)        
              ### add asymptote at -0.3
    }
added 373 characters in body
Source Link
Sextus Empiricus
  • 86.5k
  • 6
  • 115
  • 302

Your data does not seem to be strongly distributed along a single line and this is what makes your strong initial negative correlation change into a more weak correlation of -0.3 when you are adding more items to the set.

These changes may happen very randomlyrandomly* and may depend on whatever distribution you are dealing with.

However, while it depends on chance, you will most typically see that with fewer points you have a larger variation of the sample correlation coefficient and are more likely to deviate from the true correlation. So often you will see a line decreasing or increasing from some initial estimate of the correlation with some large error towards some more precise estimate with less error.

In every case, you have an initial strong correlation. This is because with two points the correlation is always either fully +1 or -1. The strength will decrease when you start adding more points.

data


* In the image below you can see 36 cases of randomly generated cumulative correlation coefficients for data that is distributed with a multivariate normal distribution an -0.3 correlation. The differences in the curves are large (and this difference is what they have in common).

demonstrate

library(MASS)

set.seed(1)
n = 6
layout(matrix(c(1:(n^2)),n))
par(mar = c(1,1,1,1))

for (i in 1:(n^2)) {
  x <- mvrnorm(20, c(0,0), matrix(c(1,-0.3,-0.3,1),2))           ### generate data
  s <- sapply(2:20, FUN = function(i) cor(x[1:i,1],x[1:i,2]))    ### compute cum correlation
  plot(2:20, s,
       type = "l", col = rgb(0,0,0,1), xlim = c(2,20), ylim = c(-1,1),
       xlab = "", ylab = "", xaxt = "n", yaxt = "n")             ### plot correlation curve
  lines(c(2,20),c(1,1)*-0.3,col = 8, lty = 3)                    ### add asymptote at -0.3
}
 

Your data does not seem to be strongly distributed along a single line and this is what makes your strong initial negative correlation change into a more weak correlation of -0.3 when you are adding more items to the set.

These changes may happen very randomly and may depend on whatever distribution you are dealing with.

However, while it depends on chance, you will most typically see that with fewer points you have a larger variation of the sample correlation coefficient and are more likely to deviate from the true correlation. So often you will see a line decreasing or increasing from some initial estimate of the correlation with some large error towards some more precise estimate with less error.

In every case, you have an initial strong correlation. This is because with two points the correlation is always either fully +1 or -1. The strength will decrease when you start adding more points.

data

Your data does not seem to be strongly distributed along a single line and this is what makes your strong initial negative correlation change into a more weak correlation of -0.3 when you are adding more items to the set.

These changes may happen very randomly* and may depend on whatever distribution you are dealing with.

However, while it depends on chance, you will most typically see that with fewer points you have a larger variation of the sample correlation coefficient and are more likely to deviate from the true correlation. So often you will see a line decreasing or increasing from some initial estimate of the correlation with some large error towards some more precise estimate with less error.

In every case, you have an initial strong correlation. This is because with two points the correlation is always either fully +1 or -1. The strength will decrease when you start adding more points.

data


* In the image below you can see 36 cases of randomly generated cumulative correlation coefficients for data that is distributed with a multivariate normal distribution an -0.3 correlation. The differences in the curves are large (and this difference is what they have in common).

demonstrate

library(MASS)

set.seed(1)
n = 6
layout(matrix(c(1:(n^2)),n))
par(mar = c(1,1,1,1))

for (i in 1:(n^2)) {
  x <- mvrnorm(20, c(0,0), matrix(c(1,-0.3,-0.3,1),2))           ### generate data
  s <- sapply(2:20, FUN = function(i) cor(x[1:i,1],x[1:i,2]))    ### compute cum correlation
  plot(2:20, s,
       type = "l", col = rgb(0,0,0,1), xlim = c(2,20), ylim = c(-1,1),
       xlab = "", ylab = "", xaxt = "n", yaxt = "n")             ### plot correlation curve
  lines(c(2,20),c(1,1)*-0.3,col = 8, lty = 3)                    ### add asymptote at -0.3
}
 
Source Link
Sextus Empiricus
  • 86.5k
  • 6
  • 115
  • 302

Your data does not seem to be strongly distributed along a single line and this is what makes your strong initial negative correlation change into a more weak correlation of -0.3 when you are adding more items to the set.

These changes may happen very randomly and may depend on whatever distribution you are dealing with.

However, while it depends on chance, you will most typically see that with fewer points you have a larger variation of the sample correlation coefficient and are more likely to deviate from the true correlation. So often you will see a line decreasing or increasing from some initial estimate of the correlation with some large error towards some more precise estimate with less error.

In every case, you have an initial strong correlation. This is because with two points the correlation is always either fully +1 or -1. The strength will decrease when you start adding more points.

data