| Type: | Package |
| Title: | Divisia Monetary Aggregates Index |
| Version: | 1.0.0 |
| Date: | 2026-11-05 |
| 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. |
| License: | GPL-2 |
| URL: | https://myaseen208.com/dmai/, https://github.com/myaseen208/dmai |
| BugReports: | https://github.com/myaseen208/dmai/issues |
| Encoding: | UTF-8 |
| Language: | en-US |
| LazyData: | true |
| Depends: | R (≥ 4.2) |
| Imports: | data.table, ggplot2, grDevices, scales, stats, utils |
| Suggests: | bslib, DT, knitr, magick, pkgload, quarto, ragg, R.rsp, shiny, svglite, testthat (≥ 3.0.0), withr |
| VignetteBuilder: | quarto, R.rsp |
| Config/testthat/edition: | 3 |
| Config/skill/prefix: | dmai |
| RoxygenNote: | 7.3.1 |
| NeedsCompilation: | no |
| Packaged: | 2026-11-09 02:01:43 UTC; myaseen208 |
| Author: | Muhammad Yaseen |
| Maintainer: | Muhammad Yaseen <myaseen208@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-09 08:50:17 UTC |
dmai: Divisia monetary aggregates index
Description
The dmai package builds monetary aggregates from their components (currency, demand deposits, savings and time deposits, ...) by the methods of index number theory. The Divisia index of Barnett (1980) weights every component by its share in the expenditure on monetary services, priced by its user cost (Barnett 1978); the package also gives the Fisher ideal index, a variant with simple growth rates, the simple sum and the currency equivalent index, the dual user-cost price index and the Divisia second moments.
Functions
dmai()the aggregate by one method (Barnett, Hancock, Fisher, simple sum, currency equivalent).
dmai_compare()every method on the same data.
dmai_user_cost()user costs and expenditure shares of the components.
dmai_moments()Divisia means and variances of the growth of the components.
dmai_interpret(),dmai_cite(),dmai_app()plain-language interpretation, references and a shiny application.
The data sets money_sim (simulated monetary data) and cpi_ch19 (the artificial data
of the Consumer Price Index Manual, used to check the index formulas) come with the package.
Author(s)
Muhammad Yaseen (myaseen208@gmail.com) and Ahmad Nadeem (Ahmed.Nadeem@sbp.org.pk)
References
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
See Also
Useful links:
Report bugs at https://github.com/myaseen208/dmai/issues
Plot a dmai result with ggplot2
Description
autoplot() methods for the results of dmai; plot() draws the same figures.
Usage
autoplot.dmai_result(object, which = NULL, ...)
Arguments
object |
a result of |
which |
the figure: for |
... |
not used. |
Value
A ggplot object.
Author(s)
Muhammad Yaseen (myaseen208@gmail.com)
Examples
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"
)
Artificial price and quantity data of the Consumer Price Index Manual
Description
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).
Usage
cpi_ch19
Format
A data frame with 5 rows and 13 columns: period (1 to 5), p1, ..., p6 (prices)
and q1, ..., q6 (quantities).
Source
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.
See Also
Other dmai data:
money_sim
Examples
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
)
Divisia monetary aggregates index
Description
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.
Usage
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
)
Arguments
.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; |
Details
With quantities x_{it} of components i = 1, \dots, n at dates t, their
rates of return r_{it} and the benchmark rate R_t, the user cost of component i
is
\pi_{it} = \frac{R_t - r_{it}}{1 + R_t}
(Barnett 1978) and its
expenditure share s_{it} = \pi_{it}x_{it} / \sum_j \pi_{jt}x_{jt}.
With \bar{s}_{it} = (s_{it} + s_{i,t-1})/2, the methods are
"Barnett"the Divisia index in the discrete form of Tornqvist and Theil (Barnett 1980):
\log\frac{Q_t}{Q_{t-1}} = \sum_i \bar{s}_{it}\left(\log x_{it} - \log x_{i,t-1}\right)."Hancock"the same shares with simple growth rates (as in version 0.5.0):
\frac{Q_t}{Q_{t-1}} - 1 = \sum_i \bar{s}_{it}\left(\frac{x_{it}}{x_{i,t-1}} - 1\right)."Fisher"the Fisher ideal index, the geometric mean of the Laspeyres and Paasche indexes with the user costs as prices (Fisher 1922; Diewert 1976):
\frac{Q_t}{Q_{t-1}} = \left(\frac{\sum_i \pi_{i,t-1}x_{it}}{\sum_i \pi_{i,t-1}x_{i,t-1}}\cdot\frac{\sum_i \pi_{it}x_{it}}{\sum_i \pi_{it}x_{i,t-1}}\right)^{1/2}."SimpleSum"the official aggregate
\sum_i x_{it}."CE"the currency equivalent index
\sum_i (R_t - r_{it})x_{it}/R_t(Rotemberg, Driscoll and Poterba 1995; Barnett 1991).
All indexes are chained and equal base at the first date. The growth DMAI is
100\log(Q_t/Q_{t-1})/\log(\mathrm{logbase}), in percent for the
natural logarithm, and 100(Q_t/Q_{t-1} - 1) 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 1/(1 + R_t) is common to
the components and does not change the shares.
The dual user-cost price index follows by factor reversal, P_t = E_t / V_t, with the
expenditure E_t = \sum_i \pi_{it}x_{it} and the aggregate V_t in the
units of x (column value).
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.
Author(s)
Muhammad Yaseen (myaseen208@gmail.com) and Ahmad Nadeem (Ahmed.Nadeem@sbp.org.pk)
References
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.
See Also
dmai_compare, dmai_user_cost, dmai_moments,
dmai_interpret, money_sim
Other dmai analyses:
dmai_compare(),
dmai_moments(),
dmai_user_cost()
Examples
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)
Methods for dmai results
Description
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.
Usage
## 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, ...)
Arguments
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). |
Value
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.
Author(s)
Muhammad Yaseen (myaseen208@gmail.com)
Monetary aggregates in a web browser
Description
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.
Usage
dmai_app(launch.browser = interactive(), ...)
dmai_app_object()
Arguments
launch.browser |
passed to |
... |
further arguments to |
Details
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.
Value
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).
Author(s)
Muhammad Yaseen (myaseen208@gmail.com)
See Also
dmai, dmai_compare, dmai_interpret
Examples
if (interactive()) {
dmai_app(
launch.browser = TRUE
)
}
References of a result or of the package
Description
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.
Usage
dmai_cite(x = NULL, style = c("text", "bibtex"))
## Default S3 method:
dmai_cite(x = NULL, style = c("text", "bibtex"))
Arguments
x |
a result of a function of the package (with |
style |
|
Value
An object of class bibentry (printed in the chosen style).
Author(s)
Muhammad Yaseen (myaseen208@gmail.com)
Examples
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"
)
Monetary aggregates by every method
Description
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.
Usage
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
)
Arguments
.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). |
Value
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").
Author(s)
Muhammad Yaseen (myaseen208@gmail.com)
References
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
See Also
Other dmai analyses:
dmai(),
dmai_moments(),
dmai_user_cost()
Examples
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)
Plain-language interpretation of a result
Description
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().
Usage
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), ...)
Arguments
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 |
Details
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.
Value
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.
Author(s)
Muhammad Yaseen (myaseen208@gmail.com)
See Also
Examples
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
)
Divisia second moments
Description
dmai_moments() gives the Divisia mean and variance of the growth rates of the components at every date
(Theil 1967; Barnett and Serletis 1990):
\kappa_t = \sum_i \bar{s}_{it}\,\Delta\log x_{it}, \qquad K_t =
\sum_i \bar{s}_{it}\left(\Delta\log x_{it} - \kappa_t\right)^2,
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.
Usage
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, ...)
Arguments
.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 |
Value
An object of class c("dmai_moments", "dmai_result", "list"): moments (a data.table
with the date, growth = 100\kappa_t, variance = 10^4K_t,
sd, price_growth and price_variance) and settings. plot() draws the
standard deviation over time.
Author(s)
Muhammad Yaseen (myaseen208@gmail.com)
References
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.
See Also
Other dmai analyses:
dmai(),
dmai_compare(),
dmai_user_cost()
Examples
data(money_sim)
m <-
dmai_moments(
.data = money_sim
, benchmark = "rb"
)
m
plot(x = m)
Notation of dmai
Description
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 (P, R), indices lower-case italic (i, j), vectors lower-case bold
(\mathbf{y}, \boldsymbol{\beta}) and matrices upper-case bold (\mathbf{X},
\boldsymbol{\Sigma}).
Usage
dmai_notation(format = c("table", "path", "tex"))
Arguments
format |
|
Value
See format.
Author(s)
Muhammad Yaseen (myaseen208@gmail.com)
See Also
Other dmai utilities:
dmai_reference(),
dmai_save(),
dmai_theme()
Examples
dmai_notation(
format = c("table", "path", "tex")[1]
)
Published values used by the tests and vignettes
Description
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.
Usage
dmai_reference(source = NULL, evaluate = FALSE, level = 1)
Arguments
source |
optional regular expression; keep rows whose |
evaluate |
logical; evaluate the rows and add columns |
level |
largest |
Value
A data.table with columns id, source, quantity, call, extract,
value, digits, level, note (and computed, agrees).
Author(s)
Muhammad Yaseen (myaseen208@gmail.com)
See Also
Other dmai utilities:
dmai_notation(),
dmai_save(),
dmai_theme()
Examples
ref <-
dmai_reference(
source = NULL
, evaluate = FALSE
, level = 1
)
ref
dmai_reference(
source = "."
, evaluate = TRUE
, level = 1
)
Save a figure (vector PDF by default)
Description
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, ...).
Usage
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,
...
)
Arguments
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 |
Value
The file name, invisibly.
Author(s)
Muhammad Yaseen (myaseen208@gmail.com)
See Also
Other dmai utilities:
dmai_notation(),
dmai_reference(),
dmai_theme()
Examples
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
)
ggplot2 theme of dmai
Description
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.
Usage
dmai_theme(
base_size = 11,
base_family = "serif",
ticks_inward = TRUE,
legend_position = "bottom"
)
Arguments
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 |
Value
A ggplot2 theme.
Author(s)
Muhammad Yaseen (myaseen208@gmail.com)
See Also
Other dmai utilities:
dmai_notation(),
dmai_reference(),
dmai_save()
Examples
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))
User costs and expenditure shares of monetary assets
Description
dmai_user_cost() gives, for every date and component, the rate, the user cost
\pi_{it} = (R_t - r_{it})/(1 + R_t) (Barnett 1978) and the share of the
component in the expenditure on monetary services, the weights of the Divisia index.
Usage
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
)
Arguments
.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 |
Value
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.
Author(s)
Muhammad Yaseen (myaseen208@gmail.com)
References
Barnett, W. A. (1978). The user cost of money. Economics Letters, 1(2), 145–149. doi:10.1016/0165-1765(78)90051-4
See Also
Other dmai analyses:
dmai(),
dmai_compare(),
dmai_moments()
Examples
data(money_sim)
uc <-
dmai_user_cost(
.data = money_sim
, date = "Date"
, x = NULL
, r = NULL
, benchmark = "rb"
, percent = TRUE
)
uc
plot(x = uc)
Simulated monetary components and rates
Description
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.
Usage
money_sim
Format
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
x1in percent (zero).r2the own rate of
x2in percent (zero).r3the own rate of
x3in percent.r4the own rate of
x4in percent.r5the own rate of
x5in percent.r6the own rate of
x6in percent.r7the own rate of
x7in percent.r8the own rate of
x8in percent.rbthe benchmark rate in percent (a long bond yield), above every component rate.
Source
Simulated; see data-raw/make-data.R.
See Also
Other dmai data:
cpi_ch19
Examples
data(money_sim)
head(money_sim)