Reputation: 9
I am trainig a an ARIMA model
> data=read.csv("R1.csv")
> resp=data$RESP
> respNA=resp[1:100]
> model=arima(respNA,order = c(0,0,1),include.mean = FALSE)
> p=predict(model$model,na.ahead=10)
but for the last line I get below error:
Error in ets(object, lambda = lambda, biasadj = biasadj, allow.multiplicative.trend = allow.multiplicative.trend, :
y should be a univariate time series
what is wrong with above code?
I gues the data is coorect when I call print(respNA) , the output is like below:
[1] 0.00000000 0.18333333 0.93333333 0.00000000 0.25000000 0.86666667 0.00000000 0.31666667 0.80000000 0.00000000
[11] 0.38333333 0.73333333 0.00000000 0.45000000 0.66666667 0.00000000 0.51666667 0.60000000 0.00000000 0.58333333
[21] 0.53333333 0.00000000 0.65000000 0.46666667 0.00000000 0.71666667 0.40000000 0.00000000 0.78333333 0.33333333
[31] 0.00000000 0.85000000 0.26666667 0.00000000 0.91666667 0.20000000 0.00000000 0.98333333 0.13333333 0.05000000
[41] 1.00000000 0.06666667 0.11666667 1.00000000 0.00000000 0.18333333 0.93333333 0.00000000 0.25000000 0.86666667
[51] 0.00000000 0.31666667 0.80000000 0.00000000 0.38333333 0.73333333 0.00000000 0.45000000 0.66666667 0.00000000
[61] 0.51666667 0.60000000 0.00000000 0.58333333 0.53333333 0.00000000 0.65000000 0.46666667 0.00000000 0.71666667
[71] 0.40000000 0.00000000 0.78333333 0.33333333 0.00000000 0.85000000 0.26666667 0.00000000 0.91666667 0.20000000
[81] 0.00000000 0.98333333 0.13333333 0.05000000 1.00000000 0.06666667 0.11666667 1.00000000 0.00000000 0.18333333
[91] 0.93333333 0.00000000 0.25000000 0.86666667 0.00000000 0.31666667 0.80000000 0.00000000 0.38333333 0.73333333
Upvotes: 0
Views: 1950
Reputation: 50668
The correct syntax with predict
is predict(your_model, ...)
, i.e. in your case
# Fit ARIMA model
model <- arima(respNA,order = c(0,0,1),include.mean = FALSE);
# Predict next 10 steps
p <- predict(model, n.ahead = 10);
p;
$pred
Time Series:
Start = 101
End = 110
Frequency = 1
[1] 0.2006601 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
[8] 0.0000000 0.0000000 0.0000000
$se
Time Series:
Start = 101
End = 110
Frequency = 1
[1] 0.4155428 0.5847784 0.5847784 0.5847784 0.5847784 0.5847784 0.5847784
[8] 0.5847784 0.5847784 0.5847784
respNA <- c(0.00000000, 0.18333333, 0.93333333, 0.00000000, 0.25000000, 0.86666667, 0.00000000, 0.31666667, 0.80000000, 0.00000000,
0.38333333, 0.73333333, 0.00000000, 0.45000000, 0.66666667, 0.00000000, 0.51666667, 0.60000000, 0.00000000, 0.58333333,
0.53333333, 0.00000000, 0.65000000, 0.46666667, 0.00000000, 0.71666667, 0.40000000, 0.00000000, 0.78333333, 0.33333333,
0.00000000, 0.85000000, 0.26666667, 0.00000000, 0.91666667, 0.20000000, 0.00000000, 0.98333333, 0.13333333, 0.05000000,
1.00000000, 0.06666667, 0.11666667, 1.00000000, 0.00000000, 0.18333333, 0.93333333, 0.00000000, 0.25000000, 0.86666667,
0.00000000, 0.31666667, 0.80000000, 0.00000000, 0.38333333, 0.73333333, 0.00000000, 0.45000000, 0.66666667, 0.00000000,
0.51666667, 0.60000000, 0.00000000, 0.58333333, 0.53333333, 0.00000000, 0.65000000, 0.46666667, 0.00000000, 0.71666667,
0.40000000, 0.00000000, 0.78333333, 0.33333333, 0.00000000, 0.85000000, 0.26666667, 0.00000000, 0.91666667, 0.20000000,
0.00000000, 0.98333333, 0.13333333, 0.05000000, 1.00000000, 0.06666667, 0.11666667, 1.00000000, 0.00000000, 0.18333333,
0.93333333, 0.00000000, 0.25000000, 0.86666667, 0.00000000, 0.31666667, 0.80000000, 0.00000000, 0.38333333, 0.73333333)
Upvotes: 1