【发布时间】:2016-07-20 03:13:29
【问题描述】:
我正在尝试在 .csv 文件中的时间数据集上运行 ARIMA。到目前为止,这是我的代码:
Oil_all <- read.delim("/Users/Jkels/Documents/Introduction to Computational
Statistics/Oil production.csv",sep="\t",header=TRUE,stringsAsFactors=FALSE)
Oil_all
文件如下:
year.mbbl
1 1880,30
2 1890,77
3 1900,149
4 1905,215
5 1910,328
6 1915,432
7 1920,689
8 1925,1069
9 1930,1412
10 1935,1655
11 1940,2150
12 1945,2595
13 1950,3803
14 1955,5626
15 1960,7674
16 1962,8882
17 1964,10310
18 1966,12016
19 1968,14104
20 1970,16690
21 1972,18584
22 1974,20389
23 1976,20188
24 1978,21922
25 1980,21732
26 1982,19403
27 1984,19608
代码:
apply(Oil_all,1,function(x) sum(is.na(x)))
结果:
[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
当我运行 ARIMA 时:
library(forecast)
auto.arima(Oil_all,xreg=year)
这是错误:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
0 (non-NA) cases
In addition: Warning message:
In data.matrix(data) : NAs introduced by coercion
所以,我能够调用数据集并打印出来。但是,当我使用 apply 函数检查这些值是否存在时,我看到的都是 0,所以我知道出了点问题,这可能就是我收到错误的原因。我只是不确定错误的含义或如何在代码中修复它。
有什么建议吗?
【问题讨论】: