Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 误差滞后函数_R - Fatal编程技术网

R 误差滞后函数

R 误差滞后函数,r,R,我有以下向量,它是自相关函数(packagequantmod) 但是,对于这两种情况,我都得到了以下误差mesagge Error en `tsp<-`(`*tmp*`, value = p - (k/p[3L]) * c(1, 1, 0)) : el atributo 'tsp' debe ser numérico de longitud tres Además: Mensajes de aviso perdidos 1: In if (k != round(k)) { : la co

我有以下向量,它是自相关函数(packagequantmod

但是,对于这两种情况,我都得到了以下误差mesagge

Error en `tsp<-`(`*tmp*`, value = p - (k/p[3L]) * c(1, 1, 0)) : 
el atributo 'tsp' debe ser numérico de longitud tres
Además: Mensajes de aviso perdidos
1: In if (k != round(k)) { :
la condición tiene longitud > 1 y sólo el primer elemento será usado
2: In (k/p[3L]) * c(1, 1, 0) :
longitud de objeto mayor no es múltiplo de la longitud de uno menor
3: In p - (k/p[3L]) * c(1, 1, 0) :
longitud de objeto mayor no es múltiplo de la longitud de uno menor
Error durante el wrapup: no se puede abrir la conexión
TSP1 y sólo el primer elemento seráusado错误
2:In(k/p[3L])*c(1,1,0):
奥布杰托市市长不在城市长
3:在p-(k/p[3L])*c(1,1,0)中:
奥布杰托市市长不在城市长
错误durante el-wrapup:不可能
您是否知道为什么会出现错误,以及我必须使用什么表达式来生成posAutoRelation和negatAutoRelation的列

tl;博士 类
“ts”
没有
Lag()
方法,因此它将分派给基本函数
Lag()
,该函数不喜欢在此处传递
k
lags的向量。一种解决方案是强制使用
Lag.numeric()
方法或强制时间序列
s
到支持的类之一<例如,代码>“numeric”或
“zoo”

细节 问题是
Lag()
的默认方法将调度到
Lag()
,据我所知,它只希望提供一个滞后
k
。如果您继续往下看,您将在
stats:::lag.default
中看到一行,它计算

tsp(x) <- p - (k/p[3L]) * c(1, 1, 0)
(例如,使用您的一些数据)


接下来请注意,
的tspI有且没有整数(O),s生成一个随机序列,poscorr和negcorr就我所能理解的而言都很好,谢谢你的详细回复,这是我力所不及的。我将按照转换为数字,这似乎是可行的。
Error en `tsp<-`(`*tmp*`, value = p - (k/p[3L]) * c(1, 1, 0)) : 
el atributo 'tsp' debe ser numérico de longitud tres
Además: Mensajes de aviso perdidos
1: In if (k != round(k)) { :
la condición tiene longitud > 1 y sólo el primer elemento será usado
2: In (k/p[3L]) * c(1, 1, 0) :
longitud de objeto mayor no es múltiplo de la longitud de uno menor
3: In p - (k/p[3L]) * c(1, 1, 0) :
longitud de objeto mayor no es múltiplo de la longitud de uno menor
Error durante el wrapup: no se puede abrir la conexión
tsp(x) <- p - (k/p[3L]) * c(1, 1, 0)
R> p - (poscorr/p[3L]) * c(1, 1, 0)
[1]  0 98  1
Warning message:
In (poscorr/p[3L]) * c(1, 1, 0) :
  longer object length is not a multiple of shorter object length
attr(x, "tsp") <- value
 Note that some attributes (namely ‘class’, ‘comment’, ‘dim’,
 ‘dimnames’, ‘names’, ‘row.names’ and ‘tsp’) are treated specially
 and have restrictions on the values which can be set.  (Note that
 this is not true of ‘levels’ which should be set for factors via
 the ‘levels’ replacement function.)
R> p - (poscorr/p[3L]) * c(1, 1, 0)
[1]  0 98  1
quantmod:::Lag.numeric(s, poscorr)

R> head(quantmod:::Lag.numeric(s, poscorr))
       Lag.1   Lag.2
[1,]      NA      NA
[2,] -1.5363      NA
[3,] -0.2461 -1.5363
[4,] -0.3276 -0.2461
[5,] -0.8280 -0.3276
[6,] -0.2980 -0.8280
Lag(as.numeric(s), poscorr)

R> head(Lag(as.numeric(s), poscorr))
       Lag.1   Lag.2
[1,]      NA      NA
[2,] -1.5363      NA
[3,] -0.2461 -1.5363
[4,] -0.3276 -0.2461
[5,] -0.8280 -0.3276
[6,] -0.2980 -0.8280
Lag(as.zoo(s), poscorr)

R> head(Lag(as.zoo(s), poscorr))
    Lag.1   Lag.2
1      NA      NA
2 -1.5363      NA
3 -0.2461 -1.5363
4 -0.3276 -0.2461
5 -0.8280 -0.3276
6 -0.2980 -0.8280