[R] Beginner problems forecasting arma model

David Winsemius dwinsemius at comcast.net
Tue Mar 13 04:52:18 CET 2012

On Mar 12, 2012, at 8:51 PM, Alex Chen wrote:

> Hello,
> I am new to the R software and attempting to create a time series
> model with trend, seasonality, as well as cycles. I have already been
> able to create a model that incorporates both the trend and
> seasonality and my approach is to then use the fitted results from
> this model in order to create an ARMA model. My code looks like this:
>> model1=tslm(m2ts~poly(t,9)+season)
>> model2=arma(model1$fit,c(1,0))

When you post code you should name the packages in which functions  
> But after attempting to create the second model I receive this error  
> message:
> "Error in AA %*% t(X) : requires numeric/complex matrix/vector  
> arguments"

When you get an error pointing to a type mismatch you should look at  
the object with str() and then compare that to the requirements laid  
out in the help page. You may also find that traceback() is informative.

> I have seen code that works in using $fit to create an ARMA model but
> I cannot figure out what is wrong with my models. Why is it that
> model1$fit does not meet the requirements as a numeric/complex
> matrix/vector? Does it not return as a time-series? Also, is this the
> best approach to creating a model that incorporates all three of these
> elements: trend, seasonality, and cycles? or is there a better method
> which may be simpler?
> Thank you very much for helping a novice R programmer out.

> I can
> provide more information if needed.

I certainly hope so.

David Winsemius, MD
West Hartford, CT

More information about the R-help mailing list