Type: | Package |
Title: | Brazilian Economic Time Series |
Version: | 0.4.9 |
Date: | 2018-08-25 |
Maintainer: | Talitha Speranza <talitha.speranza@fgv.br> |
Depends: | R (≥ 3.4) |
Imports: | grnn, ggplot2, plotly, urca, forecast, zoo, rmarkdown, foreign, seasonal, stringr, dygraphs, shiny (≥ 0.13), miniUI (≥ 0.1.1), rstudioapi (≥ 0.4), DT, webshot, RMySQL, digest,DBI, rjson, rvest, xml2, lubridate, htmltools, httr, dplyr, sqldf |
Suggests: | mFilter, devtools, xts, knitr |
Description: | It provides access to and information about the most important Brazilian economic time series - from the Getulio Vargas Foundation http://portal.fgv.br/en, the Central Bank of Brazil http://www.bcb.gov.br and the Brazilian Institute of Geography and Statistics http://www.ibge.gov.br. It also presents tools for managing, analysing (e.g. generating dynamic reports with a complete analysis of a series) and exporting these time series. |
License: | GPL-3 |
BugReports: | https://github.com/nmecsys/BETS/issues |
URL: | https://github.com/nmecsys/BETS |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 6.0.1 |
NeedsCompilation: | no |
Repository: | CRAN |
VignetteBuilder: | knitr |
Packaged: | 2018-09-26 02:09:09 UTC; jonatha |
Author: | Pedro Costa Ferreira [aut], Talitha Speranza [aut, cre], Jonatha Costa [aut], Fernando Teixeira [ctb], Daiane Marcolino [ctb] |
Date/Publication: | 2018-09-28 17:10:03 UTC |
BETS: A package for obtaining and analysing thousands of Brazilian economic time series.
Description
The Brazilian Economic Time Series (BETS) package provides access and information about the most important Brazilian economic time series.
These series are created by three influential centers: the Central Bank of Brazil (BCB), the Brazilian Institute of Geography and Statistics (IBGE) and the Brazilian Institute of Economics, from the Getulio Vargas Foundation (FVG-IBRE). Currently, there are more than 18.640 available time series, most of them free of charge. Besides providing access to this vast database, the package allows the user to interact with data in an easy and friendly way.
For instance, the user can search for a time series using keywords. More importantly, it installs several consecrated packages for time series analysis, giving the user the option to perform a complete analysis without having to worry about installing and loading other packages. In a near future, the authors will publish a series of R exercises to be solved with BETS and its statiscal/econometrical tools, therefore helping the user to understand the behavior of brazilian time series.
Note
The authors would like to thank the support by the Getulio Vargas Foundation (FGV) and make it clear that all data in the package is in public domain. The rights of all centers from which the series are taken are maintained. We reaffirm that BETS is mainly intended for academic usage.
Author(s)
Pedro Costa Ferreira pedro.guilherme@fgv.br, Jonatha Costa jonatha.costa@fgv.br, Talitha Speranza talitha.speranza@fgv.br, Fernando Teixeira fernando.teixeira@fgv.br
BETS search
Description
An interface for searching time series with possibility to extract the data in different extensions.
Usage
BETS.addin_en()
BETS search
Description
An interface for searching time series with possibility to extract the data in different extensions.
Usage
BETS.addin_pt()
Get a complete time series from a BETS database
Description
Extracts a complete time series from either the Central Bank of Brazil (BCB), the Brazilian Institute of Geography and Statistics (IBGE) or the Brazilian Institute of Economics (FGV/IBRE).
Usage
BETSget(code, from = "", to = "", data.frame = FALSE, frequency = NULL)
Arguments
code |
A |
from |
A |
to |
A |
data.frame |
A |
frequency |
An |
Value
A ts
(time series) object containing the desired series.
Note
Due to the significant size of the databases, it could take a while to retrieve the values. However, it shouldn't take more than 90 seconds.
See Also
ts
, BETSsearch
and seas
Examples
# Anual series: GDP at constant prices, in R$ (brazilian reais)
#BETSget(1208)
# International reserves - Cash concept
#int.reserves <- get("3543")
#plot(int.reserves)
# Exchange rate - Free - United States dollar (purchase)
#us.brl <- get(3691)
# Multiple requests
# BETSget(code = c(10777,4447),from = "2001-01-01", to = "2016-10-31")
# BETSget(code = c(10777,4447),from = c("2001-10-31",""),to = c("2016-10-31",""))
# f <- c("2001-10-31","1998-09-01")
# t <- c("2014-10-31","2015-01-01")
# BETSget(code = c(10777,4447), from = f, to = t)
# BETSget(code = c(10777,4447),from = "2001-10-31", to = c("2014-10-31","2015-01-01"))
# BETSget(code = c(10777,4447),from = c("2002-10-31","1997-01-01"), to = "2015-01-01")
Search for a Brazilian Economic Time Series
Description
Searches the BETS databases for a time series by its description, source, periodicity, code, data, unit of measurement and database name.
Usage
BETSsearch(description = "*", src, periodicity, unit, code, start,
view = FALSE, lang = "en")
Arguments
description |
A |
src |
A |
periodicity |
A |
unit |
A |
code |
An |
start |
A |
view |
A |
lang |
A |
Details
Syntax rules for the parameter
description
, the search string to look for matching series descriptions:To search for alternative words, separate them by white spaces. Example:
description = "ipca core"
means that the series description must contain 'ipca' AND'core'To search for whole expressions, surround them with
' '
. Example:description = "'core ipca' index"
means that the series description must contain 'core ipca' AND 'index'To exclude words from the search, insert a
~
before each of them. Example:description = "ipca ~ core"
means that the series description must contain 'ipca' AND must NOT contain 'core'To exclude whole expressions from the search, surround them with code' ' and insert a
~
before each of them. Example:description = "~ 'ipca core' index"
means that the series description must contain 'index' AND must NOT contain 'core ipca'It is possible to search for multiple words or expressions and to negate multiple words or expressions, as long as the preceeding rules are observed.
The white space after the negation sign (
~
) is not required. But the white spaces AFTER expressions or words ARE required.
Possible values for the parameter
src
:IBGE Brazilian Institute of Geography and Statistics BCB Central Bank of Brazil FGV Getulio Vargas Foundation FGv-IBRE Getulio Vargas Foundation - Brazilian Institute of Economics BCB e FGV Central Bank of Brazil and Getulio Vargas Foundation BCB-Deban Cetral Bank of Brazil - Department of Banking and Payments BCB-Depin Central Bank of Brazil - Department of International Reserves BCB-Derin Central Bank of Brazil - Department of International Affairs BCB-Desig Central Bank of Brazil - Department of Financial Monitoring BCB-Secre Central Bank of Brazil - Executive Secretariat BCB-Demab Central Bank of Brazil - Department of Open Market Operations BCB-Denor Central Bank of Brazil - Department of Financial System Regulation BCB-Depec Central Bank of Brazil - Department of Economics Sisbacen Central Bank of Brazil Information System Abecip Brazilian Association of Real Estate Loans and Savings Companies Possible values for the parameter
periodicity
:A anual data M monthly data Q quaterly data W weekly data D daily data Possible values for the parameter
unit
:R$ brazilian reais $ US dolars % percentage
Value
A list
that can be interpreted as a data.frame
. The fields are described below.
code | The code/index of the series within the database |
description | The description of the series |
periodicity | The periodicity of the series |
start | Starting date of the series |
source | The source of the series |
unit | The unit of measurement of the data |
References
Central Bank of Brazil
Examples
#not run
#BETSsearch(description="sales",view = FALSE)
#BETSsearch(src="Denor", view = FALSE)
#BETSsearch(periodicity="A", view = FALSE)
Display a list of sources available at BETS package
Description
Display a list of sources available at BETS package in console. The numbers of sources will increase wiht new versions of the package.
Usage
BETSsources()
Perform an ARCH test
Description
Performs an ARCH test and show the results. Formerly, this function was part of FinTS, now an obsoleted package.
Usage
arch_test(x, lags = 12, demean = FALSE, alpha = 0.5)
Arguments
x |
A |
lags |
An |
demean |
A |
alpha |
A |
Value
A list
with the results of the ARCH test
Author(s)
Spencer Graves spencer.graves@prodsyse.com, Talitha Speranza talitha.speranza@fgv.br
bcbExpectA
Description
Market Expectations with annual reference.
Usage
bcbExpectA(indicator = "IPCA", limit = 100, variables = c("Media",
"Mediana", "DesvioPadrao", "CoeficienteVariacao", "Minimo", "Maximo",
"numeroRespondentes", "baseCalculo"), start, end)
Arguments
indicator |
A string. Available indicator. |
limit |
A integer. A limint of data in request, top is 10000. |
variables |
Possible options: "Media", "Mediana", "DesvioPadrao", "CoeficienteVariacao", "Minimo", "Maximo". |
start |
Initial date at which the data was projected, in ISO format. |
end |
Final date at which the data was projected, in ISO format. |
Value
A data.frame.
Note
The available indicators are: Balanca comercial, Balanco de pagamentos, Fiscal, IGP-DI, IGP-M, INPC, IPA-DI, IPA-M, IPCA, IPCA-15, IPC-FIPE, Precos administrados por contrato e monitorado, Producao industrial, PIB Industrial, PIB Servicos, PIB Total, Meta para taxa over-selic e Taxa de cambio.
In collaboration with Angelo Salton <https://github.com/angelosalton>.
Examples
# bcbExpectA()
bcbExpectATop5
Description
Annual Market Expectations Top5.
Usage
bcbExpectATop5(indicator = "IGP-DI", limit = 100,
variables = c("tipoCalculo", "Media", "Mediana", "DesvioPadrao",
"CoeficienteVariacao", "Minimo", "Maximo"), start, end)
Arguments
indicator |
A string. Available indicator. |
limit |
A integer. A limint of data in request, top is 10000. |
variables |
Possible options: "Media", "Mediana", "DesvioPadrao", "CoeficienteVariacao", "Minimo", "Maximo". |
start |
Initial date at which the data was projected, in ISO format. |
end |
Final date at which the data was projected, in ISO format. |
Value
A data.frame.
Note
The available indicators are: IGP-DI, IGP-M, IPCA, Meta para taxa over-selic, Taxa de cambio.
Examples
# bcbExpectATop5()
bcbExpectInf12
Description
Market expectations for inflation in the next 12 months
Usage
bcbExpectInf12(indicator = "IPC-FIPE", limit = 100, variables = c("Media",
"Mediana", "DesvioPadrao", "CoeficienteVariacao", "Minimo", "Maximo",
"numeroRespondentes", "baseCalculo"), start, end)
Arguments
indicator |
A string. Available indicator. |
limit |
A integer. A limint of data in request, top is 10000. |
variables |
Possible options: "Media", "Mediana", "DesvioPadrao", "CoeficienteVariacao", "Minimo", "Maximo". |
start |
Initial date at which the data was projected, in ISO format. |
end |
Final date at which the data was projected, in ISO format. |
Value
A data.frame.
Note
The available indicators are: IGP-DI, IGP-M, INPC, IPA-DI, IPA-M, IPCA, IPCA-15, IPC-FIPE.
Examples
# bcbExpectInf12()
bcbExpectM
Description
Market Expectations with mensal reference.
Usage
bcbExpectM(indicator = "IPCA-15", limit = 100, variables = c("Media",
"Mediana", "DesvioPadrao", "CoeficienteVariacao", "Minimo", "Maximo",
"numeroRespondentes", "baseCalculo"), start, end)
Arguments
indicator |
A string. Available indicator. |
limit |
A integer. A limint of data in request, top is 10000. |
variables |
Possible options: "Media", "Mediana", "DesvioPadrao", "CoeficienteVariacao", "Minimo", "Maximo". |
start |
Initial date at which the data was projected, in ISO format. |
end |
Final date at which the data was projected, in ISO format. |
Value
A data.frame.
Note
The available indicators are: IGP-DI, IGP-M, INPC, IPA-DI, IPA-M, IPCA, IPCA-15, IPC-FIPE, Producao industrial, Meta para taxa over-selic, Taxa de cambio .
Examples
# bcbExpectM()
bcbExpectMTop5
Description
Monthly Market Expectations Top5.
Usage
bcbExpectMTop5(indicator = "IGP-DI", limit = 100,
variables = c("tipoCalculo", "Media", "Mediana", "DesvioPadrao",
"CoeficienteVariacao", "Minimo", "Maximo"), start, end)
Arguments
indicator |
A string. Available indicator. |
limit |
A integer. A limint of data in request, top is 10000. |
variables |
Possible options: "Media", "Mediana", "DesvioPadrao", "CoeficienteVariacao", "Minimo", "Maximo". |
start |
Initial date at which the data was projected, in ISO format. |
end |
Final date at which the data was projected, in ISO format. |
Value
A data.frame.
Note
The available indicators are: IGP-DI, IGP-M, IPCA, Meta para taxa over-selic, Taxa de cambio.
Examples
# bcbExpectMTop5()
bcbExpectT
Description
Quarterly Market Expectations.
Usage
bcbExpectT(indicator = "PIB Total", limit = 100, variables = c("Media",
"Mediana", "DesvioPadrao", "CoeficienteVariacao", "Minimo", "Maximo",
"numeroRespondentes"), start, end)
Arguments
indicator |
A string. Available indicator. |
limit |
A integer. A limint of data in request, top is 10000. |
variables |
Possible options: "Media", "Mediana", "DesvioPadrao", "CoeficienteVariacao", "Minimo", "Maximo". |
start |
Initial date at which the data was projected, in ISO format. |
end |
Final date at which the data was projected, in ISO format. |
Value
A data.frame.
Note
The available indicators are: PIB Agropecuario, PIB Industrial, PIB Serviços e PIB Total.
Examples
# bcbExpectT()
Create a chart with BETS aesthetics
Description
Create a professional looking chart, using a pre-defined BETS series or a custom series.
Usage
chart(ts, style = "normal", file = NULL, open = TRUE, lang = "en",
params = NULL)
Arguments
ts |
A |
style |
A |
file |
A |
open |
A |
lang |
A |
params |
A |
Details
Names of pre-defined charts:
1. Business Cycle Dashboard ('plotly' style)
VALUE | DESCRIPTION | CODE |
'iie_br' | Uncertainty Index | ST_100.0 |
'sent_ind' | Economic Sentiment Index (average between several confidence indexes) | (*) |
'gdp_mon' | GDP Monthly and Interanual Variation (last values) - GDP Monitor (FGV/IBRE) | (*) |
'ei_vars' | Economic Indicators (Leading and Coincident) monthly variation | (*) |
'ei_comps' | Economic Indicators (Leading and Coincident) components variation | (*) |
'lei' | Leading Economic Indicator (LEI - FGV/IBRE with The Conference Board) | (*) |
'cei' | Coincident Economic Indicator (CEI - FGV/IBRE with the Conference Board) | (*) |
'gdp_vars' | GDP components variation (whole series) - GDP Monitor (FGV/IBRE) | (*) |
'misery_index | Misery Index | 13522 plus 24369 |
'gdp_comps' | GDP components variation (last values) - GDP Monitor (FGV/IBRE) | (*) |
'gdp_unemp' | GDP monthly levels versus Unemployement Rate | 22109 and 24369 |
'conf_lvl' | Enterprises Confidence Index versus Consumers Confidence Index | (*) |
'inst_cap' | Installed Capacity Index | (*) |
'lab_lead' | Labor Leading Indicator | (*) |
'lab_coin' | Labor Coincident Indicator | (*) |
'transf_ind' | Transformation Industry Confidence Index (Expectations versus Present Situation) | (*) |
'servc' | Services Confidence Index (Expectations versus Present Situation) | (*) |
'constr' | Construction Confidence Index (Expectations versus Present Situation) | (*) |
'retail' | Retail Sellers Confidence Index (Expectations versus Present Situation) | (*) |
'consm' | Consumer Confidence Index (Expectations versus Present Situation) | (*) |
2. Macro Situation Dashboard ('normal' style)
VALUE | DESCRIPTION | CODE |
'ipca_with_core' | National consumer price index (IPCA) - in 12 months and Broad national consumer price index - Core IPCA trimmed means smoothed | 13522 and 4466 |
'ulc' | Unit labor cost - ULC-US$ - June/1994=100 | 11777 |
'eap' | Economically active population | 10810 |
'cdb' | Time deposits (CDB/RDB-preset) - Daily return (percentage) | 14 |
'indprod' | Prodcution Indicators (2012=100) - General | 21859 |
'selic' | Interest rate - Selic accumulated in the month in annual terms (basis 252) | 4189 |
'unemp' | Unemployment rate - by metropolitan region (PNAD-C) | 10777 |
'vargdp' | GDP - real percentage change in the year | 7326 |
(*) Not available on BETS databases yet. But you can find it in .csv files saved under your BETS installation directory.
3. Custom Charts
None of these parameters is required. Please note that some parameters only work for a certain type of chart.
PARAMETER | DESCRIPTION | WORKS FOR |
type | A character . Either 'bar' or 'lines'. Whether to plot bars or lines. Works for main series, only. | Both |
trend | A boolean . Default is FALSE . Set it to TRUE if the trend of the main series (parameter ts ) is to be drawn. | Both |
title | A character . Plot's title. | Both |
subtitle | A character . Plot's subtitle. | Both |
xlim | A numeric vector. X axis limits | Both |
ylim | A numeric vector. Y axis limits | Both |
arr.ort | A character . Orientation of the arrow pointing to the last value of the main series. Valid values are 'h' (horizontal) and 'v' (vertical). | 'normal' |
arr.len | A numeric value. Length of the arrow pointing to the last value of the main series. | 'normal' |
extra | A ts object. A second series to be plotted. | Both |
extra.y2 | A boolean . Default is FALSE . Does the extra series require a second y axis? | 'plotly' |
extra.arr.ort | A character . Orientation of the arrow pointing to the last value of the extra series. Valid values are 'h' (horizontal) and 'v' (vertical). | 'normal' |
extra.arr.len | A numeric value. Length of the arrow pointing to the last value of the extra series. | 'normal' |
colors | A character or integer vector. A vector of colors, one for each series. Trends will always be drawn in gray, its color can't be set. | Both |
legend | A character vector. Names of the series. Default is NULL (no legends). | Both |
legend.pos | A character . Legend position. If type is set to 'normal', possibile values are 'top' and 'bottom'; if type is set to 'plotly', either 'h' (horizontal) and 'v' (vertical). | Both |
codace | A boolean . Default is FALSE . Include shaded areas for recessions, as dated by CODACE(**)? | 'plotly' |
(**) Business Cycle Dating Committee (FGV/IBRE)
Value
If parameter file
is not set by the user, the chart will be shown at the standard R ploting area. Otherwise, it is going to be saved on your computer.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Examples
# chart(ts = "sent_ind", file = "animal_spirits", open = T)
# chart(ts = "gdp_mon", file = "gdp_mon.png", open = F)
# chart(ts = "misery_index")
# chart(ts = "transf_ind", file = "transf_ind.png", open = F)
Create a chart of the Unitary Labor Cost time series
Description
Creates a plot of series 11777
Usage
chart.add_basic(ts, xlim = NULL, ylim = NULL, type = "lines",
title = "", subtitle = "", col = "firebrick4", arr.size = NULL,
arr.pos = "v", leg.pos = "top", trend = FALSE)
Arguments
ts |
A |
xlim |
A |
ylim |
A |
type |
A |
title |
A |
subtitle |
A |
col |
A |
arr.size |
A |
arr.pos |
A |
leg.pos |
A |
trend |
A |
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Unitary Labor Cost time series
Description
Creates a plot of series 11777
Usage
chart.add_extra(ts, ylim = NULL, xlim = NULL, col = "firebrick3",
arr.size = NULL, arr.pos = "v", leg.pos = "top", leg.text = "",
main.type = "lines")
Arguments
ts |
A |
ylim |
A |
xlim |
A |
col |
A |
arr.size |
A . |
arr.pos |
A . |
leg.pos |
A . |
leg.text |
A . |
main.type |
A . |
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Add notes
Description
Add notes
Usage
chart.add_notes(series.list, xlim, ylim, names = NULL, dec = 2)
Arguments
series.list |
A |
xlim |
A |
ylim |
A |
names |
A |
dec |
An |
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Check series
Description
Check series in BETS dataset
Usage
check.series(ts, message = NULL)
Arguments
ts |
A |
message |
A |
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Connection with the server
Description
Make the connection with the server
Usage
connection()
Plot the ACF or the PACF of a time series
Description
Plot correlograms using plot.ly and several other options that differ theses plots from forecasts ACF and PACF.
Usage
corrgram(ts, lag.max = 12, type = "correlation", mode = "simple",
ci = 0.95, style = "plotly", knit = F)
Arguments
ts |
An object of type |
lag.max |
A |
type |
A |
mode |
A |
ci |
A |
style |
A |
knit |
A |
Value
A plot and a vector
containing the correlations.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a BETS custom dashboard
Description
Generate thematic dashboards using a selection of BETS time series and charts. For now, themes and charts are pre-defined.
Usage
dashboard(type = "business_cycle", charts = "all", saveas = NA,
parameters = NULL)
Arguments
type |
A |
charts |
A |
saveas |
A |
parameters |
A |
Details
Macro Situation and Custom Dashboard Parameters
text | The text to be printed in the dashboard. Separate paragraphs with two backslashes 'n' and pages with '##'. There are no other syntax rules. |
author | The author's name. |
email | The author's email. |
url | The author's webpage. |
logo | The author's business logo. |
Additional Custom Dashboard Parameters
style | A character . The style of the charts. As in chart , can be either 'plotly' or 'normal' . |
charts.opts | A list of parameters lists, one for each chart. Parameters are specified in chart |
Value
A .pdf file (the dashboard)
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Examples
# dashboard()
# dashboard(saveas = "survey.pdf")
# dashboard(type = "macro_situation")
Deflate a time series
Description
Deflate a time series using a deflator series. The deflator can be an index, a percentage or a point percentage series.
Usage
deflate(ts, deflator, type = "index")
Arguments
ts |
A |
deflator |
A |
type |
A |
Value
The deflated series.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.cap_utl()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Time Deposits time series
Description
Creates a plot of series 14
Usage
draw.cdb()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.cei()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.conf_lvl()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Economically Active Population time series
Description
Creates a plot of series 10810
Usage
draw.eap()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.ei_comps()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.ei_vars()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.gdp_comps()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.gdp_mon()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.gdp_unemp()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.gdp_vars()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.generic(ts, style, params)
Arguments
ts |
aaaa |
style |
aaa |
params |
aaa |
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.iie_br()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Production Indicators time series
Description
Creates a plot of series 21859
Usage
draw.indprod()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the National Consumer Price Index time series
Description
Creates a plot of series 13522 (NCPI), along with series 4466 (NCPI core)
Usage
draw.ipca()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.lab_coin()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.lab_lead()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.lei()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.misery_index()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.selic()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.sent_ind()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Base Interest Rate (SELIC) time series
Description
Creates a plot of series 4189
Usage
draw.survey(survey)
Arguments
survey |
xxx |
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create a chart of the Unitary Labor Cost time series
Description
Creates a plot of series 11777
Usage
draw.ulc()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Create a chart of the Open Unemployment Rate time series
Description
Creates a plot of series 10777
Usage
draw.unemp()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Create a chart of the Real Percentage Change of GDP in the Year time series
Description
Creates a plot of series 7326
Usage
draw.vargdp()
Value
An image file is saved in the 'graphs' folder, under the BETS installation directory.
Create a monthly or quarterly dummy
Description
Returns a monthly or quarterly dummy (a time series with only 0s and 1s).
Usage
dummy(start = NULL, end = NULL, frequency = 12, year = NULL,
month = NULL, quarter = NULL, date = NULL, from = NULL, to = NULL)
Arguments
start |
An |
end |
An |
frequency |
An |
year |
An |
month |
An |
quarter |
An |
date |
a |
from |
An |
to |
The ending period of a sequence of perids for which the dummy must be set to one. Periods must be represented as integer vectors, as described for |
Value
A monthly or a quarterly ts
object.
See Also
Examples
#1 from a specific date to another specific date
dummy(start = c(2000,1),end = c(2012,5),frequency = 12,from = c(2005,1),to = c(2006,12))
#Other options that may be helpful:
#over a month equal to 1
dummy(start = c(2000,1), end = c(2012,5), frequency = 12, month = c(5,12))
#Months equal to 1 only for some year
dummy(start = c(2000,1), end = c(2012,5), frequency = 12, month = 5, year = 2010)
dummy(start = c(2000,1), end = c(2012,5), frequency = 12, month = 8, year = 2002)
#Months equal to 1 only for some years
dummy(start = c(2000,1), end = c(2012,5), frequency = 12, month = 5, year = 2005:2007)
dummy(start = c(2000,1), end = c(2012,5), frequency = 12, month = 3, year = c(2005,2007))
dummy(start = c(2000,1), end = c(2012,5), frequency = 12, month = 5:6, year = c(2005,2007))
#specific dates
dummy(start = c(2000,1), end = c(2012,5), frequency = 12, date = list(c(2010,1)))
dummy(start = c(2000,1), end = c(2012,5),
freq = 12, date = list(c(2010,9), c(2011,1), c(2000,1)) )
Get a complete time series from a BETS database
Description
Extracts a complete time series from either the Central Bank of Brazil (BCB), the Brazilian Institute of Geography and Statistics (IBGE) or the Brazilian Institute of Economics (FGV/IBRE).
Usage
get.series(code, from = "", to = "", data.frame = FALSE,
frequency = NULL)
Arguments
code |
A |
from |
A |
to |
A |
data.frame |
A |
frequency |
An |
A function to extract BACEN series using their API
Description
A function to extract BACEN series using their API
Usage
get.series.bacen(x, from = "", to = "", save = "")
Arguments
x |
Bacen series numbers. Either an integer or a numeric vector. |
from |
A string specifying where the series shall start. |
to |
A string specifying where the series shall end. |
save |
A string specifying if data should be saved in csv or xlsx format. Defaults to not saving. |
Author(s)
Fernando Teixeira fernando.teixeira@fgv.br and Jonatha Azevedo jonatha.costa@fgv.br
Test a set of General Regression Neural Networks
Description
Given new values of the independent variables, tests a list of trained GRNNs and picks the best net, based on an accuracy measure between the forecasted and the actual values.
Usage
grnn.test(results, test.set)
Arguments
results |
The object returned by grnn.train. |
test.set |
A |
Value
A list
object representing the best network (according to forecasting MAPE). Its fields are:
mape
: The forecasting MAPEmodel
: The network objectsigma
: The sigma parameterid
: The id number of the network, as given by grnn.trainmean
: The predicted valuesx
: The original seriesfitted
: The fitted valuesactual
: The actual values (to be compared with the predicted values)residuals
: Difference between the fitted values and the series original valuesregressors
: The regressors used to train the network
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Train a General Regression Neural Network
Description
Creates a set of probabilistic neural networks as proposed by Specht [1991]. The user provides a set of regressors and the function chooses which subset is the best, based on an accuracy measure (by default, the MAPE) between fited and actual values. These networks have only one parameter, the sigma
, which is the standard deviation of each activation function (gaussian) of the pattern layer. Sigma can also be automatically chosen. This function builds on grnn-package.
Usage
grnn.train(train.set, sigma, step = 0.1, select = TRUE, names = NA)
Arguments
train.set |
A |
sigma |
A |
step |
A |
select |
A |
names |
A |
Value
A list
of result objects, each representing a network. These objects are ordered by MAPE (the 20 best MAPEs) and its fields are:
accuracy
: Anumeric
value. Accuracy measure between the fitted and the actual series values. By default, the MAPE. In future versions, it will be possible to change it.fitted
: The fitted values, that is, one step ahead predicitions calculated by the trained net.net
: An object returned by the grnn function. Represents a trained net.sigma
: Anumeric
. The sigma that was chosen, either by the user or by the function itself (in caseselect
was set toTRUE
)regressors
: Acharacter vector
. Regressors that were chosen, either by the user or by the fuction itself (in caseselect
was set toTRUE
)sigma.accuracy
: Adata.frame
. Sigma versus accuracy value of the corresponding trained network. Those networks were trained using the best set of regressors.residuals
: Anumeric vector
. Fitted values subtracted from the actual values.
grnn.train also returns a diagnostic of training rounds and a sigma
versus accuracy
plot.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Format and show a console message.
Description
Customizes a message and shows it in the console.
Usage
msg(..., skip_before = TRUE, skip_after = FALSE, warn = FALSE)
Arguments
... |
Arguments to be passed to |
skip_before |
A |
skip_after |
A |
warn |
A |
Value
None
Author(s)
Talitha Speranza talitha.speranza@fgv.br, Jonatha Azevedo jonatha.azevedo@fgv.br
Normalize a time series
Description
Normalizes a time series, either by stardization or by mapping to values between 0 and 1.
Usage
normalize(series, mode = "scale")
Arguments
series |
A |
mode |
A |
Value
A ts
object or a ts list
. The normalized series.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Get the predicted values of a model and visualize it
Description
This function is built upon forecast. Besides the model predictions, it returns an accuracy measure table (calculated by the accuracy function) and a graph showing the original series, the predicted values and the actual values.
Usage
predict(..., actual = NULL, main = "", ylab = "", xlim = NULL,
style = "dygraphs", unnorm = NULL, legend.pos = "topright", knit = F)
Arguments
... |
arguments passed on to forecast. If the model is a neural network, these arguments will be passed on to grnn.test. |
actual |
A |
main |
A |
ylab |
A |
xlim |
A |
style |
A |
unnorm |
A |
legend.pos |
A |
knit |
A |
Value
Besides the prediction plot, this function returns an object whose fields are:
accuracy
: An object returned by accuracy. It is a table containing several accuracy measurespredictions
: Anumeric vector
containing the predicted values.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Create dynamic reports with a full analysis of a set of time series
Description
Generate automatic reports with a complete analysis of a set of time series. For now, SARIMA (Box & Jenkins approach), Holt-Winters and GRNN analysis are possible. Soon, Multilayer Perceptron, Fuzzy Logic and Box-Cox analysis will become available.
Usage
report(mode = "SARIMA", ts = 21864, parameters = NULL, report.file = NA,
series.saveas = "none")
Arguments
mode |
A |
ts |
A |
parameters |
A |
report.file |
A |
series.saveas |
A |
Details
SARIMA Report Parameters
cf.lags
: Aninteger
. Maximum number of lags to show on the ACFs e PACFsn.ahead
: Aninteger
. Prevision horizon (number of steps ahead)inf.crit
: Acharacter
. Information criterion to be used in model selection.dummy
: Ats
object. A dummy regressor. Must also cover the forecasting period.ur.test
: Alist
. Parameters ofur_test
arch.test
: Alist
. Parameters ofarch_test
box.test
: Alist
. Parameters ofBox.test
GRNN Report Parameters
auto.reg
: Aboolean
. Is the dependant variable auto-regressive?present.regs
: Aboolean
Include non-lagged series among regressors?lag.max
: Ainteger
Regressors' maximum lagregs
: Alist
. Regressors codes or time seriesstart.train
: Training set starting periodend.train
: Training set ending periodstart.test
: Testing set starting periodend.test
: Testing set ending periodsigma.interval
: Anumeric
vector. Sigma intevalsigma.step
: Anumeric
value. Sigma stepvar.names
: Acharacter
vector. Variable names
HOLT-WINTERS Report Parameters
alpha
: Smooth factor of the level component. If numeric, it must be within the half-open unit interval (0, 1]. A small value means that older values in x are weighted more heavily. Values near 1.0 mean that the latest value has more weight. NULL means that the HoltWinters function should find the optimal value of alpha. It must not be FALSE or 0.beta
: Smooth factor of the trend component. If numeric, it must be within the unit interval [0, 1]. A small value means that older values in x are weighted more heavily. Values near 1.0 mean that the latest value has more weight. NULL means that the HoltWinters function should find the optimal value of beta. The trend component is omitted if beta is FALSE or 0.gamma
: Smooth factors of the seasonal component. If numeric, it must be within the unit interval [0, 1]. A small value means that older values in x are weighted more heavily. Values near 1.0 mean that the latest value has more weight. NULL means that the HoltWinters function should find the optimal value of gamma. The seasonal component will be omitted if gamma is FALSE or 0. This must be specified as FALSE if frequency(x) is not an integer greater than 1.additive
: A single character string specifying how the seasonal component interacts with the other components. "additive", the default, means that x is modeled as level + trend + seasonal and "multiplicative" means the model is (level + trend) * seasonal. Abbreviations of "additive" and "multiplicative" are accepted.l.start
: The starting value of the level component.b.start
: The starting value of the trend components.start
: The starting values of seasonal component, a vector of length frequency(x)n.ahead
: Prevision horizon (number of steps ahead)
For more information about these parameters, see also HoltWinters
. Most parameters are the same and we just reproduced their documentation here.
Value
One or more .html files (the reports) and, optionally, data files (series plus predictions).
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Examples
##-- SARIMA
# parameters = list(lag.max = 48, n.ahead = 12 )
# report(ts = 21864, parameters = parameters)
# report(ts = 4447, series.saveas = "csv")
# series = list(BETSget(4447), BETSget(21864))
# parameters = list(lag.max = 20, n.ahead = 15 )
# report(ts = series, parameters = parameters)
# series = list(4447, 21864)
# report(ts = series, parameters = parameters)
# parameters = list(
# cf.lags = 25,
# n.ahead = 15,
# dummy = dum,
# arch.test = list(lags = 12, alpha = 0.01),
# box.test = list(type = "Box-Pierce")
# )
# report(ts = window(BETSget(21864), start= c(2002,1) , end = c(2015,10)),
#parameters = parameters)
# dum <- dummy(start= c(2002,1) , end = c(2017,1) ,
#from = c(2008,9) , to = c(2008,11))
# parameters = list(
# cf.lags = 25,
# n.ahead = 15,
# dummy = dum
# )
# report(ts = window(BETSget(21864), start= c(2002,1) , end = c(2015,10)),
#parameters = parameters)
##-- GRNN
# params = list(regs = 4382)
# report(mode = "GRNN", ts = 13522, parameters = params)
##-- HOLT-WINTERS
# params = list(alpha = 0.5, gamma = TRUE)
# report(mode = "HOLT-WINTERS", ts = 21864, series.saveas = "csv", parameters = params)
# params = list(gamma = T, beta = TRUE)
# report(mode = "HOLT-WINTERS", ts = 21864, series.saveas = "csv", parameters = params)
Prepare a time series to be exported
Description
To be used with saveSpss, saveSas and others.
Usage
save(code = NULL, data = NULL, file.name = "series", type = "")
Arguments
code |
An |
data |
A |
file.name |
A |
type |
A |
Value
A list with the data frame to be saved and the file name
Export a time series to SAS
Description
Writes a time series to a .sas (SAS) file.
Usage
saveSas(code = NULL, data = NULL, file.name = "series")
Arguments
code |
An |
data |
A |
file.name |
A |
Value
None
Examples
#Exchange rate - Free - United States dollar (purchase)
#us.brl <- get(3691)
#require(seasonal)
#us.brl.seasonally_adjusted <- seas(us.brl)
#saveSas(data = us.brl.seasonally_adjusted,file.name="us.brl.seasonally_adjusted")
# Or
#saveSas(code=3691,file.name="us.brl")
Export a time series to SPSS
Description
Writes a time series to a .spss (SPSS) file.
Usage
saveSpss(code = NULL, data = NULL, file.name = "series")
Arguments
code |
An |
data |
A |
file.name |
A |
Examples
#Exchange rate - Free - United States dollar (purchase)
#us.brl <- get(3691)
#requires(seasonal)
#us.brl.seasonally_adjusted <- seas(us.brl)
#saveSpss(data = us.brl.seasonally_adjusted,file.name="us.brl.seasonally_adjusted")
# Or
#saveSpss(code=3691,file.name="us.brl")
Export a time series to STATA
Description
Writes a time series to a .dta (STATA) file.
Usage
saveStata(code = NULL, data = NULL, file.name = "series")
Arguments
code |
An |
data |
A |
file.name |
A |
Value
None
Examples
#Exchange rate - Free - United States dollar (purchase)
#us.brl <- get(3691)
#requires(seasonal)
#us.brl.seasonally_adjusted <- seas(us.brl)
#saveStata(data = us.brl.seasonally_adjusted,file.name="us.brl.seasonally_adjusted")
# Or
#saveStata(code=3691,file.name="us.brl")
Search for Sidra Series
Description
Searches the Sidra databases for a series by its description or a given table descriptions.
Usage
sidra.aux(x, len, nova_req, from, to, inputs, territory, variable, header,
sections)
Arguments
x |
Either a character or a numeric. If character, function searches the Sidra metadata. If a numeric argument is provided the descriptions of the given table are seached . |
len |
A . |
nova_req |
A . |
from |
A . |
to |
A . |
inputs |
A . |
territory |
A . |
variable |
A . |
header |
A . |
sections |
A . |
A function to extract Sidra series using their API
Description
The different parameters define the table and its dimensions (periods, variables, territorial units and classification) to be consulted. The parameters that define the sections may vary from table to table. Henceforth, the Sidra function ranges between 5 mandatory arguments to 7. You can only choose one variable per series per request, but multiple sections within the variable.
Usage
sidraGet(x, from, to, territory = c(n1 = "brazil", n2 = "region", n3 =
"state", n6 = "city", n8 = "mesoregion", n9 = "microregion", n129 =
"citizenship", n132 = "semiarid", n133 = "semiaridUF"), variable, cl = NULL,
sections = NULL)
Arguments
x |
Sidra series number. |
from |
A string or character vector specifying where the series shall start |
to |
A string or character vector specifying where the series shall end |
territory |
Specifies the desired territorial levels. |
variable |
An integer describing what variable characteristics are to be returned. Defaults to all available. |
cl |
A vector containing the classification codes in a vector. |
sections |
A vector or a list of vectors if there are two or more classification codes containing the desired tables from the classification. |
Examples
## Not run: sidra = sidraGet(x = c(1612), from = 1990, to = 2015, territory = "brazil", variable =109)
sidra = sidraGet(x = c(3653), from = c("200201"),
to = c("201703"), territory = "brazil",
variable = 3135, sections = c(129316,129330), cl = 544)
sidra = sidraGet(x = c(3653), from = c("200201"),
to = c("201512"), territory = "brazil", variable = 3135,
sections = "all", cl = 544)
sidra = sidraGet(x = c(1618), from = c("201703"), to = c("201703"),
territory = "brazil",
variable = 109, sections=list(c(39427), c(39437,39441)), cl = c(49, 48))
trim - x = 1620; from = 199001; to = 201701; territory = "brazil";
sections = list(c(90687)); cl =c(11255); variable = 583
sidra = sidraGet(x = 1620, from = 199001, to = 201701,
territory = "brazil",
sections=list(c(90687)), cl =c(11255), variable = 583)
## End(Not run)
Search for Sidra Series
Description
Searches the Sidra databases for a series by its description or a given table descriptions.
Usage
sidraSearch(description = NULL, code, view = TRUE, browse = FALSE)
Arguments
description |
A |
code |
A numeric argument must be provided. The descriptions of the given table are returned. |
view |
A |
browse |
A |
Examples
## Not run:
sidraSearch(description = "pib")
sidraSearch(code = 1248)
## End(Not run)
Plot standardized residuals
Description
Uses a model object to create a plot of standardized residuals. This model can be an Arima or an arima. In a near future, this function will also accept objects returned by grnn.train.
Usage
std_resid(model, alpha = 0.05)
Arguments
model |
|
alpha |
A |
Value
Besides showing the plot, this function returns a numeric vector
containing the standardized residuals.
Author(s)
Talitha Speranza talitha.speranza@fgv.br
Test the significance of the parameters of an ARIMA model
Description
Performs the t test on every parameter of an ARIMA model. This model can be an Arima or an arima.
Usage
t_test(model, nx = 0, alpha = 0.05)
Arguments
model |
An Arima or an arima object. The model for which the parameters must be tested. |
nx |
An |
alpha |
A |
Value
A data.frame
containing the standard erros, the t-statistic, the critical values and whether the null hypothesis should be rejected or not, for each model parameter.
Author(s)
Talitha Speranza talitha.speranza@fgv.br, Daiane Marcolino daiane.mattos@fgv.br
Examples
require(forecast)
data("AirPassengers")
fit.air<- Arima(AirPassengers,order = c(1,1,1), seasonal = c(1,1,1), method ="ML",lambda=0)
summary(fit.air)
# Significance test for the model SARIMA(1,1,1)(1,1,1)[12]
t_test(model = fit.air)
Perform unit root tests
Description
This function uses the package 'urca' to perform unit root tests on a pre-defined time series. Unlike urca functions, it returns a meaningful table summarizing the results.
Usage
ur_test(..., mode = "ADF", level = "5pct")
Arguments
... |
Arguments passed on to urca functions |
mode |
A |
level |
A |
Value
A list
object. The first element is a data.frame
with the test statistics, the critical values and the test results. The second, the model residuals.
Author(s)
Talitha Speranza talitha.speranza@fgv.br