*! version 1.1.2 07oct2022

Title

xtmipolateu -- Replace missing values in a time series,
two- or multidimensional varlist with interpolated (extrapolated) ones
and prepare a corresponding report document

Syntax

xtmipolateu
[varlist]
[if] [in]
[, options]

Mipolate-related
i(varlist:varlist) use varlist as dimensions
(grouped by egen group) (omittable)

t(varname:varname_t) use varname_t as the time
variable

* (mipolate options) none or all options
from (SSC) mipolate

Exporting
export(... [using] filename, ...) export
descriptive statistics to filename
(omittable)

Reporting
put(strings:docx|pdf) "docx" or "pdf" (omittable)

pbreak add a page break between each graph
and table (omittable)

nformat(%fmt) specify numeric format
for cell text (omittable)

saving(filename, ...) save
the report document to filename (omittable)

by is not allowed; see [D] by.

weights are not allowed; see weight.

Description

xtmipolateu replaces missing values in a time series, two- or
multidimensional varlist with interpolated (extrapolated) ones using
(SSC) mipolate, at the same time allowing the user to export
related descriptive statistics (mean, sd, min and max) collected with (SSC)
summarizeby (an extension of statsby for summarize
with the same syntax but no ": command") and to write
corresponding tsline or xtline graphs and
tables with these statistics into a new or existing
report document using putdocx or putpdf, keeping it open or
saving it and finishing work.

The user can change the style of the report document by typing a customized
putdocx begin or putpdf begin prior to running
xtmipolateu or with putdocx table or putpdf table
after the command has finished running. The name of each table
in the document is identical to each varname in the varlist.

Options

"i(varlist:varlist)" is a varlist used as non-time dimension(s)
for panel and multidimensional data. This option should be a) omitted
for time series, b) varname for panel data and c) varlist
for multidimensional data. Multidimensional data are treated as panel data
with a group variable, generated from varlist using
egen group, missing label.

"t(varname:varname_t)" is a varname used as the time dimension
for a) time series, b) panel and c) multidimensional data, and so
non-omittable. The varname should have the correct
date and time type and format.

* (mipolate options) are none or all options
from (SSC) mipolate such as pchip, groupwise or
epolate with the exception of generate() which is handled internally
and will be ignored (if typed after comma in the command). The user is
expected to having read help on mipolate.

export(... [using] filename, ...) is an
everything-like string forwarded
to export. The descriptive statistics (mean, sd, min and max)
are collected by dimensions specified in i(varlist) with (SSC)
summarizeby (an extension of statsby for summarize
with the same syntax but no ": command")
for both interpolated (extrapolated) and original data allowing to compare
and contrast both. The output file can be
CSV,
Microsoft Excel or any other
supported file type .

put(strings:docx|pdf) is string with two possible
values, "docx" and "pdf". Depending on its value, a report document using
putdocx or putpdf is either created (if putdocx begin
or putpdf begin are not specified by user in advance) or appended
(otherwise).

pbreak adds a page break between each graph
and table in the report document, its usage is optional. These page breaks
are not useful except for a big number of groups generated from
i(varlist).

nformat(%fmt) sets the numeric format for cell text
of each table in the report document. The default format is "%9.2f".

saving(filename, ...) is an
everything-like string forwarded
to putdocx save or
putdpdf save. This option should
be omitted if work with the report document is expected to continue, and
the file must be saved manually by the user using the aforementioned
commands.

Remarks

Please install summarizeby before using xtmipolateu.

For detailed information on mipolate, see mipolate.

Examples

. sysuse xtline1.dta, clear
. replace calories = . if ! mod(_n, 5) | ! mod(_n, 14)

* pure mipolate:
. xtmipolateu calories, i(person) t(day) spline

* export descriptive statistics to "./stats.csv"
. xtmipolateu calories, i(person) t(day) nearest export(delimited using "./stats.csv", replace)

* create a report file "./report.docx"
. xtmipolateu calories, i(person) t(day) spline epolate put("docx") sa("./report.docx", replace)

* create a report file "./report.pdf" with a custom style
. set scheme economist
. putpdf begin, landscape font("Verdana")
. xtmipolateu calories, i(person) t(day) epolate put("pdf") pbr sa("./report.pdf", replace)

Author

Ilya Bolotov

Prague University of Economics and Business

Prague, Czech Republic

ilya.bolotov@vse.cz

Thanks for citing this software and my works on the topic:

Bolotov, I. (2020). XTMIPOLATEU: Stata module to replace missing values in a
time series, two- or multidimensional varlist with interpolated
(extrapolated) ones. Available from
https://ideas.repec.org/c/boc/bocode/s458881.html.