简体   繁体   English

在R中的ARIMAX模型中预测转换后的时间序列的实际值

[英]Forecast the actual values of a transformed time series in ARIMAX model in R

I am fitting an ARIMAx model to my time series data. 我正在将ARIMAx模型拟合到我的时间序列数据。 The "data" includes "Rate" as the outcome and x1, x2, and x3 as covariates and I have transformed the outcome using Box-Cox transformation. “数据”包括“ Rate”作为结果,x1,x2和x3作为协变量,我已经使用Box-Cox变换对结果进行了变换。 My data is split into a train and a test set and I want to forecast the test set with the actual values and not the transformed values. 我的数据分为火车和测试集,我想用实际值而不是转换后的值预测测试集。 I have done the following: 我已经完成以下工作:

data.train <- ts(data[1:24, ] , frequency = 4, start = c(2011, 4)  
data.test <- ts(data[25:28, ], frequency = 4, start = c(2017, 4)) 

covariates <- c("x1", "x2", "x3")
xreg.train <- data.train[, covariates] 
xreg.test <- data.test[, covariates] 

outcome <- data.train[, "Rate"]
lambda <- BoxCox.lambda(outcome)
outcome.trans <- BoxCox(outcome, lambda) 

fit <- auto.arima(outcome.trans, xreg = xreg.train, trace = TRUE, stepwise = FALSE, seasonal = TRUE)

Now I want to forecast the test set with the actual values and not the transformed values: 现在,我想用实际值而不是转换后的值预测测试集:

 forecast.test <- predict(fit, newxreg = xreg.test, lambda = lambda)

Now the PROBLEM is that this predict function produces a forecast of the transformed values and not the actual values. 现在的问题是,此预测函数将生成转换后的值而不是实际值的预测。 How can I get the forecast of the actual values without doing the transformation myself. 我如何在不自己进行转换的情况下获得实际值的预测。

The forecast package does all this for you. 预测包将为您完成所有这一切。 But you need to use the forecast() function, not the predict() function. 但是您需要使用forecast()函数,而不是predict()函数。

data.train <- ts(data[1:24,] ,frequency=4, start=c(2011,4)  
data.test <- ts(data[25:28,], frequency=4, start=c(2017,4)) 

covariates <- c("x1","x2","x3")
xreg.train <- data.train[, covariates] 
xreg.test <- data.test[, covariates] 

outcome <- data.train[,"Rate"]
lambda <- BoxCox.lambda(outcome)

fit<- auto.arima(outcome, xreg=xreg.train, lambda=lambda,
  trace=TRUE, stepwise=FALSE, seasonal=TRUE, lambda=lambda)

forecast.test <- forecast(fit, xreg=xreg.test, lambda=lambda)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM