R 预测值及相应年份

R 预测值及相应年份,r,forecasting,prediction,R,Forecasting,Prediction,我有一个样本数据集(命名为s3),其方式如下: year T_tc P_tc N_tc 1990 570 200 370 1991 490 100 390 1992 535 410 125 1993 495 270 225 1994 485 351 134 1995 430 330 100 1996 536 310 226 1997 546 246 300 1998 524 298 226 1999

我有一个样本数据集(命名为
s3
),其方式如下:

year  T_tc  P_tc  N_tc
1990  570  200    370
1991  490  100    390
1992  535  410    125
1993  495  270    225
1994  485  351    134
1995  430  330    100
1996  536  310    226
1997  546  246    300
1998  524  298    226
1999  493  286    207
2000  425  235    190
2001  585  258    327
2002  476  373    103
2003  452  225    227
2004  515  376    139
2005  509  381    128
2006  498  255    243
2007  462  321    141
我按照以下步骤进行预测:

sample <- as.ts(s3$T_tc, start=1990, end=2000, order.by=s3$year, frequency=1)

library(forecast)
fit <- arima(sample$No_of_Test_Cases, order=c(1,0,1))
cast <- forecast(fit, n.ahead=4, level=c(80,85), lambda=TRUE, 
                 allow.multiplicative.trend=TRUE, find.frequency=TRUE, interval="year")
cast

Point Forecast     Lo 80    Hi 80    Lo 85    Hi 85    
19                 534.7275 490.3288 579.1262 484.8557 
20                 507.0437 450.7865 563.3010 443.8515 
21                 502.3010 445.7332 558.8687 438.7600 
22                 501.4885 444.9116 558.0653 437.9373 
我需要预测值以及相应的年份

您可以这样做:

sample <- ts(s3$T_tc, start=1990)
plot(sample)
library(forecast)
fit <- Arima(sample, order=c(1,0,1))
cast <- forecast(fit, h=4, level=c(80,85), lambda=TRUE)
cast

> cast
     Point Forecast    Lo 80    Hi 80    Lo 85    Hi 85
2008       534.7275 490.3288 579.1262 484.8557 584.5993
2009       507.0437 450.7865 563.3010 443.8515 570.2359
2010       502.3010 445.7332 558.8687 438.7600 565.8420
2011       501.4885 444.9116 558.0653 437.9373 565.0397
示例
sample <- ts(s3$T_tc, start=1990)
plot(sample)
library(forecast)
fit <- Arima(sample, order=c(1,0,1))
cast <- forecast(fit, h=4, level=c(80,85), lambda=TRUE)
cast

> cast
     Point Forecast    Lo 80    Hi 80    Lo 85    Hi 85
2008       534.7275 490.3288 579.1262 484.8557 584.5993
2009       507.0437 450.7865 563.3010 443.8515 570.2359
2010       502.3010 445.7332 558.8687 438.7600 565.8420
2011       501.4885 444.9116 558.0653 437.9373 565.0397