首页
学习
活动
专区
圈层
工具
发布

ARIMA误差
EN

Stack Overflow用户
提问于 2015-08-04 21:28:12
回答 2查看 542关注 0票数 1

我试图在.csv文件中的时态数据集上运行ARIMA。到目前为止,我的代码如下:

代码语言:javascript
复制
Oil_all <- read.delim("/Users/Jkels/Documents/Introduction to Computational
Statistics/Oil production.csv",sep="\t",header=TRUE,stringsAsFactors=FALSE)
Oil_all

该文件如下所示:

代码语言:javascript
复制
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

代码:

代码语言:javascript
复制
apply(Oil_all,1,function(x) sum(is.na(x)))

结果:

代码语言:javascript
复制
[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时:

代码语言:javascript
复制
library(forecast)
auto.arima(Oil_all,xreg=year)

这是一个错误:

代码语言:javascript
复制
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,所以我知道有些地方不对劲,这可能就是我得到错误的原因。我只是不知道这个错误意味着什么,也不知道如何在代码中修复它。

有什么建议吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-08-05 00:28:38

如果我把你的问题说对了,那就应该是:

代码语言:javascript
复制
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
票数 1
EN

Stack Overflow用户

发布于 2015-08-05 00:49:56

你的进口应该是

代码语言:javascript
复制
Oil_all<-read.csv("/Users/Jkels/Documents/Introduction to Computational Statistics/Oil production.csv")

这就是为什么你的数据很奇怪。对不起,我没有这个名声,我和Nemesi做了同样的事情,那时候起了作用。我认为您正在尝试将csv导入为选项卡分隔的文件。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31819666

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档