简体   繁体   中英

ARIMA Time Series Graph in R

I am just starting out learning R Programming and have a question if anyone can help me.

When I create a graph (ie plot() ) with my date data on the x-axis and polling data on the y-axis all works well.

But when I covert the polling data with arima and try to add the converted data with my dates ( which worked beforehand ) the message,

“Error: unexpected symbol in "plot(x,y)"

Appears where it did not beforehand.

Here is the code I am using:

Politicalpollingdata <- arima(politicalparty, order=c(0,1,1))                    

Futurepoliticalforecast <- forecast(Politicalpollingdata, h=20)

plot(Datedata, Futurepoliticalforecast, main = "Political Party’s Polling Data", 
ylab = "% of Votes", xlab = "Years / Months")

Does anyone know

A) why this occurs after I convert the polling data with the arima command?

B) is there a way to be able to use time series data in the x-axis (preferably” y/m/d”)

Apologies if this a simple fix, but I am new to R programming and I have spent hours and hours trying to find a solution with no luck!

Thanks in advance

Here's your problem:

  • Data was not converted using ARIMA, you made a model. When you ask it for a forecast, it will output an object of type forecast (a list) which includes a lot more information than just the fitted values. You will be able to access the fitted values using Futurepoliticalforecast$fitted .

  • Yes, there are many. You have not produced your data so I don't know what the problem is. However, x-labels act very well when the input is in type Date, but again, I don't know what the problem could be for your data.

Administrative notes about your question:

Please make sure you provide a reproducible example (data and all code more here https://stackoverflow.com/help/how-to-ask ). Also, please use the correct format for your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM