TimeSeries.OBeu v1.2.2 release on CRAN

We are very pleased to announce TimeSeries.OBeu v1.2.2 on CRAN!

TimeSeries.OBeu is used on OpenBudgets.eu data mininig tool platform with OpenCPU integration of R and JavaScript to estimate and return the needed parameters for visualizations designed for OpenBudgets.eu time series budget or expenditure data.

The vignette shows the way TimeSeries.OBeu (in R and OpenCPU environment) is fitted with datasets of OpenBudgets.eu according to the OpenBudgets.eu data model. Detailed documentation about OpenBudgets.eu data model can be found here.

First install TimeSeries.OBeu


and start using the library

# load TimeSeries.OBeulibrary(TimeSeries.OBeu)

Time Series analysis on OpenBudgets.eu platform

open_spending.ts is designed to estimate autocorrelation and partial autocorrelation of input time series data, autocorrelation and partial autocorrelation of the model residuals, trend, seasonal (if exists) and remainder components, model parameters such as arima order, arima coefficients etc. and the desired forecasts with their corresponding confidence intervals 

of OpenBudgets.eu time series data.

The input data must be a JSON link according to the OpenBudgets.eu data model. The user should specify the amount and time variables, future steps to be predicted (default is 1 step forward) and the arima order (if not specified the most appropriate model will be selected according to AIC value).

open_spending.ts input
Input Description


The json string, URL or file from Open Spending API


the time label of the json time series data


the amount label of the json time series data


An integer vector of length 3 specifying the order of the Arima model


The number of prediction steps

Stationary test

TimeSeries.OBeu includes function that automatically tests the deterministic and stochastic trend of the input time series data. This function uses ACF and PACF functions from forecast package, Phillips Perron test, Augmented Dickey Fuller (ADF) test, Kwiatkowski Phillips Schmidt Shin (KPSS) test, from tseries package and Mann Kendall test for Monotonic Trend Cox Stuart trend test from trend package.


Decomposition of seasonal time series data through arima models is based on stlm from forecast package and returns a list with useful parameters for OBEU. For non-seasonal time series that there is no seasonal component, local regression and likelihood models (locfit package) are used in order to extract the trend and remaider components.

Model Fitting

Model fit of time series using arima models of seasonal time series data. The model with the lowest AIC value is selected for forecasts.


Forecasts the model that fits the input data using the auto.arima function(see forecast package). The model selection depends on the results of some diagnostic tests (acf,pacf,pp adf and kpss). For short time series the selected arima model is among various orders of the AR part using the first differences and the first order moving average component, with the lower AIC value.


Here is a sort description of the outputs of each function:

open_spending.ts return
Component Output Description


  • acf
  • acf.lag
  • confidence.interval.up
  • confidence.interval.low
  • ACF values of the input time series
  • Lags at which the acf is estimated
  • Upper limit of the confidence interval
  • Lower limit of the confidence interval


  • pacf
  • pacf.lag
  • confidence.interval.up
  • confidence.interval.low
  • PACF values of the input time series
  • Lags at which the pacf is estimated
  • Upper limit of the confidence interval
  • Lower limit of the confidence interval


  • acf.res
  • acf.res.lag
  • confidence.interval.up
  • confidence.interval.low
  • ACF values of the model residuals
  • Lags at which the acf is estimated of the model residuals
  • Upper limit of the confidence interval
  • Lower limit of the confidence interval


  • pacf.res
  • pacf.res.lag
  • confidence.interval.up
  • confidence.interval.low
  • Pacf values of the model residuals
  • Lags at which the pacf is estimated of the model residuals
  • Upper limit of confidence interval
  • Lower limit of confidence interval


  • trend
  • trend.ci.up
  • trend.ci.low
  • seasonal
  • remainder
  • time
  • Trend component
  • Up limit for trend component
  • Low limit for trend component
  • Seasonal component
  • Remainder component
  • Time of the series was sampled


  • stl.degree
  • degfr
  • degfr.fitted
  • fitted
  • Degree of fit
  • Effective degrees of freedom
  • Fitted degrees of freedom
  • Model’s fitted values


  • residuals
  • Residuals of the model


  • arima.order
  • arima.coef
  • arima.coef.se
  • covariance.coef
  • resid.variance
  • not.used.obs
  • used.obs
  • loglik
  • aic
  • bic
  • gcv
  • aicc
  • Arima order
  • AR, MA and regression coefficients
  • Standard error of the coefficients
  • Variance of the coefficients
  • Residuals variance
  • Number of not used observations
  • Used observations
  • Maximized log-likelihood,
  • AIC value
  • BIC value
  • Generalized cross-validation statistic
  • Second-order AIC


  • ts.model
  • data_year
  • data
  • predict_time
  • predict_values
  • up80
  • low80
  • up95
  • low95
  • A string indicating the arima orders
  • Time of time series data
  • Time series values
  • Time of the predicted values
  • Predicted values
  • Upper 80% confidence limit
  • Lower 80% confidence limit
  • Upper 95% confidence limit
  • Lower 95% confidence limit


The dataset that is being used is a sample json string from OpenBudgets.eu platform.

In R environment

open_spending.ts function’s input are data as json link and described with OpenBudgets.eu data model.

#example openbudgets.eu time series datasample.ts.data = '{    "page": 0,
"page_size": 30,
"total_cell_count": 15,
"cell": [],
"status": "ok",
"cells": [{
"global__fiscalPeriod__28951.notation": "2002",
"global__amount__0397f.sum": 290501420.64,
"global__amount__0397f__CZK.sum": 9210928544.2325,
"_count": 4805
"global__fiscalPeriod__28951.notation": "2003",
"global__amount__0397f.sum": 311242291.07,
"global__amount__0397f__CZK.sum": 9832143974.9013,
"_count": 4988
"global__fiscalPeriod__28951.notation": "2004",
"global__amount__0397f.sum": 5268500701.1,
"global__amount__0397f__CZK.sum": 170688885714.24,
"_count": 10055
"global__fiscalPeriod__28951.notation": "2005",
"global__amount__0397f.sum": 2542887761.01,
"global__amount__0397f__CZK.sum": 77204615312.025,
"_count": 2032
"global__fiscalPeriod__28951.notation": "2006",
"global__amount__0397f.sum": 14803951786.68,
"global__amount__0397f__CZK.sum": 429758720367.32,
"_count": 13632
"global__fiscalPeriod__28951.notation": "2007",
"global__amount__0397f.sum": 16188514346.44,
"global__amount__0397f__CZK.sum": 445588857385.76,
"_count": 22798
"global__fiscalPeriod__28951.notation": "2008",
"global__amount__0397f.sum": 18231035815.89,
"global__amount__0397f__CZK.sum": 480643028250.12,
"_count": 24176
"global__fiscalPeriod__28951.notation": "2009",
"global__amount__0397f.sum": 19079541164.68,
"global__amount__0397f__CZK.sum": 511808691742.54,
"_count": 26250
"global__fiscalPeriod__28951.notation": "2010",
"global__amount__0397f.sum": 22738650575.01,
"global__amount__0397f__CZK.sum": 597685430364.14,
"_count": 87667
"global__fiscalPeriod__28951.notation": "2011",
"global__amount__0397f.sum": 24961375670.57,
"global__amount__0397f__CZK.sum": 626230992823.26,
"_count": 134352
"global__fiscalPeriod__28951.notation": "2012",
"global__amount__0397f.sum": 261513607691.41,
"global__amount__0397f__CZK.sum": 7030666436872.5,
"_count": 147556
"global__fiscalPeriod__28951.notation": "2013",
"global__amount__0397f.sum": 268946402299.09,
"global__amount__0397f__CZK.sum": 7226220232913.8,
"_count": 150079
"global__fiscalPeriod__28951.notation": "2014",
"global__amount__0397f.sum": 255222816704.9,
"global__amount__0397f__CZK.sum": 6907598086283.4,
"_count": 176019
"global__fiscalPeriod__28951.notation": "2015",
"global__amount__0397f.sum": 22976062973.62,
"global__amount__0397f__CZK.sum": 636276111928.46,
"_count": 213777
"global__fiscalPeriod__28951.notation": "2016",
"global__amount__0397f.sum": 12051686541.16,
"global__amount__0397f__CZK.sum": 325672725401.77,
"_count": 161797
"order": [
["global__fiscalPeriod__28951.fiscalPeriod", "asc"]
"aggregates": ["", "_count"],
"summary": {
"global__amount__0397f.sum": 945126777743.27,
"global__amount__0397f__CZK.sum": 25485085887878
"attributes": [""]
result = open_spending.ts(  json_data =  sample.ts.data,   time ="global__fiscalPeriod__28951.notation",  amount = "global__amount__0397f.sum"
# Pretty output using prettify of jsonlite library
jsonlite::prettify(result,indent = 2)

In OpenCPU environment

Select library and function

  1. Go to: yourserver/ocpu/test

  2. Copy and paste the following function to the endpoint

../library/TimeSeries.OBeu/R/open_spending.ts# library/ {name of the library} /R/ {function}
  1. Select Method: Post

Add parameters

Click add parameters every time you want to add a new parameters and values.

  1. Define the input data:

    • Param Name: json_data
    • Param Value: URL of json data or json string
  2. Define the time parameter:

    • Param Name: time
    • Param Value: Time label of the json time series data
  3. Define the amount parameter:

    • Param Name: amount
    • Param Value: Amount label of the json time series data

You add likewise x.order parameter to fit a specific arima order, see TimeSeries.OBeu reference manual for further details.

  1. Ready! Click on Ajax request!


  1. copy the /ocpu/tmp/{this_id_number}/R/.val (second on the right panel)

  2. finally, paste yourserver/ocpu/tmp/{this_id_number}/R/.val on a new tab.

Views: 874


You need to be a member of Data Science Central to add comments!

Join Data Science Central

© 2021   TechTarget, Inc.   Powered by

Badges  |  Report an Issue  |  Privacy Policy  |  Terms of Service