Movatterモバイル変換


[0]ホーム

URL:


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 Foundationhttp://portal.fgv.br/en, the Central Bank of Brazilhttp://www.bcb.gov.br and the Brazilian Institute of Geography and Statisticshttp://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 andinformation about the most important Brazilian economic time series.

These series are created by three influential centers: the Central Bank ofBrazil (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, mostof them free of charge. Besides providing access to this vast database, thepackage 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. Moreimportantly, it installs several consecrated packages for time seriesanalysis, giving the user the option to perform a complete analysis withouthaving to worry about installing and loading other packages. In a nearfuture, the authors will publish a series of R exercises to be solved withBETS and its statiscal/econometrical tools, therefore helping the user tounderstand the behavior of brazilian time series.

Note

The authors would like to thank the support by the GetulioVargas Foundation (FGV) and make it clear that alldata in the package is in public domain. The rights of all centers fromwhich the series are taken are maintained. We reaffirm that BETSis mainly intended for academic usage.

Author(s)

Pedro Costa Ferreirapedro.guilherme@fgv.br,Jonatha Costajonatha.costa@fgv.br,Talitha Speranzatalitha.speranza@fgv.br,Fernando Teixeirafernando.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

Acharacter or aninteger. The unique code that references the time series. This code can be obtained by using thesearch function. More than one code can be provided at once, through a vector. In this case, be careful with the dates, i.e, parametersfrom andto. They must either be the same length ascode, containing the date limits in order, or an isolated date, but nothing in between. See the examples section.

from

Acharacter or aData object. Starting date of the time series (format YYYY-MM-DD). Can be a vector of dates/characters if the length of the parametercode is greater than 1.

to

Acharacter or aData object. Ending date of the time series (format YYYY-MM-DD). Can be a vector of dates/characters if the length of the parametercode is greater than 1.

data.frame

Aboolean. True if you want the output to be a data frame. True tots output.

frequency

Aninteger. The frequency of the time series. It is not needed. It is going to be used only if the metadata for the series is corrupted.

Value

Ats (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 andseas

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

Acharacter. A search string to look for matching series descriptions. Check the syntax rules under the 'Details' section for better performance.

src

Acharacter. The source of the series. See the 'Details' section for a list of the available sources.

periodicity

Acharacter. The periodicity of the series. See the 'Details' section for a list of possible values.

unit

Acharacter. The unit of measurement of the data. See the 'Details' section for a list of possible values.

code

Aninteger. The index of the series within the database.

start

Adate. Starting date of the series.

view

Aboolean. The default isTRUE. If set toFALSE, the output'shead will be printed in your console as adata.frame.

lang

Acharacter. The search language. The default is "en" for english, but "pt" for portuguese is also possible.

Details

Value

Alist that can be interpreted as adata.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 ofsources 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

Ats object. The time series

lags

Aninteger. Maximum number of lags

demean

Aboolean. Should the series be demeaned?

alpha

Anumeric value. Significance level

Value

Alist with the results of the ARCH test

Author(s)

Spencer Gravesspencer.graves@prodsyse.com, Talitha Speranzatalitha.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

Acharacter or ats object. A custom time series or the name of a pre-defined series. A complete list of names is under the 'Details' section.

style

Acharacter. Should the chart be made with Plotly (style = "plotly") or with R standard library (style = "normal")?

file

Acharacter. The whole path, including a custom name, for the output (an image file). The default value is NULL. If left to NULL, the chart will be rendered in the standard R plotting area.

open

Aboolean. Whether to open the file containing the chart.

lang

Acharacter. The language. For now, only 'en' (english) is available.

params

Alist. Parameters for drawing custom charts. See the 'details' section.

Details

Names of pre-defined charts:

1. Business Cycle Dashboard ('plotly' style)

VALUEDESCRIPTIONCODE
'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)

VALUEDESCRIPTIONCODE
'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.

PARAMETERDESCRIPTIONWORKS FOR
type Acharacter. Either 'bar' or 'lines'. Whether to plot bars or lines. Works for main series, only. Both
trend Aboolean. Default isFALSE. Set it toTRUE if the trend of the main series (parameterts) is to be drawn. Both
title Acharacter. Plot's title. Both
subtitle Acharacter. Plot's subtitle. Both
xlim Anumeric vector. X axis limits Both
ylim Anumeric vector. Y axis limits Both
arr.ort Acharacter. Orientation of the arrow pointing to the last value of the main series. Valid values are 'h' (horizontal) and 'v' (vertical).'normal'
arr.len Anumeric value. Length of the arrow pointing to the last value of the main series.'normal'
extra Ats object. A second series to be plotted. Both
extra.y2 Aboolean. Default isFALSE. Does the extra series require a second y axis?'plotly'
extra.arr.ort Acharacter. 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 Anumeric value. Length of the arrow pointing to the last value of the extra series.'normal'
colors Acharacter orinteger vector. A vector of colors, one for each series. Trends will always be drawn in gray, its color can't be set. Both
legend Acharacter vector. Names of the series. Default isNULL (no legends). Both
legend.pos Acharacter. Legend position. Iftype is set to'normal', possibile values are 'top' and 'bottom'; iftype is set to'plotly', either 'h' (horizontal) and 'v' (vertical). Both
codace Aboolean. Default isFALSE. Include shaded areas for recessions, as dated by CODACE(**)?'plotly'

(**) Business Cycle Dating Committee (FGV/IBRE)

Value

If parameterfile 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 Speranzatalitha.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

Ats. the ts object.

xlim

Anumeric vector. x axis limits.

ylim

Anumeric vector. Y axis limits.

type

Acharacter. The type of of plot (lines).

title

Acharacter. The plot title.

subtitle

Acharacter. The plot subtitle.

col

Acharacter. Color.

arr.size

Avector.

arr.pos

Avector.

leg.pos

Avector.

trend

Aboolean.

Value

An image file is saved in the 'graphs' folder, under the BETS installation directory.

Author(s)

Talitha Speranzatalitha.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

Ats. the ts object.

ylim

Anumeric vector. Y axis limits.

xlim

Anumeric vector. x axis limits.

col

Acharacter. Color.

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 Speranzatalitha.speranza@fgv.br


Add notes

Description

Add notes

Usage

chart.add_notes(series.list, xlim, ylim, names = NULL, dec = 2)

Arguments

series.list

Ats object

xlim

Avector

ylim

Avector

names

Acharacter

dec

Aninteger

Author(s)

Talitha Speranzatalitha.speranza@fgv.br


Check series

Description

Check series in BETS dataset

Usage

check.series(ts, message = NULL)

Arguments

ts

Ats object

message

Acharacter

Author(s)

Talitha Speranzatalitha.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 fromforecasts 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 typets orxts. The time series for which the plot must be constructed.

lag.max

Anumeric value. The number of lags to be shown in the plot.

type

Acharacter. Can be either 'correlation' (for the ACF) or 'partial' (for the PACF).

mode

Acharacter. Set this parameter to 'bartlett' if you want the variance to be calculated according toBartlett's formula. Otherwise, it is going to be simply equal to1/sqrt(N).

ci

Anumeric value. The confidence interval to be shown in the plot.

style

Acharacter. Set this parameter to 'normal' if you want it made with ggplot2 or to 'plotly' if you want to be aplotly object.

knit

Aboolean. If you're using this function to exhibit correlograms on a R dynamic report, set this parameter to true.

Value

A plot and avector containing the correlations.

Author(s)

Talitha Speranzatalitha.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

Acharacter. The theme of the dashboard. The only three options, for the time being, is 'business_cycle', 'macro_situation' and 'custom'. Custom dashboards can be rendered with any given set of charts.

charts

Acharacter and/orts object list. The charts to be added to a custom dashboard. Up to 16 charts are allowed, including pre-defined charts, identified by their codes (seechart). This will only work if parameter 'type' is set to 'custom'.

saveas

Acharacter. A path and a name for the dashboard file (a .pdf file). If this parameter is not provided, the dashboard will be saved inside the 'dashboards' folder, under the BETS installation directory.

parameters

Alist. A list of parameters. See the 'Details' section for a description of these parameters for each type of dashboard.

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 Acharacter. The style of the charts. As inchart, can be either'plotly' or'normal'.
charts.opts Alist of parameters lists, one for each chart. Parameters are specified inchart

Value

A .pdf file (the dashboard)

Author(s)

Talitha Speranzatalitha.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

Ats object. The time series to be deflated.

deflator

Ats object. The deflator series.

type

Acharacter. Can be either'index','point.perc' (for point percentage) or'perc' (for percentage).

Value

The deflated series.

Author(s)

Talitha Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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 Speranzatalitha.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

Aninteger vector. The period of the first observation. The first element of thevector specifies the year of the first observation, whereas the second, the month (for monthly dummies) or quarter (for quarterly dummies)

end

Aninteger vector. The period of the last observation. The first element of thevector specifies the year of the last observation, whereas the second, the month (for monthly dummies) or quarter (for quarterly dummies)

frequency

Aninteger. The frequency of the dummy, that is, the number of observations per unit of time. The defaulf is 12 (a monthly dummy).

year

Aninteger, aseq or avector. The years for which the dummy must be set to 1. All periods of these years will be set to 1.

month

Aninteger, aseq or avector. The months for which the dummy must be set to 1. These months will be set to 1 for all years.

quarter

Aninteger, aseq or avector. The quarters for which the dummy must be set to 1. The quarters will be set to 1 for all years.

date

alist. The periods for which the dummy must be set to one. Periods must be represented as integer vectors, as described forstart andend.

from

Aninteger vector The starting period of a sequence of perids for which the dummy must be set to one. Periods must be represented as integer vectors, as described forstart andend.

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 forstart andend.

Value

A monthly or a quarterlyts object.

See Also

ts,dummy

Examples

#1 from a specific date to another specific datedummy(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 1dummy(start = c(2000,1), end = c(2012,5), frequency = 12, month = c(5,12))#Months equal to 1 only for some yeardummy(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 yearsdummy(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 datesdummy(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

Acharacter. The unique code that references the time series. This code can be obtained by using theBETSsearch function.

from

Acharacter or aData object. Starting date of the time series (format YYYY-MM-DD).

to

Acharacter or aData object. Ending date of the time series (format YYYY-MM-DD).

data.frame

Aboolean. True if you want the output to be a data frame. True tots output.

frequency

Aninteger. The frequency of the time series. It is not needed. It is going to be used only if the metadata for the series is corrupted.


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 Teixeirafernando.teixeira@fgv.br and Jonatha Azevedojonatha.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 bygrnn.train.

test.set

Ats list. The first element must be the actual values of the dependent variable. The others, the new values of the regressors.

Value

Alist object representing the best network (according to forecasting MAPE). Its fields are:

Author(s)

Talitha Speranzatalitha.speranza@fgv.br


Train a General Regression Neural Network

Description

Creates a set of probabilistic neural networks as proposed bySpecht [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, thesigma, which is the standard deviation of each activation function (gaussian) of the pattern layer. Sigma can also be automatically chosen. This function builds ongrnn-package.

Usage

grnn.train(train.set, sigma, step = 0.1, select = TRUE, names = NA)

Arguments

train.set

Ats list (a list ofts objects). The first element must be the dependent variable. The other elements, the regressors.

sigma

Anumeric or anumeric vector. The sigma parameter, that is, the standard deviation of the activation functions (gaussians) of the pattern layer. Can be either a fixed value or a range (a vector containing the minimum and the maximum values).

step

Anumeric value. Ifsigma is a range, the user must provide a step value to vary sigma. The function is going to select the best sigma based on MAPE.

select

Aboolean. Must be set toFALSE if the regressors should not be chosen. The default isTRUE.

names

Acharacter vector. Optional. The names of the regressors. If not provided, indexes will be used and reported.

Value

Alist of result objects, each representing a network. These objects are ordered by MAPE (the 20 best MAPEs) and its fields are:

grnn.train also returns a diagnostic of training rounds and asigma versusaccuracy plot.

Author(s)

Talitha Speranzatalitha.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 tomessage

skip_before

Aboolean. Indicates if a line should be skipped before the message.

skip_after

Aboolean. Indicates if a line should be skipped after the message.

warn

Aboolean. Indicates whether a warning should be thrown.

Value

None

Author(s)

Talitha Speranzatalitha.speranza@fgv.br, Jonatha Azevedojonatha.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

Ats object or ats list. The series to be normalized.

mode

Acharacter. The normalization method. Set this parameter to 'maxmin' to map series values to values between 0 and 1. Alternatively, set this parameter to 'scale' to standardize (substract the mean and divide by the standard deviation).

Value

Ats object or ats list. The normalized series.

Author(s)

Talitha Speranzatalitha.speranza@fgv.br


Get the predicted values of a model and visualize it

Description

This function is built uponforecast. Besides the model predictions, it returns an accuracy measure table (calculated by theaccuracy 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 toforecast. If the model is a neural network, these arguments will be passed on togrnn.test.

actual

Anumeric vector. The actual values (to be compared with predicted values).

main

Acharacter. The name of the prediction plot.

ylab

Acharacter. The Y axis label.

xlim

Anumeric vector. The limits of the X axis.

style

Acharacter. Can be either 'dygraphs' (thedygraph function will be use to make the plot, which is going to be HTML based) or 'normal' (standard R functions will be used to make the plot)

unnorm

Anumeric vector. If predictions must be unnormalized, set the first element of this vector to the mean and the second, to the standard deviation.

legend.pos

Acharacter. The position of the legend. Possible values are standard R plot values, i.e., "topright', "bottomleft', etc.

knit

Aboolean. Set this parameter toTRUE if

Value

Besides the prediction plot, this function returns an object whose fields are:

Author(s)

Talitha Speranzatalitha.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

Acharacter.The type of the analysis. So far, 'SARIMA', 'GRNN' and 'HOLT-WINTERS' are available.

ts

Ainteger, ats object or alist ofintegers andts objects. Either the ID of the series in the BETS database or a time series object (any series, not just BETS's). If alist is provided, a report is generated for each series in this list, which can be mixed with IDs and time series objects.

parameters

Alist. The parameters of the report. See the 'details' section for more information.

report.file

Acharacter. A path and a name for the report file (an .html file). If there is more than one series, this name will be used as a prefix. If this parameter is not provided, the report will be saved inside the 'reports' folder, under the BETS installation directory.

series.saveas

Acharacter. The format of the file on which the series and the predictions should be written. Possible values are 'none' (default), 'sas', 'dta', 'spss', 'csv', 'csv2' . Is is saved under the same directory as the report file.

Details

SARIMA Report Parameters

GRNN Report Parameters

HOLT-WINTERS Report Parameters

For more information about these parameters, see alsoHoltWinters. 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 Speranzatalitha.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

Aninteger. The unique identifier of the series within the BETS database.

data

Adata.frame or ats. Contains the data to be written. Ifdata is supplied, the BETS database will not be searched.

file.name

Acharacter. The name of the output file. The default is 'series.spss'.

type

Acharacter. The type of the file (e.g. 'spss' or 'sas').

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

Aninteger. The unique identifier of the series within the BETS database.

data

Adata.frame or ats. Contains the data to be written. Ifdata is supplied, the BETS database will not be searched.

file.name

Acharacter. The name of the output file. The default is 'series.sas'.

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

Aninteger. The unique identifier of the series within the BETS database.

data

Adata.frame or ats. Contains the data to be written. Ifdata is supplied, the BETS database will not be searched.

file.name

Acharacter. The name of the output file. The default is 'series.spss'.

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

Aninteger. The unique identifier of the series within the BETS database.

data

Adata.frame or ats. Contains the data to be written. Ifdata is supplied, the BETS database will not be searched.

file.name

Acharacter. The name of the output file. The default is 'series.dta'.

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 classificationcodes 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 = 583sidra = 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

Acharacter argument. Function searches the Sidra metadata and prints results in a window.

code

A numeric argument must be provided. The descriptions of the given table are returned.

view

Aboolean. The default isTRUE. If set toFALSE, the results are NOT going to be shown.

browse

Aboolean. If browse is set toTRUE, the description table opens in your browser for better visualization.

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 anArima or anarima. In a near future, this function will also accept objects returned bygrnn.train.

Usage

std_resid(model, alpha = 0.05)

Arguments

model

AnArima or anarima object. The model.

alpha

Anumeric between 0 and 1. The significance level.

Value

Besides showing the plot, this function returns anumeric vector containing the standardized residuals.

Author(s)

Talitha Speranzatalitha.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 anArima or anarima.

Usage

t_test(model, nx = 0, alpha = 0.05)

Arguments

model

AnArima or anarima object. The model for which the parameters must be tested.

nx

Aninteger. The number of exogenous variables

alpha

Anumeric value between 0 and 1. The significance level.

Value

Adata.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 Speranzatalitha.speranza@fgv.br, Daiane Marcolinodaiane.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

Acharacter. The type of the test. Set it to 'ADF' for Augmented Dickey-Fuller, 'KPSS' for KPSS or 'PP' for Phillips-Perron.

level

Acharacter. The confidence level. Can be either '1pct' (not for KPSS), '2.5pct', '5pct' or '10pct'

Value

Alist object. The first element is adata.frame with the test statistics, the critical values and the test results. The second, the model residuals.

Author(s)

Talitha Speranzatalitha.speranza@fgv.br


[8]ページ先頭

©2009-2025 Movatter.jp