ARIMA错误
我试图在.csv文件中的临时数据集上运行ARIMA。以下是我目前的代码:ARIMA错误,r,dataset,R,Dataset,我试图在.csv文件中的临时数据集上运行ARIMA。以下是我目前的代码: Oil_all <- read.delim("/Users/Jkels/Documents/Introduction to Computational Statistics/Oil production.csv",sep="\t",header=TRUE,stringsAsFactors=FALSE) Oil_all 代码: 结果: [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Oil_all <- read.delim("/Users/Jkels/Documents/Introduction to Computational
Statistics/Oil production.csv",sep="\t",header=TRUE,stringsAsFactors=FALSE)
Oil_all
代码:
结果:
[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,因此我知道有什么地方出错,这可能就是我出错的原因。我只是不确定这个错误是什么意思,或者如何在代码中修复它
有什么建议吗?如果我没弄错你的问题,应该是这样的:
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
Oil\u all您的导入应该是
Oil_all<-read.csv("/Users/Jkels/Documents/Introduction to Computational Statistics/Oil production.csv")
Oil_all@Nemesi您好,所以我尝试了您的建议,出于某种原因,我现在遇到了一个新错误:ts(x)中的错误:'ts'对象必须有一个或多个观测点谢谢,我找到了!嗨,Elle,一般来说,这是一个建议:如果你提供你正在使用的数据,回答你问题的人可以给你更准确的建议。很高兴听到你成功了!非常感谢。我知道了!
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
Oil_all<-read.csv("/Users/Jkels/Documents/Introduction to Computational Statistics/Oil production.csv")