向量自回归模型预测多元数据

问题描述

我正在使用多元时间序列数据(小时时间序列数据)处理功能时间序列。我使用的FAR模型不止一个订单,R中没有可用的统计软件包,因此,我将数据转换为功能形式并获得了功能原理组件,然后从那些FPCA中提取了它们相应的** FPCscores **。知道我在那些 FPCscores 上使用VAR模型通过VAR模型进行每24小时的预测,但是当我把phat = 23放进去时,VAR会给我提供所有23小时的预测值,但是无论何时我放例如,phat = 24要预测每24小时以NA的形式给出结果。代码在下面给出

library(vars)
library(fda)

fdata<- function(mat){
  nb = 27 # number of basis functions for the data
  fbf = create.fourier.basis(rangeval=c(0,1),nbasis=nb) # basis for data
  args=seq(0,1,length=24)
  fdata1=Data2fd(args,y=t(mat),fbf) # functions generated from discretized y
  return(fdata1)
}
prediction.ffpe = function(fdata1){
  n = ncol(fdata1$coef)
  D = nrow(fdata1$coef)
  #center the data
  #mu = mean.fd(fdata1)
  data = center.fd(fdata1)
  #ffpe = fFPE(fdata1,Pmax=10)
  #p.hat = ffpe[2] #order of the model
  d.hat=23
  p.hat=6
  #fPCA
  fpca = pca.fd(data,nharm=D,centerfns=TRUE)
  scores = fpca$scores[,0:d.hat]
  # to avoid warnings from vars predict function below
  colnames(scores) <- as.character(seq(1:d.hat))
  VAR.pre= predict(VAR(scores,p.hat),n.ahead=1,type="const")$fcst
  
}

请指导我如何解决我的问题或我犯了什么错误。谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...