[R] Fitting an ARIMA model to a time series
Wouter van Rijsinge
wprijsin at cs.uu.nl
Sun May 25 10:15:37 CEST 2003
R 1.6.2 on windows XP (and windows 2000)
Dear Readers,
I have to fit an ARIMA model to a blood pressure series to make predictions
with it. But since I don't have a blood pressure data set yet I have to
work with self made data. So I have created an AR( 2 ) series with the
following code:
series <- list()
series$series <- arima.sim(n=2100, model=list(ar = c(0.6, 0.1)), sd=1) + 120
It is based upon the assumption that the blood pressure will be a value
around a mean of 120 with only minor fluctuations. Only when something goes
terribly wrong it will have a trend up or down.
I now try to predict new values every interval of size 20 with data from a
sliding window of size 100 with the following code:
windowSize <- 100
lagSize <- 5
for(i in 1 : 100)
{
index <- windowSize + ((i-1)*20)
model <- arima(series$series[ ( ( (index-windowSize) + 1) : index ) ],
order = c(2, 1, 1), method = c("ML") )
predictions <- arima.sim(n=5, model = model)
}
The problem is that whatever order I use for the model estimation I always
end up with the error: "ar part of model is not stationary". I have tried
to fit totally different series with less random fluctuations and more
trend etc. but it also doesn't work. I don't know any solution for this
problem anymore. So I have the following questions:
1. Is there anybody who can tell me how to (automatically) fit an ARIMA
model to the data and make predictions with it? It of course has to work
with future blood pressure series too. Even with blood pressure series with
trend because in the future I will have to fit it to data from the
Intensive Care.
2. Or is the model not compatible with the (simulated) blood pressure data
and should I just stop trying?
I hope someone has a solution for this problem because I can't find one.
Greetings,
Wouter
More information about the R-help
mailing list