R analysis example

Below is the R script for the forecasting analytic. It is also available as part of the installation package in the default RScripts folder as a file called SeasonalForecasting.R. This example explains how to deploy this script with the MicroStrategy Tutorial project available with MicroStrategy Analytics Enterprise.

The header block for this R script includes the following metric expression information:

#Metric Expression: 
RScript<_RScriptFile="SeasonalForecasting.R",
_InputNames="Target, Trend, Season", StringParam9="">
(Target, Trend, Season)

The inputs for the metric expression are included in parentheses and separated by commas at the end of the metric expression: (Target, Trend, Season).

The following steps provide a brief overview of how to use the metric expression to deploy the example analytic to MicroStrategy Analytics Enterprise. The metric is placed in a report for analysis.

To deploy the sample R analytic

1 Copy the metric expression to the clipboard.
2 Open the MicroStrategy Tutorial project in either Developer or Web and run the report named 2 -- Monthly Revenue Forecast located by default at Tutorial\Public Objects\Reports\MicroStrategy Platform Capabilities\MicroStrategy Data Mining Services\Linear Regression\Monthly.
3 When the report finishes executing, insert a new metric and give it a name such as Forecast from R.
4 Paste the metric expression from the clipboard into the Definition field of the new metric.
5 The inputs are listed at the end of the metric expression, in parentheses and separated by commas. Map the three inputs to MicroStrategy metrics using the following steps:
a Highlight Target in the expression and replace it with Revenue from the Report Objects.
b Highlight Trend in the expression and replace it with Month Index from the Report Objects.
c Highlight Season in the expression and replace it with Month of Year from the Report Objects.
6 Click OK to save the new metric and re-execute your report.

The values for your new metric generated by R match those from the Revenue Predictor (Monthly) metric, because they are both linear regression models trained with the same data as on this report.