这些时间序列相关性在 R 中意味着什么?
what do these time series correlations mean in R?
假设我的2个时间序列数据集如下:
temp <- matrix(c(12,8,9,11,10,3,7,2,4), byrow = TRUE, ncol = 3)
rownames(temp) <- c("Denver", "LA", "NY")
colnames(temp) <- c("day-1", "day-2", "day-3")
humidity <- matrix(c(70,67,34,45,56,47,68,74,36), byrow = TRUE, ncol = 3)
colnames(humidity)<- c("day-1", "day-2", "day-3")
rownames(humidity)<- c("Denver", "LA", "NY")
> temp
day-1 day-2 day-3
Denver 12 8 9
LA 11 10 3
NY 7 2 4
> humidity
day-1 day-2 day-3
Denver 70 67 34
LA 45 56 47
NY 68 74 36
> cor(humidity)
day-1 day-2 day-3
day-1 1.0000000 0.8924544 -0.9974590
day-2 0.8924544 1.0000000 -0.8580461
day-3 -0.9974590 -0.8580461 1.0000000
> cor(temp)
day-1 day-2 day-3
day-1 1.0000000 0.9078413 0.5291067
day-2 0.9078413 1.0000000 0.1245339
day-3 0.5291067 0.1245339 1.0000000
> cor(humidity, temp)
day-1 day-2 day-3
day-1 -0.2584615 -0.6397084 0.6829690
day-2 -0.6664738 -0.9176629 0.2799863
day-3 0.1889822 0.5833240 -0.7332730
我不确定如何将其解释为时间序列?
1- 哪个 cor 显示变量是否相关?
2- 为什么不忽略城市?
3- 在第三个 cor(humidity, temp)
中,主对角线值不是 cor 矩阵中的一个。怎么来的?
第三个矩阵(cor(humidity, temp)
)的第(i,j)个元素显示了humidity
的第i列和temp
的第j列之间的相关性。插图:
cor(c(12,11,7),c(70,45,68)) ## day-1 humidities vs day-1 temps (m[1,1])
cor(c(8,10,2), c(70,45,68)) ## day-2 humidities vs day-1 temps (m[2,1])
如果您设置
,可能更容易解释结果
cc <- cor(humidity, temp)
names(dimnames(cc)) <- c("humidity", "temp")
假设我的2个时间序列数据集如下:
temp <- matrix(c(12,8,9,11,10,3,7,2,4), byrow = TRUE, ncol = 3)
rownames(temp) <- c("Denver", "LA", "NY")
colnames(temp) <- c("day-1", "day-2", "day-3")
humidity <- matrix(c(70,67,34,45,56,47,68,74,36), byrow = TRUE, ncol = 3)
colnames(humidity)<- c("day-1", "day-2", "day-3")
rownames(humidity)<- c("Denver", "LA", "NY")
> temp
day-1 day-2 day-3
Denver 12 8 9
LA 11 10 3
NY 7 2 4
> humidity
day-1 day-2 day-3
Denver 70 67 34
LA 45 56 47
NY 68 74 36
> cor(humidity)
day-1 day-2 day-3
day-1 1.0000000 0.8924544 -0.9974590
day-2 0.8924544 1.0000000 -0.8580461
day-3 -0.9974590 -0.8580461 1.0000000
> cor(temp)
day-1 day-2 day-3
day-1 1.0000000 0.9078413 0.5291067
day-2 0.9078413 1.0000000 0.1245339
day-3 0.5291067 0.1245339 1.0000000
> cor(humidity, temp)
day-1 day-2 day-3
day-1 -0.2584615 -0.6397084 0.6829690
day-2 -0.6664738 -0.9176629 0.2799863
day-3 0.1889822 0.5833240 -0.7332730
我不确定如何将其解释为时间序列?
1- 哪个 cor 显示变量是否相关?
2- 为什么不忽略城市?
3- 在第三个 cor(humidity, temp)
中,主对角线值不是 cor 矩阵中的一个。怎么来的?
第三个矩阵(cor(humidity, temp)
)的第(i,j)个元素显示了humidity
的第i列和temp
的第j列之间的相关性。插图:
cor(c(12,11,7),c(70,45,68)) ## day-1 humidities vs day-1 temps (m[1,1])
cor(c(8,10,2), c(70,45,68)) ## day-2 humidities vs day-1 temps (m[2,1])
如果您设置
,可能更容易解释结果cc <- cor(humidity, temp)
names(dimnames(cc)) <- c("humidity", "temp")