[英]Error with ARIMA
I'm trying to run an ARIMA on a temporal dataset that is in a .csv file. 我正在尝试在.csv文件中的时间数据集上运行ARIMA。 Here is my code so far: 到目前为止,这是我的代码:
Oil_all <- read.delim("/Users/Jkels/Documents/Introduction to Computational
Statistics/Oil production.csv",sep="\t",header=TRUE,stringsAsFactors=FALSE)
Oil_all
The file looks like: 该文件如下所示:
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
Code: 码:
apply(Oil_all,1,function(x) sum(is.na(x)))
Results: 结果:
[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
When I run ARIMA: 当我运行ARIMA时:
library(forecast)
auto.arima(Oil_all,xreg=year)
This is the error: 这是错误:
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
So, I was able to call in the data set and it prints. 因此,我能够调用数据集并进行打印。 However, when I go to check whether the values are present with the apply function, I see all 0's, so I know something's wrong and that's probably why I'm getting the error. 但是,当我去检查值是否与apply函数一起出现时,我看到的全为0,所以我知道出了点问题,这可能就是为什么我得到此错误。 I'm just not sure what the error means or how to fix it in the code. 我只是不确定错误的含义或如何在代码中修复它。
Any advice? 有什么建议吗?
If I got your question right, it should be like: 如果我对您的问题正确,应该是这样的:
Oil_all <- read.csv("myfolder/myfile.csv",header=TRUE)
## I don't have your source data, so I tried to reproduce it with the data you printed
Oil_all
year value
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
library(forecast)
auto.arima(Oil_all$value,xreg=Oil_all$year)
Series: Oil_all$value
ARIMA(3,0,0) with non-zero mean
Coefficients:
ar1 ar2 ar3 intercept Oil_all$year
1.2877 0.0902 -0.4619 -271708.4 144.2727
s.e. 0.1972 0.3897 0.2275 107344.4 55.2108
sigma^2 estimated as 642315: log likelihood=-221.07
AIC=454.15 AICc=458.35 BIC=461.92
your import should be 您的导入应为
Oil_all<-read.csv("/Users/Jkels/Documents/Introduction to Computational Statistics/Oil production.csv")
That is why your data is weird. 这就是为什么您的数据很奇怪的原因。 Sorry I do not have the reputation to comment.I did the same as Nemesi and it worked then. 抱歉,我没有发表评论的名声。我和Nemesi一样,后来奏效了。 I think you are trying to import a csv as a tab delimited file. 我认为您正在尝试将csv导入为制表符分隔的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.