Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R '中的错误;ts';对象必须有一个或多个观察值_R_Time Series_Forecasting - Fatal编程技术网

R '中的错误;ts';对象必须有一个或多个观察值

R '中的错误;ts';对象必须有一个或多个观察值,r,time-series,forecasting,R,Time Series,Forecasting,我在运行此代码时遇到问题,它总是显示此错误:“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-seri

我在运行此代码时遇到问题,它总是显示此错误:“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)
library('forecast')
图书馆('tseries')
图书馆(“urca”)

dataset_180days我回来发布解决方案!
嗯,我只需在代码中更改变量“Actual”的名称,因为我已经更改了数据集;)

只要我们看不到您使用的数据,就很难知道出了什么问题。你能发布你正在阅读的文件的(子集)吗?此外,我还不清楚何时发出错误,是在最后一个print()-语句中还是在更高的位置?我已经编辑了问题并添加了数据集。否则,我已经打印了整个代码,但它停留在第7行:Yts_180days=ts(dataset_180days$Actual),并生成错误:ts中的错误(dataset_180days$Actual):“ts”对象必须有一个或多个观察值