r语言 - "ts"对象中的错误必须具有一个或多个观测值



我在运行此代码时遇到问题,它总是显示此错误:"ts"对象必须有一个或多个观测值。

library('forecast')
library('tseries')
library('urca')

dataset_180days <- read.csv(file.choose())
head(dataset_180days)
# Timeseries data 
Yts_180days=ts(dataset_180days$Actual) #used to create time-series objects.
# ^--- this is where the error occurs.
# Augmented Dickey-Fuller Test Unit Root / Cointegration Test 
udf_test_180days <- ur.df(Yts_180days) #computes the augmented Dickey-Fuller test
summary(udf_test_180days)
# Ljung-Box Test
LB_test_180days <- Box.test(Yts_180days, type='Ljung-Box') # test statistic for examining the null hypothesis of independence in a given time series
print(LB_test_180days)
# Augmented Dickey-Fuller (ADF) t-test
adf_test_180days <- adf.test(Yts_180days,alternative = 'stationary')
print(adf_test_180days)

谢谢

请在附件中找到数据集。

https://www.dropbox.com/s/1cmwf4dema1jemw/January-2012.csv?dl=0

我回到这里发布解决方案!好吧,我只需要更改代码中变量"Actual"的名称,因为我已经更改了数据集;(

相关内容

最新更新