Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

QlikSense - R with Arima Prediction

Hi,

I have a customer with the sample attached data.
Who wants me to display predictive values for next one year.

Can anyone of you, show me or send me the Required R codes required to generate the futuristic data for Next one year based on the sample file:

Activity Period : is my Field for Period
Passenger Count: is my field for values.

I have downloaded R-studio.

But not understanding the concept of Ts, arima etc.

If someone can explain to me.. that will be very much appreciated . My Skpye id: ashvinzoe

At the end, i want to use the predicted data to display in a graph.

( from qlikview i know we have linear prediction, however Customer wants an ideal forecast graph )

Regards,

Ashvin

1 Solution

Accepted Solutions
Not applicable
Author

Ok guy, i gat it working.

// This is going to generate all the difference between the present and past row of data.

// Remember to send the DAta Measure into that. NEVER THE DATE.

// lag = 1 ::  diference between 2 rows immediate

// lag = 1  :: difference bewen Two 2 rows... behind.

dif1 = diff(dfSummarize[[2]] , lag = 1  )  

// When plot of you will know whether it is stationary or not.

plot(dif1)

// UNTIL you get a staiotnay plot... u need to keep on Differentioating...

// remember... you need to Diff the diff ...

// Check these tw0 ONLY WHEN YOU HAEV A STATIONARY SERIES.. u can use these fucntion.

// numbe rof AR terms

pacf(dif1) // from this chart >> locate the PEEK. The highest. VALUE ABOVE THE BLUE LINE. Max line out of the RANGE ( Blue dotted lines)

// numbe rof  MA terms

acf(dif1)  // from this chart >> locate the PEEK. The highest.

// calculate the Fit

c(6,1,6) = 1 here is the number of Diff we have made. No of times we have differentiate to be stationary.

fit  <- arima(x = dfSummarize[[2]] , order = c(6,1,6)  )

fit  <- arima(x = dfSummarize[[2]] , order = c(6,1,6)  )

fit  <- arima(x = dfSummarize[[2]] , order = c(12,1,12))

fit  <- arima(x = dfSummarize[[2]] , order = c(6,1,6)  )

// WHY DONT U reduce the amount of data loaded and then when predict, do the prediction for KNOWN values.

// u will know whether the model is best fit.

// VALIDATION of Forecast data.

// Finally forcast .... H = 12.. depends on what you want to predict.. periods... how many values.

pForecast <- forecast(fit, h = 12)

View solution in original post

5 Replies
boopeshj
Partner - Creator II
Partner - Creator II

Hi Ashvin,

I went through your dataset. May i understand at what level you would want to predict the data.

Thanks

Boopesh

Not applicable
Author

For instance the last period was : 200606

And what is required is to predict till 200706.

I have managed to use grouping to get the Period per month.

> csvdata <- read.csv("MonthlyPassengerData_200507_to_201509.csv", header = TRUE)

> xPeriod  <- csvdata[1]

> yPax <- csvdata["Passenger.Count"]

> df = data.frame(xPeriod,yPax);

// use library(data.table)

dfSummarize <-  aggregate(Passenger.Count ~ Activity.Period, df, sum)

Activity.Period   total

             (int)   (int)

1           200507 3225769

2           200508 3195866

3           200509 2740553

4           200510 2770715

5           200511 2617333

etc etc

----------------

Convert date from YYYYMM to YYYY-MM-DD

// where initialy dfSummarize[[1]] has a list of date in YYYYMM

dfSummarize[[1]] <-  as.Date(paste(dfSummarize[[1]],"01", sep = ""), format = "%Y%m%d")

So from here... i need to get next 12 months data...

Not applicable
Author

Ok guy, i gat it working.

// This is going to generate all the difference between the present and past row of data.

// Remember to send the DAta Measure into that. NEVER THE DATE.

// lag = 1 ::  diference between 2 rows immediate

// lag = 1  :: difference bewen Two 2 rows... behind.

dif1 = diff(dfSummarize[[2]] , lag = 1  )  

// When plot of you will know whether it is stationary or not.

plot(dif1)

// UNTIL you get a staiotnay plot... u need to keep on Differentioating...

// remember... you need to Diff the diff ...

// Check these tw0 ONLY WHEN YOU HAEV A STATIONARY SERIES.. u can use these fucntion.

// numbe rof AR terms

pacf(dif1) // from this chart >> locate the PEEK. The highest. VALUE ABOVE THE BLUE LINE. Max line out of the RANGE ( Blue dotted lines)

// numbe rof  MA terms

acf(dif1)  // from this chart >> locate the PEEK. The highest.

// calculate the Fit

c(6,1,6) = 1 here is the number of Diff we have made. No of times we have differentiate to be stationary.

fit  <- arima(x = dfSummarize[[2]] , order = c(6,1,6)  )

fit  <- arima(x = dfSummarize[[2]] , order = c(6,1,6)  )

fit  <- arima(x = dfSummarize[[2]] , order = c(12,1,12))

fit  <- arima(x = dfSummarize[[2]] , order = c(6,1,6)  )

// WHY DONT U reduce the amount of data loaded and then when predict, do the prediction for KNOWN values.

// u will know whether the model is best fit.

// VALIDATION of Forecast data.

// Finally forcast .... H = 12.. depends on what you want to predict.. periods... how many values.

pForecast <- forecast(fit, h = 12)

reddy-s
Master II
Master II

Hi Ashvin,

This link here will give you more information on how to implement ARIMA.

https://www.otexts.org/fpp/8/7

Also, once done with your predictive model , you can plot the data in Qliksense in a line chart as I have done in my project (I made use of random forest time series forecasting).

You can color the line chart the way you need. Please check the image below: the red and the yellow lines are the confidence bands.Line chart(1).PNG

!

Nims
Partner - Contributor II
Partner - Contributor II

Hi,

 

I have similar request from my client to get forecast figures for next year using the sales data for last 3 years with ARIMA model. I don't have any idea on this ARIMA model. Could you please help me with this? Could you please share the steps which you followed.

 

Thanks,

Nimi