多列上的 adf 测试和 acf 图
adf test and acf plot on multiple columns
我正在尝试将 adf.test 应用于数据框的所有列。有些列有 NA 值。我想将输出存储在 vector/list/dataframe.
H<-data.frame(replicate(10,sample(0:20,10,rep=TRUE)))
H[c(2,3,7,9),9]<-NA
H[c(1,4,8),2]<-NA
H[c(1,2,3,4,8),4]<-NA
我收到如下错误
oi<-adf.test(H,alternative="stationary")
Error in adf.test(H, alternative = "stationary") :
x is not a vector or univariate time series
lapply(na.omit(H),adf.test)
Error in res.sum$coefficients[2, 1] : subscript out of bounds
包:tseries
感谢帮助
你可以试试
lapply(H, function(x) adf.test(x[!is.na(x)],
alternative='stationary', k=0))
我正在尝试将 adf.test 应用于数据框的所有列。有些列有 NA 值。我想将输出存储在 vector/list/dataframe.
H<-data.frame(replicate(10,sample(0:20,10,rep=TRUE)))
H[c(2,3,7,9),9]<-NA
H[c(1,4,8),2]<-NA
H[c(1,2,3,4,8),4]<-NA
我收到如下错误
oi<-adf.test(H,alternative="stationary")
Error in adf.test(H, alternative = "stationary") :
x is not a vector or univariate time series
lapply(na.omit(H),adf.test)
Error in res.sum$coefficients[2, 1] : subscript out of bounds
包:tseries
感谢帮助
你可以试试
lapply(H, function(x) adf.test(x[!is.na(x)],
alternative='stationary', k=0))