Forecasting

Moderator
7910 Views
Highlighted
Moderator
Posts: 17
Registered: ‎09-29-2015

Forecasting

[ Edited ]

report_forecastin.JPGDescription

Forecasting is used to predict next points in time series data sets. The prediction in this example is based on trend and seasonality.
 
 

Prerequisites (The sample .pbix files will not work without these prerequites completed)

1. Install R Engine

Power BI Desktop does not include, deploy or install the R engine. To run R scripts in Power BI Desktop, you must separately installR on your local computer. You can download and install R for free from many locations, including the Revolution Open download page, and the CRAN Repository.

 

2. Install the required R packages.

Download the R script attached to this message and run it to install all required packages on your local machine. 

 

Required R packages:

forecast, graphics, scales, zoo


Tested on:

CRAN 3.3.1, MRO 3.3.0, powerbi.com

 

Legal Disclaimers:

Terms of Service and Third Party Programs.

 

Attachment
Attachment
Attachment
Member
Posts: 73
Registered: ‎10-16-2015

Re: Forecasting

Do not sure why, but visual don't work:

 

Loading required package: scales
Loading required package: forecast
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

as.Date, as.Date.numeric

Loading required package: timeDate
Loading required package: methods
This is forecast 7.1

Error in if (frequency > 1 && abs(frequency - round(frequency)) < ts.eps) frequency <- round(frequency) :

Maxim Zelensky
excel-inside.pro
Frequent Visitor
Posts: 3
Registered: ‎08-18-2016

Re: Forecasting

Hi, great piece of software,

 

All other models work, except this one, probably with the ts code part.

 

Posting the error message file here:

 

Error Message:

Erro de script do R.
Loading required package: scales
Loading required package: forecast
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

as.Date, as.Date.numeric

Loading required package: timeDate
Loading required package: methods
This is forecast 7.1

Error in if (frequency > 1 && abs(frequency - round(frequency)) < ts.eps) frequency <- round(frequency) :
missing value where TRUE/FALSE needed
Calls: ts
Execution halted


Stack Trace:

 

Invocation Stack Trace:

 

ID de atividade
e5ab37b4-ff68-4eeb-9ac7-d3cc346b8037

Hora
Fri Aug 19 2016 00:14:08 GMT+0100 (Hora de Verão de GMT)

Versão
2.37.4464.361 (PBIDesktop)

Client Error Code
ServiceErrorToClientError

Error Details
Erro de script do R.
Loading required package: scales
Loading required package: forecast
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

as.Date, as.Date.numeric

Loading required package: timeDate
Loading required package: methods
This is forecast 7.1

Error in if (frequency > 1 && abs(frequency - round(frequency)) < ts.eps) frequency <- round(frequency) :
missing value where TRUE/FALSE needed
Calls: ts
Execution halted


Stack Trace
Microsoft.PowerBI.ExploreServiceCommon.ScriptHandlerException: Erro de script do R.
Loading required package: scales
Loading required package: forecast
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

as.Date, as.Date.numeric

Loading required package: timeDate
Loading required package: methods
This is forecast 7.1

Error in if (frequency > 1 && abs(frequency - round(frequency)) < ts.eps) frequency <- round(frequency) :
missing value where TRUE/FALSE needed
Calls: ts
Execution halted
---> Microsoft.PowerBI.Radio.RScriptRuntimeException: Erro de script do R.
Loading required package: scales
Loading required package: forecast
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

as.Date, as.Date.numeric

Loading required package: timeDate
Loading required package: methods
This is forecast 7.1

Error in if (frequency > 1 && abs(frequency - round(frequency)) < ts.eps) frequency <- round(frequency) :
missing value where TRUE/FALSE needed
Calls: ts
Execution halted

em Microsoft.PowerBI.Radio.RScriptWrapper.RunScript(String originalScript, Int32 timeoutMs)
em Microsoft.PowerBI.Client.Windows.R.RScriptHandler.GenerateVisual(String script, String inputVariableName, IDataReader dataReader, Nullable`1 viewportWidthPx, Nullable`1 viewportHeightPx)
--- Fim do rastreio da pilha de excepção interna ---
em Microsoft.PowerBI.Client.Windows.R.RScriptHandler.GenerateVisual(String script, String inputVariableName, IDataReader dataReader, Nullable`1 viewportWidthPx, Nullable`1 viewportHeightPx)
em Microsoft.PowerBI.ExploreServiceCommon.ScriptVisualCommandFlow.RunInternal(Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
em Microsoft.PowerBI.ExploreServiceCommon.ScriptVisualCommandFlow.Run(Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
em Microsoft.PowerBI.ExploreHost.SemanticQuery.ExecuteSemanticQueryFlow.TransformDataShapeResult(QueryCommand transformCommand, String dataShapeId, SemanticQueryDataShapeCommand command, Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
em Microsoft.PowerBI.ExploreHost.SemanticQuery.ExecuteSemanticQueryFlow.ProcessAndWriteDataQuery(IQueryResultDataWriter queryResultDataWriter, DataShapeGenerationContext dsqGenContext, EntityDataModel model, DataQuery query, ServiceErrorStatusCode& serviceErrorStatusCode)
em Microsoft.PowerBI.ExploreHost.SemanticQuery.ExecuteSemanticQueryFlow.ProcessAndWriteSemanticQueryCommands(IQueryResultsWriter queryResultsWriter, ExecuteSemanticQueryRequest request, IConceptualSchema conceptualSchema, EntityDataModel model)

 

 

If only one time series selected, visual does appear, but prediction model transforms into an useless predictive model.

 

Keep it up with the good work.

Frequent Visitor
Posts: 8
Registered: ‎02-25-2016

Re: Forecasting

To those who have issues with "Error in if (frequency > 1 && abs(frequency - round(frequency)) < ts.eps) frequency <- round(frequency) :" it turns out R uses your local language setting to determine a month name... 

If you add the following to you R-script it should force the code to use english setting:

Sys.setlocale("LC_ALL","English")

Make sure to add it the to top of the code

 

Hope this helps you too :

Frequent Visitor
Posts: 8
Registered: ‎02-25-2016

Re: Forecasting

To those who have issues with "Error in if (frequency > 1 && abs(frequency - round(frequency)) < ts.eps) frequency <- round(frequency) :" it turns out R uses your local language setting to determine a month name... 

If you add the following to you R-script it should force the code to use english setting:

Sys.setlocale("LC_ALL","English")

Make sure to add it the to top of the code

 

Hope this helps you too :

 

/Chris

Frequent Visitor
Posts: 3
Registered: ‎08-19-2016

Re: Forecasting

When running the ScriptInstallPackagesForForecast.R script, I'm getting the following warnings:

1: package 'forecast' was built under R version 3.3.1
2: package 'zoo' was built under R version 3.3.1

 

How can this be solved please ?

Frequent Visitor
Posts: 3
Registered: ‎08-19-2016

Re: Forecasting

When running the ScriptInstallPackagesForForecast.R script, I'm getting the following warnings:

1: package 'forecast' was built under R version 3.3.1
2: package 'zoo' was built under R version 3.3.1

 

How can this be solved please ?

Frequent Visitor
Posts: 3
Registered: ‎08-19-2016

Re: Forecasting

When running the ScriptInstallPackagesForForecast.R script, I'm getting the following warnings:

-package ‘forecast’ was built under R version 3.3.1
-package ‘zoo’ was built under R version 3.3.1

 

What should I do to solve those warnings ?

Member
Posts: 73
Registered: ‎10-16-2015

Re: Forecasting

[ Edited ]

Thank you @chrisbilsoe, it works now!

Maxim Zelensky
excel-inside.pro
Member
Posts: 73
Registered: ‎10-16-2015

Re: Forecasting

@stlecho, nothing, it works with this warnings too

Maxim Zelensky
excel-inside.pro