Thank you for your email.
The problem is that i'm not quite sure how to specify the model using arima().
Here's an example of my problem:
I would like to fit an ARMA model, but I'm not sure exactly how to fit it.
Â
Here's an example of the problem.
Â
This is my time variable, hourly dataÂ
t <- seq(as.POSIXct("2011-01-01 00:00:00"), as.POSIXct("2011-12-31 23:00:00"),
by="hour")
Â
My response
y <- rnorm(length(t), 1000, 500)
Â
Seasonal factors:
t.h <- as.POSIXlt(t)$hour # hours of the day
t.d <- as.POSIXlt(t)$day # days of the week
t.m <- as.POSIXlt(t)$mon # months of the year
This is my regressor
x.reg <- rnorm(length(t), 10, 1)
Â
Â
and I have the following auto-regressive lags (1 to 10, 24 and 48 hours)
y.lag1 <- lag(y, 1)
y.lag2 <- lag(y, 2)
y.lag3 <- lag(y, 3)
y.lag4 <- lag(y, 4)
y.lag5 <- lag(y, 5)
y.lag6 <- lag(y, 6)
y.lag7 <- lag(y, 7)
y.lag8 <- lag(y, 8)
y.lag9 <- lag(y, 9)
y.lag10 <- lag(y, 10)
y.lag24 <- lag(y, 24)
y.lag48 <- lag(y, 48)
I want to fit an ARMA (auto-regressive moving average) with my 3 seasonal
factors, 12 lagged variables and the regressor against my response variable.
Does someone know how such an ARMA model can be fit?
Regards,
Dave
________________________________
From: Greg Snow <[email protected]>
roject.org>
Sent: Friday, 17 June 2011, 21:40
Subject: RE: [R] prediction intervals
I am not an expert in time series (that is why I referred you to the task view
rather than give my own inexpert opinion). I do remember from a textbook that
covered the basics of time series that prediction 2 time points ahead was
different from plugging in the next time estimate and predicting one ahead.Â
And basic theory of linear models also supports this.Â
Â
The standard linear model assumes all xâs to be fixed (or independent of each
other if random) if you add a new x that is not independent and not fixed, then
this does not hold. There is also a whole area of linear models for what to
do if x is not an exact value but measured with error (or predicted), another
area that I know exists and is complicated, but which I have not studied beyond
the basics.Â
Â
Also the standard formula for prediction intervals has a piece to account for
variability around the mean and another piece to account for the variability in
the estimate of the mean due to the coefficients being estimates rather than
known quantities, it only makes sense that there should be another piece to
account for uncertainty due to the value of x in the prediction when it is not
known.
Â
The best I can recommend is look through the task view. Maybe someone else
has a better refrence.
Â
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[email protected]
801.408.8111
Â
Sent: Friday, June 17, 2011 1:48 AM
To: Greg Snow; [email protected]
Subject: Re: [R] prediction intervals
Â
Thank you for your post Greg.
Do you have any useful references regarding this variability (papers etc)?
Â
Many thanks.
Dave
Â
Â
From:Greg Snow <[email protected]>
roject.org>
Sent: Thursday, 16 June 2011, 21:32
Subject: RE: [R] prediction intervals
I don't think that this approach is appropriate here. Each iteration after
the 1st the lm/predict combination will assume that the new data is exact when
in fact it is an estimate with some error involved. To properly do this you
need to take into account that variability. There is a time series task view
on CRAN that may point you to better tools.
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[email protected]
801.408.8111
> -----Original Message-----
> From: [email protected] [mailto:r-help-bounces@r-
> project.org] On Behalf Of Dave Evens
> Sent: Thursday, June 16, 2011 11:33 AM
> To: [email protected]
> Subject: [R] prediction intervals
>
>
>
> Dear members,
>
> I'm fitting linear model using "lm" which has numerous auto-regressive
> terms as well as other explanatory variables. In order to calculate
> prediction intervals, i've used a for-loop as the auto-regressive
> parameters need to be updated each time so that a new forecast and
> corresponding prediction interval can be calculated.
>
> I'm fitting a number of these models which have different values for
> the response variable and possibly different explanatory variables. The
> response is temperature in fahrenheit (F), and the different models are
> for cities. So each city has its own fitted linear model for
> temperature. I'm assuming that they're independent models for the time
> being, I want to combine the results across all cities and have overall
> prediction intervals. Because I assuming that they're independent can I
> just add together the degrees of freedom from each model (i.e. total
> degrees of freedom=df1+df2+...) and the variance-covariance matrices
> (i.e. V=V1+V2+...) in order to calcalate the overall prediction
> intervals?
>
> Any help would be most appreciated.
>
> Regards,
> Dave
> Â Â Â [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.