'ts'对象中的错误必须具有一个或多个观察结果

问题描述 投票:0回答:1

我在运行此代码时遇到问题,它始终显示此错误:'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

r time-series forecasting
1个回答
0
投票

我回到这里发布解决方案!好吧,因为更改了数据集,所以我只需要在代码上更改变量“ Actual”的名称;)

© www.soinside.com 2019 - 2024. All rights reserved.