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 <greg.s...@imail.org>

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
greg.s...@imail.org
801.408.8111
 

Sent: Friday, June 17, 2011 1:48 AM
To: Greg Snow; r-help@r-project.org
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 <greg.s...@imail.org>

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
greg.s...@imail.org
801.408.8111


> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Dave Evens
> Sent: Thursday, June 16, 2011 11:33 AM
> To: r-help@r-project.org
> 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]]
> 
> ______________________________________________
> R-help@r-project.org 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]]

______________________________________________
R-help@r-project.org 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.

Reply via email to