1

我有以下格式的时间序列数据:

   hour1  hour2  hour3  hour4  hour5  hour6  hour7  hour8  hour9 hour10 hour11 hour12 hour13 hour14 hour15 hour16 hour17
1  1.300  0.888  0.792  0.324  0.650  0.670  0.836  1.018  1.220  1.258  1.744  2.302  2.582  3.182  3.962  4.630  4.378
2 -0.170 -0.534 -0.564 -1.022 -0.774 -0.660 -0.524 -0.344 -0.100 -0.064  0.024  0.614  1.360  2.072  2.722  3.330  3.398
3 -0.344 -0.684 -0.622 -1.128 -0.982 -0.844 -0.604 -0.432 -0.124  0.016  0.110  0.600  1.392  2.150  3.404  4.028  4.084
4  2.138  1.442  0.998  1.380  1.124  1.248  0.844  1.344  1.542  1.392  1.820  2.626  2.316  2.784  3.890  4.290  4.280
5  0.684 -0.178 -0.320 -0.792 -0.540 -0.550 -0.410 -0.278 -0.182  0.024  0.400  0.992  1.328  1.682  2.488  3.176  3.260
6  0.656 -0.060  1.858  1.042  3.200  2.868  1.154  1.388  1.472  2.092  2.382  3.848  3.214  3.952  4.576  5.340  4.386
  hour18 hour19 hour20 hour21 hour22 hour23 hour24
1  5.196  5.850  6.316  3.612  5.434  5.712  5.468
2  4.090  4.320  5.660  2.818  4.516  5.026  4.498
3  5.634  4.998  5.566  2.788  4.830  5.400  5.114
4  6.126  5.366  6.392  3.184  4.336  4.198  4.764
5  4.494  4.802  5.484  2.306  4.234  4.410  4.626
6  5.906  6.004  6.250  3.790  6.158  6.926  6.522

我想执行互相关分析并且我使用过 acf(od2) 但我遇到了这个错误

acf(od2) 中的错误:“lag.max”必须至少为 0

此外,我如何自动提取相关量和显着性。

4

1 回答 1

0

我猜你想要这个:

DF <- read.table(text="  hour1  hour2  hour3  hour4  hour5  hour6  hour7  hour8  hour9 hour10 hour11 hour12 hour13 hour14 hour15 hour16 hour17 hour18 hour19 hour20 hour21 hour22 hour23 hour24
1  1.300  0.888  0.792  0.324  0.650  0.670  0.836  1.018  1.220  1.258  1.744  2.302  2.582  3.182  3.962  4.630  4.378 5.196  5.850  6.316  3.612  5.434  5.712  5.468
2 -0.170 -0.534 -0.564 -1.022 -0.774 -0.660 -0.524 -0.344 -0.100 -0.064  0.024  0.614  1.360  2.072  2.722  3.330  3.398 4.090  4.320  5.660  2.818  4.516  5.026  4.498
3 -0.344 -0.684 -0.622 -1.128 -0.982 -0.844 -0.604 -0.432 -0.124  0.016  0.110  0.600  1.392  2.150  3.404  4.028  4.084 5.634  4.998  5.566  2.788  4.830  5.400  5.114
4  2.138  1.442  0.998  1.380  1.124  1.248  0.844  1.344  1.542  1.392  1.820  2.626  2.316  2.784  3.890  4.290  4.280 6.126  5.366  6.392  3.184  4.336  4.198  4.764
5  0.684 -0.178 -0.320 -0.792 -0.540 -0.550 -0.410 -0.278 -0.182  0.024  0.400  0.992  1.328  1.682  2.488  3.176  3.260 4.494  4.802  5.484  2.306  4.234  4.410  4.626
6  0.656 -0.060  1.858  1.042  3.200  2.868  1.154  1.388  1.472  2.092  2.382  3.848  3.214  3.952  4.576  5.340  4.386 5.906  6.004  6.250  3.790  6.158  6.926  6.522",header=TRUE)


m <- t(as.matrix(DF))
acf(m)

或者可能是这样的:

lapply(seq_len(ncol(m)),
         function(i) lapply(seq_len(ncol(m)), 
            function(j) ccf(drop(m[,i]),drop(m[,j]))))

(我相信这与 几乎相同print(acf(m))

或者只是这样:

sapply(seq_len(ncol(m)), 
         function(i) sapply(seq_len(ncol(m)), 
            function(j) cor(drop(m[,i]),drop(m[,j]))))
于 2013-04-05T15:39:20.837 回答