Suppose that the R.V. $X$ and $Y$ lie on the line parallel to the $x$ axis. Then their correlation must be $1$ and $-1$ at the same time! What's wrong with the degenerate case here ?
$\begingroup$
$\endgroup$
2
-
$\begingroup$ What kind of correlation are you referring to and what is the formula for it? $\endgroup$– whuber ♦Commented Nov 29, 2020 at 22:26
-
1$\begingroup$ The statement in your question is not right. The sample (Pearson) correlation $r_{X,Y}$ is undefined if either the $X_i$s or the $Y_i$s have zero variance. Similarly for population correlation $ρ_{X,Y}.$ // In your example the variance of $Y$ is $0.$ $\endgroup$– BruceETCommented Nov 29, 2020 at 23:10
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
Three examples in R. With two sample correlations and three scatterplots.
set.seed(2020)
x = rnorm(50, 100, 15)
y1 = rnorm(50, 0, .01) # Indep of x
y2 = 2 + .005*x # Exactly linear in x
y3 = rep(2, 50) # All 50 obs. are exactly 2
cor(x,y1); cor(x,y2); cor(x,y3)
[1] -0.06064351 # Essentially 0
[1] 1 # Exactly 1
[1] NA # Undefined
Warning message:
In cor(x, y3) : the standard deviation is zero
par(mfrow=c(1,3))
plot(x, y1, ylim=c(-1,3), main="Independent")
plot(x, y2, ylim=c(-1,3), main="Points on Line")
plot(x, y3, ylim=c(-1,3), main="Undefined r")
par(mfrow=c(1,1))