| Title: | Divisia Monetary Aggregates Index |
|---|---|
| Description: | Builds monetary aggregates from their components by the methods of index number theory. The Divisia index of Barnett (1980) <doi:10.1016/0304-4076(80)90070-6> weights every component (currency, demand deposits, savings and time deposits, ...) by its share in the expenditure on monetary services, priced by its user cost (Barnett 1978) <doi:10.1016/0165-1765(78)90051-4>. Also gives the Fisher ideal index, a variant with simple growth rates, the simple-sum aggregate, the currency equivalent index of Rotemberg, Driscoll and Poterba (1995), the dual user-cost price index and the Divisia second moments of Barnett and Serletis (1990) <doi:10.1016/0304-4076(90)90104-2>; benchmark rates given or taken from the components (upper envelope); 'ggplot2' graphics, a plain-language interpretation of every result and a built-in 'shiny' application. |
| Authors: | Muhammad Yaseen [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-5923-1714>), Ahmad Nadeem [aut, ctb] |
| Maintainer: | Muhammad Yaseen <[email protected]> |
| License: | GPL-2 |
| Version: | 1.0.0 |
| Built: | 2026-11-06 07:10:54 UTC |
| Source: | https://github.com/myaseen208/dmai |
autoplot() methods for the results of dmai; plot() draws the same figures.
autoplot.dmai_result(object, which = NULL, ...)autoplot.dmai_result(object, which = NULL, ...)
object |
a result of |
which |
the figure: for |
... |
not used. |
A ggplot object.
Muhammad Yaseen ([email protected])
data(money_sim) fit <- dmai( .data = money_sim , method = "Barnett" , logbase = NULL , date = "Date" , x = NULL , r = NULL , user_cost = NULL , benchmark = "rb" , percent = TRUE , base = 100 , as_dt = FALSE ) ggplot2::autoplot( object = fit , which = "shares" )data(money_sim) fit <- dmai( .data = money_sim , method = "Barnett" , logbase = NULL , date = "Date" , x = NULL , r = NULL , user_cost = NULL , benchmark = "rb" , percent = TRUE , base = 100 , as_dt = FALSE ) ggplot2::autoplot( object = fit , which = "shares" )
The artificial data set of Chapter 19 of the Consumer Price Index Manual (ILO et al. 2004, Tables 19.1 and
19.2): prices and quantities of six commodities in five periods. The Manual gives the chained Laspeyres,
Paasche, Fisher and Tornqvist price indexes of these data (Tables 19.5 and 19.11), which the package reproduces:
a Divisia quantity index is a Tornqvist index with the user costs as prices, so dmai() with the
prices as x and the quantities as user_cost gives the Manual's price indexes (the two roles are
symmetric in these formulas).
cpi_ch19cpi_ch19
A data frame with 5 rows and 13 columns: period (1 to 5), p1, ..., p6 (prices)
and q1, ..., q6 (quantities).
ILO, IMF, OECD, UNECE, Eurostat and The World Bank (2004). Consumer Price Index Manual: Theory and Practice. International Labour Office, Geneva. Chapter 19, Tables 19.1 and 19.2.
Other dmai data:
money_sim
data(cpi_ch19) # the chained Tornqvist price index of Table 19.11: 1, 1.4052, 1.3112, 1.2624, 1.2224 dmai( .data = cpi_ch19 , method = "Barnett" , logbase = NULL , date = "period" , x = paste0("p", 1:6) , r = NULL , user_cost = paste0("q", 1:6) , benchmark = NULL , percent = TRUE , base = 1 , as_dt = TRUE )data(cpi_ch19) # the chained Tornqvist price index of Table 19.11: 1, 1.4052, 1.3112, 1.2624, 1.2224 dmai( .data = cpi_ch19 , method = "Barnett" , logbase = NULL , date = "period" , x = paste0("p", 1:6) , r = NULL , user_cost = paste0("q", 1:6) , benchmark = NULL , percent = TRUE , base = 1 , as_dt = TRUE )
dmai() aggregates monetary assets (currency, deposits, ...) into one index of monetary services. Each
component is weighted by its share in the expenditure on monetary services, priced by its user cost (Barnett
1978, 1980): an asset that pays a rate close to the benchmark rate is held mostly as a store of value and gets a
small weight, while currency and demand deposits get a large one. The simple sum, which weights every component
equally, and the currency equivalent index are given for comparison.
dmai( .data, method = c("Barnett", "Hancock", "Fisher", "SimpleSum", "CE"), logbase = NULL, date = "Date", x = NULL, r = NULL, user_cost = NULL, benchmark = NULL, percent = TRUE, base = 100, as_dt = TRUE ) ## Default S3 method: dmai( .data, method = c("Barnett", "Hancock", "Fisher", "SimpleSum", "CE"), logbase = NULL, date = "Date", x = NULL, r = NULL, user_cost = NULL, benchmark = NULL, percent = TRUE, base = 100, as_dt = TRUE )dmai( .data, method = c("Barnett", "Hancock", "Fisher", "SimpleSum", "CE"), logbase = NULL, date = "Date", x = NULL, r = NULL, user_cost = NULL, benchmark = NULL, percent = TRUE, base = 100, as_dt = TRUE ) ## Default S3 method: dmai( .data, method = c("Barnett", "Hancock", "Fisher", "SimpleSum", "CE"), logbase = NULL, date = "Date", x = NULL, r = NULL, user_cost = NULL, benchmark = NULL, percent = TRUE, base = 100, as_dt = TRUE )
.data |
a data frame with one row per date: a date column and, for every component, a quantity column and a
rate column (named |
method |
|
logbase |
base of the logarithm of the growth |
date |
name of the date column (default |
x |
names of the quantity columns (default |
r |
names of the rate columns, in the order of |
user_cost |
names of columns that give the user costs directly, in the order of |
benchmark |
the benchmark rate: |
percent |
logical; are the rates in percent (default |
base |
value of the index at the first date (default 100). |
as_dt |
logical; |
With quantities of components at dates , their
rates of return and the benchmark rate , the user cost of component
is
(Barnett 1978) and its
expenditure share .
With , the methods are
"Barnett"the Divisia index in the discrete form of Tornqvist and Theil (Barnett 1980):
"Hancock"the same shares with simple growth rates (as in version 0.5.0):
"Fisher"the Fisher ideal index, the geometric mean of the Laspeyres and Paasche indexes with the user costs as prices (Fisher 1922; Diewert 1976):
"SimpleSum"the official aggregate .
"CE"the currency equivalent index (Rotemberg, Driscoll and Poterba 1995; Barnett 1991).
All indexes are chained and equal base at the first date. The growth DMAI is
, in percent for the
natural logarithm, and for "Hancock".
The benchmark rate is the largest rate of the components at each date when benchmark = NULL (as in
version 0.5.0; that component then has a user cost of zero), or the given benchmark, raised to the largest
component rate where it is lower (the upper envelope). The factor is common to
the components and does not change the shares.
The dual user-cost price index follows by factor reversal, , with the
expenditure and the aggregate in the
units of (column value).
With as_dt = TRUE, a data.table with the date, DMAI (the growth in percent,
NA at the first date), index and value (the index in the units of x, equal to the
simple sum at the first date). With as_dt = FALSE, an object of class c("dmai_index",
"dmai_result", "list") with index (that table), components (quantities, rates, user costs and
shares by date), benchmark, price (expenditure and dual price index), moments (see
dmai_moments()), simple_sum, fisher (Laspeyres and Paasche links, for
"Fisher") and settings. print(), plot(), ggplot2::autoplot() and
dmai_interpret() apply.
Muhammad Yaseen ([email protected]) and Ahmad Nadeem ([email protected])
Barnett, W. A. (1978). The user cost of money. Economics Letters, 1(2), 145–149. doi:10.1016/0165-1765(78)90051-4
Barnett, W. A. (1980). Economic monetary aggregates: an application of index number and aggregation theory. Journal of Econometrics, 14(1), 11–48. doi:10.1016/0304-4076(80)90070-6
Diewert, W. E. (1976). Exact and superlative index numbers. Journal of Econometrics, 4(2), 115–145. doi:10.1016/0304-4076(76)90009-9
Hancock, D. (1985). The financial firm: production with monetary and nonmonetary goods. Journal of Political Economy, 93(5), 859–880. doi:10.1086/261339
Rotemberg, J. J., Driscoll, J. C. and Poterba, J. M. (1995). Money, output, and prices: evidence from a new monetary aggregate. Journal of Business and Economic Statistics, 13(1), 67–83.
dmai_compare, dmai_user_cost, dmai_moments,
dmai_interpret, money_sim
Other dmai analyses:
dmai_compare(),
dmai_moments(),
dmai_user_cost()
data(money_sim) d <- dmai( .data = money_sim , method = "Barnett" , logbase = NULL , date = "Date" , x = NULL , r = NULL , user_cost = NULL , benchmark = "rb" , percent = TRUE , base = 100 , as_dt = TRUE ) d fit <- dmai( .data = money_sim , method = "Barnett" , logbase = NULL , date = "Date" , x = NULL , r = NULL , user_cost = NULL , benchmark = "rb" , percent = TRUE , base = 100 , as_dt = FALSE ) fit plot(x = fit)data(money_sim) d <- dmai( .data = money_sim , method = "Barnett" , logbase = NULL , date = "Date" , x = NULL , r = NULL , user_cost = NULL , benchmark = "rb" , percent = TRUE , base = 100 , as_dt = TRUE ) d fit <- dmai( .data = money_sim , method = "Barnett" , logbase = NULL , date = "Date" , x = NULL , r = NULL , user_cost = NULL , benchmark = "rb" , percent = TRUE , base = 100 , as_dt = FALSE ) fit plot(x = fit)
dmai_app() starts the application of dmai: load the components of a monetary aggregate (the
simulated example money_sim or a CSV file), choose the quantity and rate columns and the benchmark
rate, compute the Divisia or another index, compare all methods, inspect the user costs, weights and Divisia
second moments. Every result page shows an interpretation computed from the results
(dmai_interpret()), the output as R prints it, formatted tables, plots and the R code that repeats the
analysis, each with a Copy button.
dmai_app(launch.browser = interactive(), ...) dmai_app_object()dmai_app(launch.browser = interactive(), ...) dmai_app_object()
launch.browser |
passed to |
... |
further arguments to |
The application needs the suggested packages shiny, bslib and DT. Plots are sent to the browser as WebP images when magick is installed (smaller than PNG; PNG otherwise) and can be downloaded as PNG, PDF or WebP. Text is set in IBM Plex Sans and output in IBM Plex Mono when the browser can reach Google Fonts, in the system fonts otherwise. A CSV file needs one row per date: a date column (read as a date when it looks like one) and a quantity and a rate column for every component.
dmai_app() is called for its side effect and returns the value of shiny::runApp() when the
application is closed; dmai_app_object() returns the application object (for shiny::runApp(),
shiny::testServer() or deployment on a server).
Muhammad Yaseen ([email protected])
dmai, dmai_compare, dmai_interpret
if (interactive()) { dmai_app( launch.browser = TRUE ) }if (interactive()) { dmai_app( launch.browser = TRUE ) }
dmai_cite() gives the references of the methods behind a result of the package, or the references of every
method in the package, as text or BibTeX. citation("dmai") cites the package and its main methods.
dmai_cite(x = NULL, style = c("text", "bibtex")) ## Default S3 method: dmai_cite(x = NULL, style = c("text", "bibtex"))dmai_cite(x = NULL, style = c("text", "bibtex")) ## Default S3 method: dmai_cite(x = NULL, style = c("text", "bibtex"))
x |
a result of a function of the package (with |
style |
|
An object of class bibentry (printed in the chosen style).
Muhammad Yaseen ([email protected])
dmai_cite( x = NULL , style = "text" ) data(money_sim) fit <- dmai( .data = money_sim , method = "Fisher" , logbase = NULL , date = "Date" , x = NULL , r = NULL , user_cost = NULL , benchmark = "rb" , percent = TRUE , base = 100 , as_dt = FALSE ) dmai_cite( x = fit , style = "bibtex" )dmai_cite( x = NULL , style = "text" ) data(money_sim) fit <- dmai( .data = money_sim , method = "Fisher" , logbase = NULL , date = "Date" , x = NULL , r = NULL , user_cost = NULL , benchmark = "rb" , percent = TRUE , base = 100 , as_dt = FALSE ) dmai_cite( x = fit , style = "bibtex" )
dmai_compare() computes the Divisia (Barnett and Hancock), Fisher ideal, simple-sum and currency
equivalent aggregates of the same data, as indexes equal to base at the first date, with their growth
rates and average annual growth.
dmai_compare( .data, methods = c("Barnett", "Hancock", "Fisher", "SimpleSum", "CE"), logbase = NULL, date = "Date", x = NULL, r = NULL, user_cost = NULL, benchmark = NULL, percent = TRUE, base = 100 ) ## Default S3 method: dmai_compare( .data, methods = c("Barnett", "Hancock", "Fisher", "SimpleSum", "CE"), logbase = NULL, date = "Date", x = NULL, r = NULL, user_cost = NULL, benchmark = NULL, percent = TRUE, base = 100 )dmai_compare( .data, methods = c("Barnett", "Hancock", "Fisher", "SimpleSum", "CE"), logbase = NULL, date = "Date", x = NULL, r = NULL, user_cost = NULL, benchmark = NULL, percent = TRUE, base = 100 ) ## Default S3 method: dmai_compare( .data, methods = c("Barnett", "Hancock", "Fisher", "SimpleSum", "CE"), logbase = NULL, date = "Date", x = NULL, r = NULL, user_cost = NULL, benchmark = NULL, percent = TRUE, base = 100 )
.data |
a data frame with one row per date: a date column and, for every component, a quantity column and a
rate column (named |
methods |
the methods to compare (default: all five; |
logbase |
base of the logarithm of the growth |
date |
name of the date column (default |
x |
names of the quantity columns (default |
r |
names of the rate columns, in the order of |
user_cost |
names of columns that give the user costs directly, in the order of |
benchmark |
the benchmark rate: |
percent |
logical; are the rates in percent (default |
base |
value of the index at the first date (default 100). |
An object of class c("dmai_compare", "dmai_result", "list"): indexes (a long
data.table: date, method, index, growth), summary (by method: average growth per period and per
year, standard deviation of growth, last index value) and settings. plot() draws the indexes or
their growth (which = "growth").
Muhammad Yaseen ([email protected])
Barnett, W. A. (1980). Economic monetary aggregates: an application of index number and aggregation theory. Journal of Econometrics, 14(1), 11–48. doi:10.1016/0304-4076(80)90070-6
Other dmai analyses:
dmai(),
dmai_moments(),
dmai_user_cost()
data(money_sim) cmp <- dmai_compare( .data = money_sim , methods = c("Barnett", "Hancock", "Fisher", "SimpleSum", "CE") , logbase = NULL , date = "Date" , x = NULL , r = NULL , user_cost = NULL , benchmark = "rb" , percent = TRUE , base = 100 ) cmp plot(x = cmp)data(money_sim) cmp <- dmai_compare( .data = money_sim , methods = c("Barnett", "Hancock", "Fisher", "SimpleSum", "CE") , logbase = NULL , date = "Date" , x = NULL , r = NULL , user_cost = NULL , benchmark = "rb" , percent = TRUE , base = 100 ) cmp plot(x = cmp)
dmai_interpret() turns a result of the package into a short report: a headline, findings, recommendations
and cautions, computed from its numbers, with the sources of the method. It covers dmai() (with
as_dt = FALSE), dmai_compare(), dmai_user_cost() and
dmai_moments().
dmai_interpret(x, top = 3L, ...) ## Default S3 method: dmai_interpret(x, top = 3L, ...) ## S3 method for class 'dmai_interpretation' print(x, ...) ## S3 method for class 'dmai_interpretation' format(x, style = c("text", "markdown"), width = getOption("width", 80L), ...)dmai_interpret(x, top = 3L, ...) ## Default S3 method: dmai_interpret(x, top = 3L, ...) ## S3 method for class 'dmai_interpretation' print(x, ...) ## S3 method for class 'dmai_interpretation' format(x, style = c("text", "markdown"), width = getOption("width", 80L), ...)
x |
a result of a function of the package. |
top |
number of dates or components named in the findings (default 3). |
... |
unused. |
style |
|
width |
line width of the text (default |
Growth per year is the average growth between the first and last dates, annualised with the spacing of the
dates (monthly, quarterly, half-yearly or annual) when the date column is of class Date; otherwise growth
is reported per period.
An object of class "dmai_interpretation": a list with analysis, title,
headline, findings, recommendations, cautions, facts (the numbers behind the
sentences), guide (how to read the method) and sources. format() gives it as text or
Markdown.
Muhammad Yaseen ([email protected])
data(money_sim) fit <- dmai( .data = money_sim , method = "Barnett" , logbase = NULL , date = "Date" , x = NULL , r = NULL , user_cost = NULL , benchmark = "rb" , percent = TRUE , base = 100 , as_dt = FALSE ) dmai_interpret( x = fit , top = 3 )data(money_sim) fit <- dmai( .data = money_sim , method = "Barnett" , logbase = NULL , date = "Date" , x = NULL , r = NULL , user_cost = NULL , benchmark = "rb" , percent = TRUE , base = 100 , as_dt = FALSE ) dmai_interpret( x = fit , top = 3 )
dmai_moments() gives the Divisia mean and variance of the growth rates of the components at every date
(Theil 1967; Barnett and Serletis 1990):
and the same for the user costs. A large variance means the components grow at very different rates, so that the choice of weights matters and the simple sum is a poor guide; Barnett and Serletis use it as a diagnostic of aggregation error.
dmai_moments(.data, ...) ## Default S3 method: dmai_moments( .data, ..., date = "Date", x = NULL, r = NULL, user_cost = NULL, benchmark = NULL, percent = TRUE ) ## S3 method for class 'dmai_index' dmai_moments(.data, ...)dmai_moments(.data, ...) ## Default S3 method: dmai_moments( .data, ..., date = "Date", x = NULL, r = NULL, user_cost = NULL, benchmark = NULL, percent = TRUE ) ## S3 method for class 'dmai_index' dmai_moments(.data, ...)
.data |
a data frame as in |
... |
further arguments of |
date |
name of the date column (default |
x |
names of the quantity columns (default |
r |
names of the rate columns, in the order of |
user_cost |
names of columns that give the user costs directly, in the order of |
benchmark |
the benchmark rate: |
percent |
logical; are the rates in percent (default |
An object of class c("dmai_moments", "dmai_result", "list"): moments (a data.table
with the date, growth = , variance = ,
sd, price_growth and price_variance) and settings. plot() draws the
standard deviation over time.
Muhammad Yaseen ([email protected])
Barnett, W. A. and Serletis, A. (1990). A dispersion-dependency diagnostic test for aggregation error: with applications to monetary economics and income distribution. Journal of Econometrics, 43(1–2), 5–34. doi:10.1016/0304-4076(90)90104-2
Theil, H. (1967). Economics and Information Theory. North-Holland, Amsterdam.
Other dmai analyses:
dmai(),
dmai_compare(),
dmai_user_cost()
data(money_sim) m <- dmai_moments( .data = money_sim , benchmark = "rb" ) m plot(x = m)data(money_sim) m <- dmai_moments( .data = money_sim , benchmark = "rb" ) m plot(x = m)
The symbols used in the help pages and vignettes of dmai, with their meaning and the argument or result
component that holds them. The notation follows one rule throughout: scalars are upper-case letters in normal
face (, ), indices lower-case italic (), vectors lower-case bold
(, ) and matrices upper-case bold (,
).
dmai_notation(format = c("table", "path", "tex"))dmai_notation(format = c("table", "path", "tex"))
format |
|
See format.
Muhammad Yaseen ([email protected])
Other dmai utilities:
dmai_reference(),
dmai_save(),
dmai_theme()
dmai_notation( format = c("table", "path", "tex")[1] )dmai_notation( format = c("table", "path", "tex")[1] )
Reads inst/extdata/reference.csv: one row per published number, with its source, the R call
that recomputes it with this package (call), the expression that extracts the number from the result
(extract, in terms of x), the printed value and the digits to compare. The same file drives the test
of published values and the vignette that reproduces the published examples. Each distinct call is evaluated once.
dmai_reference(source = NULL, evaluate = FALSE, level = 1)dmai_reference(source = NULL, evaluate = FALSE, level = 1)
source |
optional regular expression; keep rows whose |
evaluate |
logical; evaluate the rows and add columns |
level |
largest |
A data.table with columns id, source, quantity, call, extract,
value, digits, level, note (and computed, agrees).
Muhammad Yaseen ([email protected])
Other dmai utilities:
dmai_notation(),
dmai_save(),
dmai_theme()
ref <- dmai_reference( source = NULL , evaluate = FALSE , level = 1 ) ref dmai_reference( source = "." , evaluate = TRUE , level = 1 )ref <- dmai_reference( source = NULL , evaluate = FALSE , level = 1 ) ref dmai_reference( source = "." , evaluate = TRUE , level = 1 )
A wrapper of ggsave with the defaults of the package: a vector PDF through
cairo_pdf (embedded fonts, correct glyphs), A4 landscape (11.69 x 8.27 inches) and 600
dpi for raster formats. The device follows the file extension for other formats (.png, .svg,
.tiff, ...).
dmai_save( plot = ggplot2::last_plot(), filename, path = NULL, width = 11.69, height = 8.27, units = c("in", "cm", "mm"), dpi = 600, scale = 1, device = NULL, limitsize = TRUE, ... ) ## Default S3 method: dmai_save( plot = ggplot2::last_plot(), filename, path = NULL, width = 11.69, height = 8.27, units = c("in", "cm", "mm"), dpi = 600, scale = 1, device = NULL, limitsize = TRUE, ... )dmai_save( plot = ggplot2::last_plot(), filename, path = NULL, width = 11.69, height = 8.27, units = c("in", "cm", "mm"), dpi = 600, scale = 1, device = NULL, limitsize = TRUE, ... ) ## Default S3 method: dmai_save( plot = ggplot2::last_plot(), filename, path = NULL, width = 11.69, height = 8.27, units = c("in", "cm", "mm"), dpi = 600, scale = 1, device = NULL, limitsize = TRUE, ... )
plot |
a |
filename |
file name; its extension chooses the format. |
path |
directory to save in (default |
width, height
|
size (default 11.69 x 8.27, A4 landscape, in |
units |
|
dpi |
resolution for raster formats (default 600). |
scale |
multiplicative scaling factor (default 1). |
device |
|
limitsize |
logical; refuse images larger than 50 x 50 inches (default |
... |
passed to |
The file name, invisibly.
Muhammad Yaseen ([email protected])
Other dmai utilities:
dmai_notation(),
dmai_reference(),
dmai_theme()
library(ggplot2) p <- ggplot(data = data.frame(x = 1:10, y = (1:10)^2), mapping = aes(x = x, y = y)) + geom_line() + dmai_theme( base_size = 11 , base_family = "serif" , ticks_inward = TRUE , legend_position = "bottom" ) f <- tempfile(fileext = ".pdf") dmai_save( plot = p , filename = f , path = NULL , width = 11.69 , height = 8.27 , units = c("in", "cm", "mm")[1] , dpi = 600 , scale = 1 , device = NULL , limitsize = TRUE ) dmai_save( plot = p , filename = basename(f) , path = tempdir() , width = 11.69 , height = 8.27 , units = c("in", "cm", "mm")[1] , dpi = 600 , scale = 1 , device = grDevices::cairo_pdf , limitsize = TRUE ) dmai_save( plot = p , filename = tempfile(fileext = ".png") , path = NULL , width = 6 , height = 4 , units = c("in", "cm", "mm")[1] , dpi = 300 , scale = 1 , device = NULL , limitsize = TRUE )library(ggplot2) p <- ggplot(data = data.frame(x = 1:10, y = (1:10)^2), mapping = aes(x = x, y = y)) + geom_line() + dmai_theme( base_size = 11 , base_family = "serif" , ticks_inward = TRUE , legend_position = "bottom" ) f <- tempfile(fileext = ".pdf") dmai_save( plot = p , filename = f , path = NULL , width = 11.69 , height = 8.27 , units = c("in", "cm", "mm")[1] , dpi = 600 , scale = 1 , device = NULL , limitsize = TRUE ) dmai_save( plot = p , filename = basename(f) , path = tempdir() , width = 11.69 , height = 8.27 , units = c("in", "cm", "mm")[1] , dpi = 600 , scale = 1 , device = grDevices::cairo_pdf , limitsize = TRUE ) dmai_save( plot = p , filename = tempfile(fileext = ".png") , path = NULL , width = 6 , height = 4 , units = c("in", "cm", "mm")[1] , dpi = 300 , scale = 1 , device = NULL , limitsize = TRUE )
The theme used by every plot() method of dmai (identical in all packages of the
author): theme_classic with a serif font, black axis lines, ticks pointing inwards and no
grid, close to the look of TikZ/pgfplots figures in LaTeX documents. The plot() methods also use
scales::pretty_breaks(n = 10) on every continuous axis. Save figures with dmai_save.
dmai_theme( base_size = 11, base_family = "serif", ticks_inward = TRUE, legend_position = "bottom" )dmai_theme( base_size = 11, base_family = "serif", ticks_inward = TRUE, legend_position = "bottom" )
base_size |
base font size in points (default 11). |
base_family |
font family (default |
ticks_inward |
logical; ticks point into the panel, as in pgfplots (default |
legend_position |
position of the legend (default |
A ggplot2 theme.
Muhammad Yaseen ([email protected])
Other dmai utilities:
dmai_notation(),
dmai_reference(),
dmai_save()
library(ggplot2) p <- ggplot(data = data.frame(x = 1:20, y = cumsum(sin(1:20))), mapping = aes(x = x, y = y)) + geom_line() p + dmai_theme( base_size = 11 , base_family = "serif" , ticks_inward = TRUE , legend_position = "bottom" ) p + dmai_theme( base_size = 12 , base_family = "serif" , ticks_inward = FALSE , legend_position = "right" ) + scale_x_continuous(breaks = scales::pretty_breaks(n = 10))library(ggplot2) p <- ggplot(data = data.frame(x = 1:20, y = cumsum(sin(1:20))), mapping = aes(x = x, y = y)) + geom_line() p + dmai_theme( base_size = 11 , base_family = "serif" , ticks_inward = TRUE , legend_position = "bottom" ) p + dmai_theme( base_size = 12 , base_family = "serif" , ticks_inward = FALSE , legend_position = "right" ) + scale_x_continuous(breaks = scales::pretty_breaks(n = 10))
dmai_user_cost() gives, for every date and component, the rate, the user cost
(Barnett 1978) and the share of the
component in the expenditure on monetary services, the weights of the Divisia index.
dmai_user_cost( .data, date = "Date", x = NULL, r = NULL, benchmark = NULL, percent = TRUE ) ## Default S3 method: dmai_user_cost( .data, date = "Date", x = NULL, r = NULL, benchmark = NULL, percent = TRUE )dmai_user_cost( .data, date = "Date", x = NULL, r = NULL, benchmark = NULL, percent = TRUE ) ## Default S3 method: dmai_user_cost( .data, date = "Date", x = NULL, r = NULL, benchmark = NULL, percent = TRUE )
.data |
a data frame with one row per date: a date column and, for every component, a quantity column and a
rate column (named |
date |
name of the date column (default |
x |
names of the quantity columns (default |
r |
names of the rate columns, in the order of |
benchmark |
the benchmark rate: |
percent |
logical; are the rates in percent (default |
An object of class c("dmai_user_cost", "dmai_result", "list"): components (date,
component, quantity, rate, user cost, share), benchmark (the benchmark rate and whether the upper
envelope raised it) and settings. plot() draws the shares over time.
Muhammad Yaseen ([email protected])
Barnett, W. A. (1978). The user cost of money. Economics Letters, 1(2), 145–149. doi:10.1016/0165-1765(78)90051-4
Other dmai analyses:
dmai(),
dmai_compare(),
dmai_moments()
data(money_sim) uc <- dmai_user_cost( .data = money_sim , date = "Date" , x = NULL , r = NULL , benchmark = "rb" , percent = TRUE ) uc plot(x = uc)data(money_sim) uc <- dmai_user_cost( .data = money_sim , date = "Date" , x = NULL , r = NULL , benchmark = "rb" , percent = TRUE ) uc plot(x = uc)
The analysis functions of dmai return the named list they have always returned, now with the class
c("dmai_<analysis>", "dmai_result", "list"). Components are read as before (x$ANOVA,
x[["Means"]]); the methods below print, summarise and plot the result and turn any component into a
data.table.
## S3 method for class 'dmai_result' print(x, digits = 4L, ...) ## S3 method for class 'dmai_result' summary(object, ...) ## S3 method for class 'summary.dmai_result' print(x, ...) ## S3 method for class 'dmai_result' format(x, ...) ## S3 method for class 'dmai_result' as.data.table(x, keep.rownames = FALSE, ..., component = 1L) ## S3 method for class 'dmai_result' as.data.frame(x, row.names = NULL, optional = FALSE, ..., component = 1L) ## S3 method for class 'dmai_result' plot(x, ...)## S3 method for class 'dmai_result' print(x, digits = 4L, ...) ## S3 method for class 'dmai_result' summary(object, ...) ## S3 method for class 'summary.dmai_result' print(x, ...) ## S3 method for class 'dmai_result' format(x, ...) ## S3 method for class 'dmai_result' as.data.table(x, keep.rownames = FALSE, ..., component = 1L) ## S3 method for class 'dmai_result' as.data.frame(x, row.names = NULL, optional = FALSE, ..., component = 1L) ## S3 method for class 'dmai_result' plot(x, ...)
x, object
|
a dmai result. |
digits |
significant digits of printed numbers (default 4). |
... |
passed on (to |
keep.rownames, row.names, optional
|
as in |
component |
name or number of the component to convert (default: the first one). |
print() returns x invisibly; summary() an object of class
summary.dmai_result; format() a character string; as.data.table() and
as.data.frame() the chosen component as a table; plot() a ggplot object.
Muhammad Yaseen ([email protected])
SIMULATED monthly data, January 2005 to December 2024, shaped like the components of a broad money aggregate of
a central bank: quantities (billions) and rates of return (percent a year) of eight components, and a benchmark
rate. The numbers are not real; they are drawn by data-raw/make-data.R in the source package (rates as
autoregressive processes that follow a policy-type rate, quantities as trending series that respond to the
spread between their own rate and the benchmark) to show the methods.
money_simmoney_sim
A data frame with 240 rows and 18 columns:
Datefirst day of the month (class Date).
x1currency in circulation.
x2demand deposits.
x3savings deposits.
x4time deposits up to 3 months.
x5time deposits of 3 to 6 months.
x6time deposits of 6 months to 1 year.
x7time deposits over 1 year.
x8foreign currency deposits.
r1the own rate of x1 in percent (zero).
r2the own rate of x2 in percent (zero).
r3the own rate of x3 in percent.
r4the own rate of x4 in percent.
r5the own rate of x5 in percent.
r6the own rate of x6 in percent.
r7the own rate of x7 in percent.
r8the own rate of x8 in percent.
rbthe benchmark rate in percent (a long bond yield), above every component rate.
Simulated; see data-raw/make-data.R.
Other dmai data:
cpi_ch19
data(money_sim) head(money_sim)data(money_sim) head(money_sim)