Differencing in multivaraite time series in R - r

I'm trying to estimate VAR model using vars package. I have a problem with differencing my multivariate time series.
First time series looks like this
the second one looks like this
I have tried to use diffM() from MTS package to difference by 1 lag in all of them, but still, some of them are non-stationary.

Related

Auto.Arima with Daily Sales - Univariate Time Series Error

I'm working with a data set from 2017-01-01 to 2017-10-27, however, the auto.arima says it can only handle univariate time series, despite there being only daily data.
What am I missing?
Reproducible example:
set.seed(25)
datelist<-seq(as.Date("2016-01-01"),as.Date("2017-10-27"),by="day")
salesvals<-round(abs(rnorm(length(datelist)))*1000,digits=2)
salestbl<-data.frame(datelist,salesvals)
salesTS<-ts(salestbl,
start=c(2016,as.numeric(format(salestbl$datelist, "%j"))),
frequency=7)
fit <- auto.arima(salesTS)
Error:
Error in auto.arima(salesTS) :
auto.arima can only handle univariate time series
Overall, I know there's a weekly seasonality, hence the seven days. I know there's also a quarterly seasonality, but I can tackle that another time.
Overall I'm trying to get a forecast for 2017-12-31, using an arima forecast.
The problem is that you are declaring the data.frame as time series wrong. Any way you dont need to do that just omit the ts part like this:
set.seed(25)
datelist<-seq(as.Date("2016-01-01"),as.Date("2017-10-27"),by="day")
salesvals<-round(abs(rnorm(length(datelist)))*1000,digits=2)
salestbl<-data.frame(datelist,salesvals)
fit <- auto.arima(salestbl[,2])
just head(salesTS) and you will see why you get the error.

Difference between simulate() and forecast() in "forecast" package

I am working on building a time series model.
However, I am having trouble understanding what the difference is between the simulate function and the forecast function in the forecast package.
Suppose I built an arima model and want to use it to simulate future values as long as 10 years. The data is hourly and we have a year worth of data.
When using forecast to predict the next 1000-step-ahead estimation, I got the following plot.
Using forecast method
Then I used the simulate function to simulate the next 1000 simulated values and got the following plot.
Using simulate method
Data points after the red line are simulated data points.
In the latter example, I used the following codes to simulate the future values.
simulate(arima1, nsim=1000, future=TRUE, bootstrap=TRUE))
where arima1 is my trained arima model, bootstrap residuals are used because the model residuals are not very normal.
Per definition in the forecast package, future=TRUE means that we are simulating future values based on the historical data.
Can anyone tell me what the difference is between these two method? Why does simulate() give me a much more realistic results but forecasted values from forecast() just converge to a constant after several iterations (no much fluctuation to the results from simulate())?
A simulation is a possible future sample path of the series.
A point forecast is the mean of all possible future sample paths. So the point forecasts are usually much less variable than the data.
The forecast function produces point forecasts (the mean) and interval forecasts containing the estimated variation in the future sample paths.
As a side point, an ARIMA model is not appropriate for this time series because of the skewness. You might need to use a transformation first.

Forecasting panel data and time series

I have a panel data set of lets say 1000 observations, so i=1,2,...,1000 . The data set runs in daily basis for a month, so t=1,2,...,31.
I want to estimate individual specific in R:
y_i10=αi+βi∗yi9+γi∗yi8+...+δi∗yi1+ϵit
and then produce density forecasts for the next 21 days, that is produce density forecasts for yi11,yi12 etc
My questions are:
Can I do this with plm package ? I am aware how to estimate with plm package but I do not know how to produce the forecasts.
Would it be easier (and correct) if I consider each observation as a separate time series, and use arima(9,0,0) for each one of them, and then get the density forecasts ? If so, how can I get the density forecasts ?
In (2.) , how can I include individual specific effects that are constant over time ?
Thanks a lot

forecasting time series by updating in R

I'm working on time series with a monthly demand for 5 years in R. Currently, I'm using naive method to forecast 12 months (h=12)and it does work very well I want to forecast only for one month (h=1) (always with naive method) and then include this predicted value to time series and repeat this process 12 times. For example:
get forecast for January 2013
include this predicted value to time series
apply naive method for the new series
My time series is not stationary and has a trend and seasonality.
What I'm looking to do is to forecast using Naive but step by step (month by month) with updating my time series each step. How can I do that?
Surely you will get the same answer. The naive method uses the most recent observation as the forecast. So your first forecast will be equal to the last observation. Your second forecast will be equal to the first forecast, and so is also equal to the last observation. And so on.
In any case, what you describe is precisely how almost all time series forecasts work. It is called the recursive method of forecasting, where predicted values take the place of observations as you forecast further ahead. In the forecast package for R, all purely time series forecasts are created this way.

R: Generate a Seasonal ARIMA time-series model using parameters of existing data

I have a count time series data which I'm able to use to determine the parameters of the underlying stochastic process. For example say I have a SARIMA (p,d,q)(P,D,Q)[S] seasonal ARIMA model.
How do I use this to generate a new count time series data set?
Being even more specific: a SARIMA(1,0,1)(1,0,0)[12] - how can I generate a time series for a 10 year period for each month? (i.e., 120 points to estimate the number of 'counts'.)
Use simulate.Arima() from the forecast package. It handles seasonal ARIMA models whereas arima.sim() does not.
However, ARIMA models are not suitable for count time series as they assume the process is defined on the whole real line.

Resources